Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.api = WikipediaAPI(on_error=self.Error.api_error)
        self.result = None

        query_box = gui.hBox(self.controlArea, 'Query')

        # Queries configuration
        layout = QGridLayout()
        layout.setSpacing(7)

        row = 0
        self.query_edit = ListEdit(self, 'query_list',
                                   "Each line represents a "
                                   "separate query.", 100, self)
        layout.addWidget(QLabel('Query word list:'), row, 0, 1,
                         self.label_width)
        layout.addWidget(self.query_edit, row, self.label_width, 1,
                         self.widgets_width)

        # Language
        row += 1
        language_edit = ComboBox(self, 'language',
                                 tuple(sorted(lang2code.items())))
        layout.addWidget(QLabel('Language:'), row, 0, 1, self.label_width)
        layout.addWidget(language_edit, row, self.label_width, 1,
                         self.widgets_width)

        # Articles per query
        row += 1
        layout.addWidget(QLabel('Articles per query:'), row, 0, 1,
                         self.label_width)
        slider = gui.valueSlider(query_box,
                                 self,
                                 'articles_per_query',
                                 box='',
                                 values=[1, 3, 5, 10, 25])
        layout.addWidget(slider.box, row, 1, 1, self.widgets_width)

        query_box.layout().addLayout(layout)
        self.controlArea.layout().addWidget(query_box)

        self.controlArea.layout().addWidget(
            CheckListLayout('Text includes',
                            self,
                            'text_includes',
                            self.attributes,
                            cols=2,
                            callback=self.set_text_features))

        self.info_box = gui.hBox(self.controlArea, 'Info')
        self.result_label = gui.label(self.info_box, self,
                                      self.info_label.format(0))

        self.button_box = gui.hBox(self.controlArea)

        self.search_button = gui.button(self.button_box, self, 'Search',
                                        self.start_stop)
        self.search_button.setFocusPolicy(Qt.NoFocus)
Beispiel #2
0
    def __init__(self):
        super().__init__()
        self.corpus = None
        self.api = None
        self.output_info = ''

        # API token
        self.api_dlg = self.CredentialsDialog(self)
        self.api_dlg.accept(silent=True)
        gui.button(self.controlArea, self, 'Facebook login',
                   callback=self.api_dlg.exec_,
                   focusPolicy=Qt.NoFocus)

        # Query
        self.query_box = gui.widgetBox(self.controlArea, 'Posts', addSpace=True)
        gui.label(self.query_box, self, 'Page IDs (or page URLs)')
        self.query_box.layout().addWidget(ListEdit(self, 'page_ids',
                         'One page ID per line', 80, self))

        def date_changed():
            d.picker_to.setVisible(self.date_option in [DATE_BETWEEN])
            d.picker_from.setVisible(self.date_option in [DATE_FROM, DATE_BETWEEN])
        gui.comboBox(self.query_box, self, 'date_option', items=DATE_OPTIONS, label="Date filter",
                     callback = date_changed)
        date_box = gui.hBox(self.query_box)
        d = DatePickerInterval(date_box, self, 'date_from', 'date_to',
                               min_date=None, max_date=date.today(),
                               margin=(0, 3, 0, 0))
        date_changed()

        self.mode_box = gui.widgetBox(self.query_box, box=True)
        mode_box_h = gui.hBox(self.mode_box)
        gui.radioButtonsInBox(mode_box_h, self, 'mode', btnLabels=['only posts from page itself', 'all public posts on page'], orientation=2)
        # gui.radioButtonsInBox(mode_box_h, self, 'accumulate', btnLabels=['new results', 'add to previous results'], orientation=2, label='On search:')
        gui.lineEdit(mode_box_h, self, 'max_documents', label='Max docs per page:', valueType=str, controlWidth=50)

        comments_box = gui.widgetBox(self.controlArea, box='Comments')
        gui.radioButtonsInBox(comments_box, self, 'comments', btnLabels=['ignore', 'direct comments', 'all comments'], orientation=2)


        # Text includes features
        self.query_box.layout().addWidget(
            CheckListLayout('Text includes', self, 'text_includes',
                            self.attributes,
                            cols=2, callback=self.set_text_features))

        # Output
        info_box = gui.hBox(self.controlArea, 'Output')
        gui.label(info_box, self, 'Articles: %(output_info)s')

        # Buttons
        self.button_box = gui.hBox(self.controlArea)
        self.button_box.layout().addWidget(self.report_button)

        self.search_button = gui.button(self.button_box, self, 'Search',
                                        self.start_stop,
                                        focusPolicy=Qt.NoFocus)
Beispiel #3
0
    def __init__(self):
        super().__init__()
        self.corpus = None
        self.nyt_api = None
        self.output_info = ''
        self.num_retrieved = 0
        self.num_all = 0

        # API key
        self.api_dlg = self.APICredentialsDialog(self)
        self.api_dlg.accept(silent=True)
        gui.button(self.controlArea,
                   self,
                   'Article API Key',
                   callback=self.api_dlg.exec_,
                   focusPolicy=Qt.NoFocus)

        # Query
        query_box = gui.widgetBox(self.controlArea, 'Query', addSpace=True)
        self.query_box = QueryBox(query_box,
                                  self,
                                  self.recent_queries,
                                  callback=self.new_query_input)

        # Year box
        date_box = gui.hBox(query_box)
        DatePickerInterval(date_box,
                           self,
                           'date_from',
                           'date_to',
                           min_date=MIN_DATE,
                           max_date=date.today(),
                           margin=(0, 3, 0, 0))

        # Text includes features
        self.controlArea.layout().addWidget(
            CheckListLayout('Text includes',
                            self,
                            'text_includes',
                            self.attributes,
                            cols=2,
                            callback=self.set_text_features))

        # Output
        info_box = gui.hBox(self.controlArea, 'Output')
        gui.label(info_box, self, 'Articles: %(output_info)s')

        # Buttons
        self.button_box = gui.hBox(self.controlArea)
        self.button_box.layout().addWidget(self.report_button)

        self.search_button = gui.button(self.button_box,
                                        self,
                                        'Search',
                                        self.start_stop,
                                        focusPolicy=Qt.NoFocus)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.api = WikipediaAPI(on_error=self.Error.api_error)
        self.result = None

        query_box = gui.hBox(self.controlArea, '查询')

        # Queries configuration
        layout = QGridLayout()
        layout.setSpacing(7)

        row = 0
        self.query_edit = ListEdit(self, 'query_list', "每一行表示一个不同的查询", 100,
                                   self)

        layout.addWidget(QLabel('查询词:'), row, 0, 1, self.label_width)
        layout.addWidget(self.query_edit, row, self.label_width, 1,
                         self.widgets_width)

        # Articles per query
        row += 1
        layout.addWidget(QLabel('每次查询文章数量:'), row, 0, 1, self.label_width)
        slider = gui.valueSlider(query_box,
                                 self,
                                 'articles_per_query',
                                 box='',
                                 values=[10, 30, 50, 80, 100])
        layout.addWidget(slider.box, row, 1, 1, self.widgets_width)

        query_box.layout().addLayout(layout)
        self.controlArea.layout().addWidget(query_box)

        self.controlArea.layout().addWidget(
            CheckListLayout('包含的内容',
                            self,
                            'text_includes',
                            self.attributes,
                            cols=2,
                            callback=self.set_text_features))

        self.info_box = gui.hBox(self.controlArea, '基本信息')
        self.result_label = gui.label(self.info_box, self,
                                      self.info_label.format(0))

        self.button_box = gui.hBox(self.controlArea)

        self.search_button = gui.button(self.button_box, self, '查询',
                                        self.start_stop)
        self.search_button.setFocusPolicy(Qt.NoFocus)
Beispiel #5
0
    def __init__(self):
        OWWidget.__init__(self)
        ConcurrentWidgetMixin.__init__(self)
        self.api = None
        self.corpus = None
        self.api_dlg = self.APICredentialsDialog(self)
        self.api_dlg.accept(silent=True)

        # Set API key button
        gui.button(
            self.controlArea,
            self,
            "Twitter API Key",
            callback=self.open_key_dialog,
            tooltip="Set the API key for this widget.",
            focusPolicy=Qt.NoFocus,
        )

        # Query
        query_box = gui.hBox(self.controlArea, "Query")
        layout = QGridLayout()
        layout.setVerticalSpacing(5)
        layout.setColumnStretch(2, 1)  # stretch last columns
        layout.setColumnMinimumWidth(1, 15)  # add some space for checkbox
        ROW = 0
        COLUMNS = 3

        def add_row(label, items):
            nonlocal ROW, COLUMNS
            layout.addWidget(QLabel(label), ROW, 0)
            if isinstance(items, tuple):
                for i, item in enumerate(items):
                    layout.addWidget(item, ROW, 1 + i)
            else:
                layout.addWidget(items, ROW, 1, 1, COLUMNS - 1)
            ROW += 1

        # Query input
        add_row(
            "Query word list:",
            ListEdit(
                self,
                "word_list",
                "Multiple lines are joined with OR.",
                80,
                self,
            ),
        )

        # Search mode
        add_row(
            "Search by:",
            gui.comboBox(self,
                         self,
                         "mode",
                         items=self.MODES,
                         callback=self.mode_toggle),
        )

        # Language
        self.language_combo = ComboBox(
            self,
            "language",
            items=(("Any", None), ) + tuple(sorted(lang2code.items())),
        )
        add_row("Language:", self.language_combo)

        # Max tweets
        add_row(
            "Max tweets:",
            gui.spin(
                self,
                self,
                "max_tweets",
                minv=1,
                maxv=10000,
                checked="limited_search",
            ),
        )

        # Retweets
        self.retweets_checkbox = gui.checkBox(self,
                                              self,
                                              "allow_retweets",
                                              "",
                                              minimumHeight=30)
        add_row("Allow retweets:", self.retweets_checkbox)

        # Collect Results
        add_row("Collect results:", gui.checkBox(self, self, "collecting", ""))

        query_box.layout().addLayout(layout)

        self.controlArea.layout().addWidget(
            CheckListLayout(
                "Text includes",
                self,
                "text_includes",
                self.attributes,
                cols=2,
                callback=self.set_text_features,
            ))

        # Buttons
        self.button_box = gui.hBox(self.controlArea)
        self.search_button = gui.button(
            self.button_box,
            self,
            "Search",
            self.start_stop,
            focusPolicy=Qt.NoFocus,
        )

        self.mode_toggle()
        self.setFocus()  # to widget itself to show placeholder for query_edit
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.api = None
        self.corpus = None
        self.api_dlg = self.APICredentialsDialog(self)
        self.api_dlg.accept(silent=True)

        # Set API key button
        gui.button(self.controlArea,
                   self,
                   'Twitter API Key',
                   callback=self.open_key_dialog,
                   tooltip='Set the API key for this widget.',
                   focusPolicy=Qt.NoFocus)

        # Query
        query_box = gui.hBox(self.controlArea, 'Query')
        layout = QGridLayout()
        layout.setVerticalSpacing(5)
        layout.setColumnStretch(2, 1)  # stretch last columns
        layout.setColumnMinimumWidth(1, 15)  # add some space for checkbox
        ROW = 0
        COLUMNS = 3

        def add_row(label, items):
            nonlocal ROW, COLUMNS
            layout.addWidget(QLabel(label), ROW, 0)
            if isinstance(items, tuple):
                for i, item in enumerate(items):
                    layout.addWidget(item, ROW, 1 + i)
            else:
                layout.addWidget(items, ROW, 1, 1, COLUMNS - 1)
            ROW += 1

        # Query input
        add_row(
            'Query word list:',
            ListEdit(self, 'word_list', 'Multiple lines are joined with OR.',
                     80, self))

        # Search mode
        add_row(
            'Search by:',
            gui.comboBox(self,
                         self,
                         'mode',
                         items=self.MODES,
                         callback=self.mode_toggle))

        # Language
        self.language_combo = ComboBox(self,
                                       'language',
                                       items=(('Any', None), ) +
                                       tuple(sorted(lang2code.items())))
        add_row('Language:', self.language_combo)

        # Max tweets
        add_row(
            'Max tweets:',
            gui.spin(self,
                     self,
                     'max_tweets',
                     minv=1,
                     maxv=10000,
                     checked='limited_search'))

        # Retweets
        self.retweets_checkbox = gui.checkBox(self,
                                              self,
                                              'allow_retweets',
                                              '',
                                              minimumHeight=30)
        add_row('Allow retweets:', self.retweets_checkbox)

        # Collect Results
        add_row('Collect results:', gui.checkBox(self, self, 'collecting', ''))

        query_box.layout().addLayout(layout)

        self.controlArea.layout().addWidget(
            CheckListLayout('Text includes',
                            self,
                            'text_includes',
                            self.attributes,
                            cols=2,
                            callback=self.set_text_features))

        self.tweets_info_label = gui.label(self.controlArea,
                                           self,
                                           self.tweets_info.format(0),
                                           box='Info')

        # Buttons
        self.button_box = gui.hBox(self.controlArea)
        self.button_box.layout().addWidget(self.report_button)

        self.search_button = gui.button(self.button_box,
                                        self,
                                        'Search',
                                        self.start_stop,
                                        focusPolicy=Qt.NoFocus)

        self.mode_toggle()
        self.setFocus()  # to widget itself to show placeholder for query_edit
Beispiel #7
0
    def __init__(self):
        super().__init__()
        self.corpus = None
        self.api = None
        self.output_info = ''

        # API token
        self.api_dlg = self.CredentialsDialog(self)
        self.api_dlg.accept(silent=True)
        gui.button(self.controlArea,
                   self,
                   'AmCAT login',
                   callback=self.api_dlg.exec_,
                   focusPolicy=Qt.NoFocus)
        # Query
        query_box = gui.widgetBox(self.controlArea, 'Query', addSpace=True)
        aset_box = gui.hBox(query_box)
        project_edit = gui.lineEdit(aset_box,
                                    self,
                                    'project',
                                    label='Project: ',
                                    orientation=1,
                                    valueType=str)
        set_edit = gui.lineEdit(aset_box,
                                self,
                                'articleset',
                                label='Articleset: ',
                                orientation=1,
                                valueType=str)
        queryset_box = gui.hBox(query_box)
        query_box.layout().addWidget(
            ListEdit(self, 'query', 'One query per line', 80, self))

        # Year box
        def date_changed():
            d.picker_to.setVisible(
                self.date_option in [DATE_BEFORE, DATE_BETWEEN])
            d.picker_from.setVisible(
                self.date_option in [DATE_AFTER, DATE_BETWEEN])

        gui.comboBox(query_box,
                     self,
                     'date_option',
                     items=DATE_OPTIONS,
                     label="Date filter",
                     callback=date_changed)
        date_box = gui.hBox(query_box)
        d = DatePickerInterval(date_box,
                               self,
                               'date_from',
                               'date_to',
                               min_date=None,
                               max_date=date.today(),
                               margin=(0, 3, 0, 0))
        date_changed()

        # Text includes features
        self.controlArea.layout().addWidget(
            CheckListLayout('Text includes',
                            self,
                            'text_includes',
                            ['Headline', 'Byline', 'Content', 'Section'],
                            cols=2,
                            callback=self.set_text_features))

        # Output
        info_box = gui.hBox(self.controlArea, 'Output')
        gui.label(info_box, self, 'Articles: %(output_info)s')

        # Buttons
        self.button_box = gui.hBox(self.controlArea)
        self.button_box.layout().addWidget(self.report_button)

        self.search_button = gui.button(self.button_box,
                                        self,
                                        'Search',
                                        self.start_stop,
                                        focusPolicy=Qt.NoFocus)