def wl_widgets_filter_results(parent, table): def table_item_changed(): if combo_box_filter_file.count() == 1: file_old = '' else: file_old = combo_box_filter_file.currentText() combo_box_filter_file.clear() for file in table.settings['files']['files_open']: if file['selected']: combo_box_filter_file.addItem(file['name']) combo_box_filter_file.addItem(parent.tr('Total')) if combo_box_filter_file.findText(file_old) > -1: combo_box_filter_file.setCurrentText(file_old) label_filter_file = QLabel(parent.tr('Filter File:'), parent) combo_box_filter_file = wl_box.Wl_Combo_Box(parent) button_filter_results = QPushButton(parent.tr('Filter Results in Table'), parent) button_filter_results.clicked.connect(lambda: table.update_filters()) table.itemChanged.connect(table_item_changed) table_item_changed() return (label_filter_file, combo_box_filter_file, button_filter_results)
def update_gui(self, mappings): self.table_mappings.hide() self.table_mappings.blockSignals(True) self.table_mappings.setUpdatesEnabled(False) self.table_mappings.clear_table() self.table_mappings.setRowCount(len(mappings)) for i, (tag, tag_universal, description, examples) in enumerate(mappings): combo_box_tag_univsersal = wl_box.Wl_Combo_Box(self.main) combo_box_tag_univsersal.addItems([ 'ADJ', 'ADP', 'ADV', 'AUX', 'CONJ', # Coordinating/Subordinating Conjunctions 'CCONJ', 'SCONJ', 'DET', 'INTJ', 'NOUN', 'PROPN', 'NUM', 'PART', 'PRON', 'VERB', 'PUNCT', 'SYM', 'X' ]) combo_box_tag_univsersal.setCurrentText(tag_universal) combo_box_tag_univsersal.setEditable(True) self.table_mappings.setItem(i, 0, QTableWidgetItem(tag)) self.table_mappings.setCellWidget(i, 1, combo_box_tag_univsersal) self.table_mappings.setItem(i, 2, QTableWidgetItem(description)) self.table_mappings.setItem(i, 3, QTableWidgetItem(examples)) self.table_mappings.blockSignals(False) self.table_mappings.setUpdatesEnabled(True) self.table_mappings.show() self.table_mappings.itemChanged.emit(self.table_mappings.item(0, 0)) # Disable editing if the default tagset is Universal POS tags if mappings == wl_tagset_universal.mappings: for i in range(self.table_mappings.rowCount()): self.table_mappings.cellWidget(i, 1).setEnabled(False) self.label_tagsets_num_pos_tags.setText( self.tr(f'Number of POS Tags: {self.table_mappings.rowCount()}')) self.combo_box_tagsets_lang.setEnabled(True) self.combo_box_tagsets_pos_tagger.setEnabled(True) self.button_tagsets_reset.setEnabled(True) self.button_tagsets_reset_all.setEnabled(True)
def _new_item_level(self, text=None): new_item_level = wl_box.Wl_Combo_Box(self) new_item_level.addItems([self.tr('Part of Speech'), self.tr('Others')]) if text: new_item_level.setCurrentText(text) return new_item_level
def _new_item_level(self, text=None): new_item_level = wl_box.Wl_Combo_Box(self) new_item_level.addItems([self.tr('Header')]) if text: new_item_level.setCurrentText(text) return new_item_level
def wl_widgets_direction_2(parent): label_direction = QLabel(parent.tr('Direction:'), parent) combo_box_direction = wl_box.Wl_Combo_Box(parent) combo_box_direction.addItems( [parent.tr('Two-tailed'), parent.tr('One-tailed')]) return label_direction, combo_box_direction
def wl_widgets_use_data_freq(parent): label_use_data = QLabel(parent.tr('Use Data:'), parent) combo_box_use_data = wl_box.Wl_Combo_Box(parent) combo_box_use_data.addItems( [parent.tr('Absolute Frequency'), parent.tr('Relative Frequency')]) return label_use_data, combo_box_use_data
def wl_widgets_measure_dispersion(parent): main = wl_misc.find_wl_main(parent) label_measure_dispersion = QLabel(parent.tr('Measure of Dispersion:'), parent) combo_box_measure_dispersion = wl_box.Wl_Combo_Box(parent) combo_box_measure_dispersion.addItems(list(main.settings_global['measures_dispersion'].keys())) return (label_measure_dispersion, combo_box_measure_dispersion)
def wl_widgets_measure_adjusted_freq(parent): main = wl_misc.find_wl_main(parent) label_measure_adjusted_freq = QLabel(parent.tr('Measure of Adjusted Frequency:'), parent) combo_box_measure_adjusted_freq = wl_box.Wl_Combo_Box(parent) combo_box_measure_adjusted_freq.addItems(list(main.settings_global['measures_adjusted_freq'].keys())) return (label_measure_adjusted_freq, combo_box_measure_adjusted_freq)
def wl_widgets_token_settings_concordancer(parent): def use_tags_changed(): if checkbox_use_tags.isChecked(): stacked_widget_ignore_tags.setCurrentIndex(1) stacked_widget_ignore_tags_type.setCurrentIndex(1) else: stacked_widget_ignore_tags.setCurrentIndex(0) stacked_widget_ignore_tags_type.setCurrentIndex(0) checkbox_puncs = QCheckBox(parent.tr('Punctuations'), parent) checkbox_ignore_tags = QCheckBox(parent.tr('Ignore'), parent) checkbox_ignore_tags_tags = QCheckBox(parent.tr('Ignore'), parent) combo_box_ignore_tags = wl_box.Wl_Combo_Box(parent) combo_box_ignore_tags_tags = wl_box.Wl_Combo_Box(parent) label_ignore_tags = QLabel(parent.tr('tags'), parent) checkbox_use_tags = QCheckBox(parent.tr('Use tags only'), parent) combo_box_ignore_tags.addItems( [parent.tr('all'), parent.tr('POS'), parent.tr('non-POS')]) combo_box_ignore_tags_tags.addItems( [parent.tr('POS'), parent.tr('non-POS')]) stacked_widget_ignore_tags = QStackedWidget(parent) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags_tags) stacked_widget_ignore_tags_type = QStackedWidget(parent) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags_tags) checkbox_use_tags.stateChanged.connect(use_tags_changed) use_tags_changed() return (checkbox_puncs, stacked_widget_ignore_tags, checkbox_ignore_tags, checkbox_ignore_tags_tags, stacked_widget_ignore_tags_type, combo_box_ignore_tags, combo_box_ignore_tags_tags, label_ignore_tags, checkbox_use_tags)
def __init__(self, main): super().__init__(main, main.tr('Citing'), width = 450, no_button = True) self.label_citing = wl_label.Wl_Label_Dialog( self.tr(''' <div> If you publish work that uses Wordless, please cite as follows. </div> '''), self ) self.label_citation_sys = QLabel(self.tr('Citation System:'), self) self.combo_box_citation_sys = wl_box.Wl_Combo_Box(self) self.text_edit_citing = QTextEdit(self) self.button_copy = QPushButton(self.tr('Copy'), self) self.button_close = QPushButton(self.tr('Close'), self) self.combo_box_citation_sys.addItems([ self.tr('APA (7th Edition)'), self.tr('MLA (8th Edition)') ]) self.button_copy.setFixedWidth(100) self.button_close.setFixedWidth(100) self.text_edit_citing.setFixedHeight(100) self.text_edit_citing.setReadOnly(True) self.combo_box_citation_sys.currentTextChanged.connect(self.citation_sys_changed) self.button_copy.clicked.connect(self.copy) self.button_close.clicked.connect(self.accept) layout_citation_sys = wl_layout.Wl_Layout() layout_citation_sys.addWidget(self.label_citation_sys, 0, 0) layout_citation_sys.addWidget(self.combo_box_citation_sys, 0, 1) layout_citation_sys.setColumnStretch(2, 1) self.wrapper_info.layout().addWidget(self.label_citing, 0, 0, 1, 2) self.wrapper_info.layout().addLayout(layout_citation_sys, 1, 0, 1, 2) self.wrapper_info.layout().addWidget(self.text_edit_citing, 2, 0, 1, 2) self.wrapper_buttons.layout().addWidget(self.button_copy, 0, 0) self.wrapper_buttons.layout().addWidget(self.button_close, 0, 1) self.load_settings() self.set_fixed_height()
def _new_item_level(self, text=None): new_item_level = wl_box.Wl_Combo_Box(self) new_item_level.addItems([ self.tr('Division'), self.tr('Paragraph'), self.tr('Sentence'), self.tr('Word') ]) if text: new_item_level.setCurrentText(text) return new_item_level
def __init__(self, main): super().__init__(main) settings_global = self.main.settings_global['pos_taggers'] # POS Tagger Settings group_box_pos_tagger_settings = QGroupBox( self.tr('POS Tagger Settings'), self) self.table_pos_taggers = wl_table.Wl_Table( self, headers=[self.tr('Language'), self.tr('POS Taggers')], cols_stretch=[self.tr('POS Taggers')]) self.checkbox_to_universal_pos_tags = QCheckBox( self.tr('Convert all POS tags to universal POS tags')) self.table_pos_taggers.verticalHeader().setHidden(True) self.table_pos_taggers.setRowCount(len(settings_global)) for i, lang in enumerate(settings_global): self.table_pos_taggers.setItem( i, 0, QTableWidgetItem(wl_conversion.to_lang_text(self.main, lang))) self.__dict__[ f'combo_box_pos_tagger_{lang}'] = wl_box.Wl_Combo_Box(self) self.__dict__[f'combo_box_pos_tagger_{lang}'].addItems( settings_global[lang]) self.__dict__[ f'combo_box_pos_tagger_{lang}'].currentTextChanged.connect( lambda text, lang=lang: self.pos_taggers_changed(lang)) self.table_pos_taggers.setCellWidget( i, 1, self.__dict__[f'combo_box_pos_tagger_{lang}']) self.checkbox_to_universal_pos_tags.stateChanged.connect( self.preview_results_changed) group_box_pos_tagger_settings.setLayout(wl_layout.Wl_Layout()) group_box_pos_tagger_settings.layout().addWidget( self.table_pos_taggers, 0, 0) group_box_pos_tagger_settings.layout().addWidget( self.checkbox_to_universal_pos_tags, 1, 0) # Preview group_box_preview = QGroupBox(self.tr('Preview'), self) self.label_pos_tagging_preview_lang = QLabel( self.tr('Select language:'), self) self.combo_box_pos_tagging_preview_lang = wl_box.Wl_Combo_Box(self) self.label_pos_tagging_preview_processing = QLabel('', self) self.text_edit_pos_tagging_preview_samples = QTextEdit(self) self.text_edit_pos_tagging_preview_results = QTextEdit(self) self.combo_box_pos_tagging_preview_lang.addItems( wl_conversion.to_lang_text(self.main, list(settings_global))) self.text_edit_pos_tagging_preview_samples.setAcceptRichText(False) self.text_edit_pos_tagging_preview_results.setReadOnly(True) self.combo_box_pos_tagging_preview_lang.currentTextChanged.connect( self.preview_changed) self.combo_box_pos_tagging_preview_lang.currentTextChanged.connect( self.preview_results_changed) self.text_edit_pos_tagging_preview_samples.textChanged.connect( self.preview_changed) self.text_edit_pos_tagging_preview_samples.textChanged.connect( self.preview_results_changed) self.text_edit_pos_tagging_preview_results.textChanged.connect( self.preview_changed) layout_preview_settings = wl_layout.Wl_Layout() layout_preview_settings.addWidget(self.label_pos_tagging_preview_lang, 0, 0) layout_preview_settings.addWidget( self.combo_box_pos_tagging_preview_lang, 0, 1) layout_preview_settings.addWidget( self.label_pos_tagging_preview_processing, 0, 3) layout_preview_settings.setColumnStretch(2, 1) group_box_preview.setLayout(wl_layout.Wl_Layout()) group_box_preview.layout().addLayout(layout_preview_settings, 0, 0, 1, 2) group_box_preview.layout().addWidget( self.text_edit_pos_tagging_preview_samples, 1, 0) group_box_preview.layout().addWidget( self.text_edit_pos_tagging_preview_results, 1, 1) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_pos_tagger_settings, 0, 0) self.layout().addWidget(group_box_preview, 1, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(0, 3) self.layout().setRowStretch(1, 2)
def wl_widgets_fig_settings(parent, collocation = False): def graph_type_changed(): if combo_box_graph_type.currentText() == parent.tr('Line Chart'): combo_box_use_file.setEnabled(False) use_data_changed() else: combo_box_use_file.setEnabled(True) checkbox_use_pct.setEnabled(False) checkbox_use_cumulative.setEnabled(False) def use_data_changed(): if combo_box_graph_type.currentText() == parent.tr('Line Chart'): if combo_box_use_data.currentText() == parent.tr('Frequency'): checkbox_use_pct.setEnabled(True) checkbox_use_cumulative.setEnabled(True) else: checkbox_use_pct.setEnabled(False) checkbox_use_cumulative.setEnabled(False) def wl_files_changed(): if combo_box_use_file.count() == 1: use_file_old = '' else: use_file_old = combo_box_use_file.currentText() combo_box_use_file.clear() for file in main.wl_files.get_selected_files(): combo_box_use_file.addItem(file['name']) combo_box_use_file.addItem(parent.tr('Total')) if use_file_old and combo_box_use_file.findText(use_file_old) > -1: combo_box_use_file.setCurrentText(use_file_old) main = wl_misc.find_wl_main(parent) label_graph_type = QLabel(parent.tr('Graph Type:'), parent) combo_box_graph_type = wl_box.Wl_Combo_Box(parent) label_use_file = QLabel(parent.tr('Use File:'), parent) combo_box_use_file = wl_box.Wl_Combo_Box(parent) label_use_data = QLabel(parent.tr('Use Data:'), parent) combo_box_use_data = wl_box.Wl_Combo_Box(parent) # Clip long file names combo_box_use_file.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) checkbox_use_pct = QCheckBox(parent.tr('Use percentage data'), parent) checkbox_use_cumulative = QCheckBox(parent.tr('Use cumulative data'), parent) combo_box_graph_type.addItems([parent.tr('Line Chart'), parent.tr('Word Cloud')]) # Collocation & Colligation if collocation: combo_box_graph_type.addItem(parent.tr('Network Graph')) combo_box_graph_type.currentTextChanged.connect(graph_type_changed) combo_box_use_data.currentTextChanged.connect(use_data_changed) main.wl_files.table.itemChanged.connect(wl_files_changed) combo_box_use_file.wl_files_changed = wl_files_changed graph_type_changed() use_data_changed() wl_files_changed() return ( label_graph_type, combo_box_graph_type, label_use_file, combo_box_use_file, label_use_data, combo_box_use_data, checkbox_use_pct, checkbox_use_cumulative )
def wl_widgets_measure_effect_size(parent): label_measure_effect_size = QLabel(parent.tr('Measure of Effect Size:'), parent) combo_box_measure_effect_size = wl_box.Wl_Combo_Box(parent) return (label_measure_effect_size, combo_box_measure_effect_size)
def wl_widgets_test_significance(parent): label_test_significance = QLabel(parent.tr('Test of Statistical Significance:'), parent) combo_box_test_significance = wl_box.Wl_Combo_Box(parent) return (label_test_significance, combo_box_test_significance)
def wl_widgets_token_settings(parent): def words_changed(): if checkbox_words.isChecked(): checkbox_lowercase.setEnabled(True) checkbox_uppercase.setEnabled(True) checkbox_title_case.setEnabled(True) else: checkbox_lowercase.setEnabled(False) checkbox_uppercase.setEnabled(False) checkbox_title_case.setEnabled(False) def use_tags_changed(): if checkbox_use_tags.isChecked(): checkbox_lemmatize_tokens.setEnabled(False) stacked_widget_ignore_tags.setCurrentIndex(1) stacked_widget_ignore_tags_type.setCurrentIndex(1) else: checkbox_lemmatize_tokens.setEnabled(True) stacked_widget_ignore_tags.setCurrentIndex(0) stacked_widget_ignore_tags_type.setCurrentIndex(0) checkbox_words = QCheckBox(parent.tr('Words'), parent) checkbox_lowercase = QCheckBox(parent.tr('Lowercase'), parent) checkbox_uppercase = QCheckBox(parent.tr('Uppercase'), parent) checkbox_title_case = QCheckBox(parent.tr('Title Case'), parent) checkbox_nums = QCheckBox(parent.tr('Numerals'), parent) checkbox_puncs = QCheckBox(parent.tr('Punctuations'), parent) checkbox_treat_as_lowercase = QCheckBox( parent.tr('Treat as all lowercase'), parent) checkbox_lemmatize_tokens = QCheckBox(parent.tr('Lemmatize all tokens'), parent) checkbox_filter_stop_words = QCheckBox(parent.tr('Filter stop words'), parent) checkbox_ignore_tags = QCheckBox(parent.tr('Ignore'), parent) checkbox_ignore_tags_tags = QCheckBox(parent.tr('Ignore'), parent) combo_box_ignore_tags = wl_box.Wl_Combo_Box(parent) combo_box_ignore_tags_tags = wl_box.Wl_Combo_Box(parent) label_ignore_tags = QLabel(parent.tr('tags'), parent) checkbox_use_tags = QCheckBox(parent.tr('Use tags only'), parent) combo_box_ignore_tags.addItems( [parent.tr('all'), parent.tr('POS'), parent.tr('non-POS')]) combo_box_ignore_tags_tags.addItems( [parent.tr('POS'), parent.tr('non-POS')]) stacked_widget_ignore_tags = QStackedWidget(parent) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags_tags) stacked_widget_ignore_tags_type = QStackedWidget(parent) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags_tags) checkbox_words.stateChanged.connect(words_changed) checkbox_use_tags.stateChanged.connect(use_tags_changed) words_changed() use_tags_changed() return (checkbox_words, checkbox_lowercase, checkbox_uppercase, checkbox_title_case, checkbox_nums, checkbox_puncs, checkbox_treat_as_lowercase, checkbox_lemmatize_tokens, checkbox_filter_stop_words, stacked_widget_ignore_tags, checkbox_ignore_tags, checkbox_ignore_tags_tags, stacked_widget_ignore_tags_type, combo_box_ignore_tags, combo_box_ignore_tags_tags, label_ignore_tags, checkbox_use_tags)
def __init__(self, main): super().__init__(main) self.pos_tag_mappings_loaded = False settings_global = self.main.settings_global['pos_taggers'] self.settings_tagsets = QWidget(self) # Preview Settings group_box_preview_settings = QGroupBox(self.tr('Preview Settings:'), self) self.label_tagsets_lang = QLabel(self.tr('Language:'), self) self.combo_box_tagsets_lang = wl_box.Wl_Combo_Box(self) self.label_tagsets_pos_tagger = QLabel(self.tr('POS Tagger:'), self) self.combo_box_tagsets_pos_tagger = wl_box.Wl_Combo_Box_Adjustable( self) self.combo_box_tagsets_lang.addItems( wl_conversion.to_lang_text(self.main, list(settings_global))) self.combo_box_tagsets_lang.currentTextChanged.connect( self.preview_lang_changed) self.combo_box_tagsets_pos_tagger.currentTextChanged.connect( self.preview_pos_tagger_changed) group_box_preview_settings.setLayout(wl_layout.Wl_Layout()) group_box_preview_settings.layout().addWidget(self.label_tagsets_lang, 0, 0) group_box_preview_settings.layout().addWidget( self.combo_box_tagsets_lang, 0, 1, Qt.AlignLeft) group_box_preview_settings.layout().addWidget( self.label_tagsets_pos_tagger, 1, 0) group_box_preview_settings.layout().addWidget( self.combo_box_tagsets_pos_tagger, 1, 1, Qt.AlignLeft) group_box_preview_settings.layout().setColumnStretch(2, 1) # Mapping Settings group_box_mapping_settings = QGroupBox(self.tr('Mapping Settings')) self.label_tagsets_num_pos_tags = QLabel('', self) self.button_tagsets_reset = QPushButton(self.tr('Reset'), self) self.button_tagsets_reset_all = QPushButton(self.tr('Reset All'), self) self.table_mappings = wl_table.Wl_Table( self, headers=[ self.tr('POS Tag'), self.tr('Universal POS Tag'), self.tr('Description'), self.tr('Examples') ]) self.button_tagsets_reset.setFixedWidth(100) self.button_tagsets_reset_all.setFixedWidth(100) self.button_tagsets_reset.clicked.connect(self.reset_mappings) self.button_tagsets_reset_all.clicked.connect(self.reset_all_mappings) group_box_mapping_settings.setLayout(wl_layout.Wl_Layout()) group_box_mapping_settings.layout().addWidget( self.label_tagsets_num_pos_tags, 0, 0) group_box_mapping_settings.layout().addWidget( self.button_tagsets_reset, 0, 2) group_box_mapping_settings.layout().addWidget( self.button_tagsets_reset_all, 0, 3) group_box_mapping_settings.layout().addWidget(self.table_mappings, 1, 0, 1, 4) group_box_mapping_settings.layout().setColumnStretch(1, 1) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_preview_settings, 0, 0) self.layout().addWidget(group_box_mapping_settings, 1, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(1, 1)
def __init__(self, main): super().__init__(main) settings_global = self.main.settings_global['stop_words'] # Stop Words Settings group_box_stop_words_settings = QGroupBox( self.tr('Stop Words Settings'), self) table_stop_words = wl_table.Wl_Table( self, headers=[self.tr('Language'), self.tr('Lists of Stop Words')], cols_stretch=[self.tr('Lists of Stop Words')]) table_stop_words.verticalHeader().setHidden(True) table_stop_words.setRowCount(len(settings_global)) for i, lang in enumerate(settings_global): table_stop_words.setItem( i, 0, QTableWidgetItem(wl_conversion.to_lang_text(self.main, lang))) self.__dict__[ f'combo_box_stop_words_{lang}'] = wl_box.Wl_Combo_Box(self) self.__dict__[f'combo_box_stop_words_{lang}'].addItems( settings_global[lang]) self.__dict__[ f'combo_box_stop_words_{lang}'].currentTextChanged.connect( lambda text, lang=lang: self.stop_words_changed(lang)) table_stop_words.setCellWidget( i, 1, self.__dict__[f'combo_box_stop_words_{lang}']) group_box_stop_words_settings.setLayout(wl_layout.Wl_Layout()) group_box_stop_words_settings.layout().addWidget( table_stop_words, 0, 0) # Preview group_box_preview = QGroupBox(self.tr('Preview'), self) self.label_stop_words_preview_lang = QLabel( self.tr('Select language:'), self) self.combo_box_stop_words_preview_lang = wl_box.Wl_Combo_Box(self) self.combo_box_stop_words_preview_lang.addItems( wl_conversion.to_lang_text(self.main, list(settings_global.keys()))) self.label_stop_words_preview_count = QLabel('', self) self.list_stop_words_preview_results = wl_list.Wl_List_Stop_Words(self) self.combo_box_stop_words_preview_lang.currentTextChanged.connect( self.preview_settings_changed) self.combo_box_stop_words_preview_lang.currentTextChanged.connect( self.preview_results_changed) layout_preview_settings = wl_layout.Wl_Layout() layout_preview_settings.addWidget(self.label_stop_words_preview_lang, 0, 0) layout_preview_settings.addWidget( self.combo_box_stop_words_preview_lang, 0, 1) layout_preview_settings.addWidget(self.label_stop_words_preview_count, 0, 3) layout_preview_settings.setColumnStretch(2, 1) group_box_preview.setLayout(wl_layout.Wl_Layout()) group_box_preview.layout().addLayout(layout_preview_settings, 0, 0, 1, 5) group_box_preview.layout().addWidget( self.list_stop_words_preview_results, 1, 0, 1, 5) group_box_preview.layout().addWidget( self.list_stop_words_preview_results.button_add, 2, 0) group_box_preview.layout().addWidget( self.list_stop_words_preview_results.button_remove, 2, 1) group_box_preview.layout().addWidget( self.list_stop_words_preview_results.button_clear, 2, 2) group_box_preview.layout().addWidget( self.list_stop_words_preview_results.button_import, 2, 3) group_box_preview.layout().addWidget( self.list_stop_words_preview_results.button_export, 2, 4) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_stop_words_settings, 0, 0) self.layout().addWidget(group_box_preview, 1, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(0, 3) self.layout().setRowStretch(1, 2) self.preview_results_changed()
def __init__(self, main): super().__init__(main, main.tr('Donating'), width=450) self.label_donating = wl_label.Wl_Label_Dialog( self.tr(''' <div> If you would like to support the development of Wordless, you may donate via <a href="https://www.paypal.com/">PayPal</a>, <a href="https://global.alipay.com/">Alipay</a>, or <a href="https://pay.weixin.qq.com/index.php/public/wechatpay_en">WeChat Pay</a>. </div> '''), self) self.label_donating_via = QLabel(self.tr('Donating via:'), self) self.combo_box_donating_via = wl_box.Wl_Combo_Box(self) self.label_donating_via_img = wl_label.Wl_Label_Html('', self) self.label_donating_note = wl_label.Wl_Label_Dialog( self.tr(''' <div> <span style="color: #F00;"><b>Important Note</b></span>: I <b>WILL NOT PROVIDE</b> invoices, receipts, refund services, detailed spending reports, my contact information other than email addresses, my personal social media accounts, private email/phone support, or guarantees on bug fixes, enhancements, new features, or new releases of Wordless for donation. </div> '''), self) self.combo_box_donating_via.addItems( [self.tr('PayPal'), self.tr('Alipay'), self.tr('WeChat Pay')]) self.combo_box_donating_via.currentTextChanged.connect( self.donating_via_changed) layout_donating_via = wl_layout.Wl_Layout() layout_donating_via.addWidget(self.label_donating_via, 0, 0) layout_donating_via.addWidget(self.combo_box_donating_via, 0, 1) layout_donating_via.setColumnStretch(2, 1) self.wrapper_info.layout().addWidget(self.label_donating, 0, 0) self.wrapper_info.layout().addLayout(layout_donating_via, 1, 0) self.wrapper_info.layout().addWidget(self.label_donating_via_img, 2, 0, Qt.AlignHCenter | Qt.AlignVCenter) self.wrapper_info.layout().addWidget(self.label_donating_note, 3, 0) # Calculate height donating_via_old = self.main.settings_custom['menu']['help'][ 'donating']['donating_via'] self.combo_box_donating_via.setCurrentText('PayPal') self.donating_via_changed() height_donating_via_paypal = self.label_donating_via_img.sizeHint( ).height() self.height_paypal = self.heightForWidth(self.width()) self.combo_box_donating_via.setCurrentText('Alipay') self.donating_via_changed() height_donating_via_alipay = self.label_donating_via_img.sizeHint( ).height() self.height_alipay = self.heightForWidth(self.width()) + ( height_donating_via_alipay - height_donating_via_paypal) self.main.settings_custom['menu']['help']['donating'][ 'donating_via'] = donating_via_old self.load_settings()
def wl_widgets_search_settings(parent, tab): def multi_search_mode_changed(): if checkbox_multi_search_mode.isChecked(): label_search_term.setText(parent.tr('Search Terms:')) if line_edit_search_term.text() and list_search_terms.count() == 0: list_search_terms.load_items([line_edit_search_term.text()]) stacked_widget_search_term.setCurrentIndex(1) else: label_search_term.setText(parent.tr('Search Term:')) stacked_widget_search_term.setCurrentIndex(0) def match_tags_changed(): if checkbox_match_tags.isChecked(): checkbox_match_inflected_forms.setEnabled(False) stacked_widget_ignore_tags.setCurrentIndex(1) stacked_widget_ignore_tags_type.setCurrentIndex(1) else: checkbox_match_inflected_forms.setEnabled(True) stacked_widget_ignore_tags.setCurrentIndex(0) stacked_widget_ignore_tags_type.setCurrentIndex(0) def token_settings_changed(): token_settings = main.settings_custom[tab]['token_settings'] if token_settings['use_tags']: checkbox_match_tags.setEnabled(False) checkbox_match_tags.setChecked(True) if token_settings['ignore_tags_tags']: stacked_widget_ignore_tags.setEnabled(False) stacked_widget_ignore_tags_type.setEnabled(False) else: stacked_widget_ignore_tags.setEnabled(True) stacked_widget_ignore_tags_type.setEnabled(True) else: checkbox_match_tags.setChecked(False) if token_settings['ignore_tags']: if token_settings['ignore_tags_type'] == parent.tr('All'): stacked_widget_ignore_tags.setEnabled(False) stacked_widget_ignore_tags_type.setEnabled(False) checkbox_match_tags.setEnabled(False) else: if checkbox_match_tags.isChecked(): stacked_widget_ignore_tags.setEnabled(False) stacked_widget_ignore_tags_type.setEnabled(False) else: stacked_widget_ignore_tags.setEnabled(True) stacked_widget_ignore_tags_type.setEnabled(True) checkbox_match_tags.setEnabled(True) else: stacked_widget_ignore_tags.setEnabled(True) stacked_widget_ignore_tags_type.setEnabled(True) checkbox_match_tags.setEnabled(True) match_tags_changed() main = wl_misc.find_wl_main(parent) label_search_term = QLabel(parent.tr('Search Term:'), parent) checkbox_multi_search_mode = QCheckBox(parent.tr('Multi-search Mode'), parent) line_edit_search_term = QLineEdit(parent) list_search_terms = wl_list.Wl_List_Search_Terms(parent) label_separator = wl_label.Wl_Label_Hint( parent.tr('* Use space to separate multiple tokens'), parent) checkbox_ignore_case = QCheckBox(parent.tr('Ignore case'), parent) checkbox_match_inflected_forms = QCheckBox( parent.tr('Match all inflected forms'), parent) checkbox_match_whole_words = QCheckBox(parent.tr('Match whole words only'), parent) checkbox_use_regex = QCheckBox(parent.tr('Use regular expression'), parent) checkbox_ignore_tags = QCheckBox(parent.tr('Ignore'), parent) checkbox_ignore_tags_tags = QCheckBox(parent.tr('Ignore'), parent) combo_box_ignore_tags = wl_box.Wl_Combo_Box(parent) combo_box_ignore_tags_tags = wl_box.Wl_Combo_Box(parent) label_ignore_tags = QLabel(parent.tr('tags'), parent) checkbox_match_tags = QCheckBox(parent.tr('Match tags only'), parent) combo_box_ignore_tags.addItems( [parent.tr('all'), parent.tr('POS'), parent.tr('non-POS')]) combo_box_ignore_tags_tags.addItems( [parent.tr('POS'), parent.tr('non-POS')]) wrapper_search_terms = QWidget(parent) wrapper_search_terms.setLayout(wl_layout.Wl_Layout()) wrapper_search_terms.layout().addWidget(list_search_terms, 0, 0, 5, 1) wrapper_search_terms.layout().addWidget(list_search_terms.button_add, 0, 1) wrapper_search_terms.layout().addWidget(list_search_terms.button_remove, 1, 1) wrapper_search_terms.layout().addWidget(list_search_terms.button_clear, 2, 1) wrapper_search_terms.layout().addWidget(list_search_terms.button_import, 3, 1) wrapper_search_terms.layout().addWidget(list_search_terms.button_export, 4, 1) wrapper_search_terms.layout().setContentsMargins(0, 0, 0, 0) stacked_widget_search_term = wl_layout.Wl_Stacked_Widget(parent) stacked_widget_search_term.addWidget(line_edit_search_term) stacked_widget_search_term.addWidget(wrapper_search_terms) stacked_widget_ignore_tags = wl_layout.Wl_Stacked_Widget(parent) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags) stacked_widget_ignore_tags.addWidget(checkbox_ignore_tags_tags) stacked_widget_ignore_tags_type = wl_layout.Wl_Stacked_Widget(parent) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags) stacked_widget_ignore_tags_type.addWidget(combo_box_ignore_tags_tags) checkbox_match_tags.token_settings_changed = token_settings_changed checkbox_multi_search_mode.stateChanged.connect(multi_search_mode_changed) checkbox_match_tags.stateChanged.connect(match_tags_changed) multi_search_mode_changed() match_tags_changed() return (label_search_term, checkbox_multi_search_mode, stacked_widget_search_term, line_edit_search_term, list_search_terms, label_separator, checkbox_ignore_case, checkbox_match_inflected_forms, checkbox_match_whole_words, checkbox_use_regex, stacked_widget_ignore_tags, checkbox_ignore_tags, checkbox_ignore_tags_tags, stacked_widget_ignore_tags_type, combo_box_ignore_tags, combo_box_ignore_tags_tags, label_ignore_tags, checkbox_match_tags)
def __init__(self, main): super().__init__(main) settings_global = self.main.settings_global['lemmatizers'] # Lemmatizer Settings group_box_lemmatizer_settings = QGroupBox( self.tr('Lemmatizer Settings'), self) table_lemmatizers = wl_table.Wl_Table( self, headers=[self.tr('Language'), self.tr('Lemmatizers')], cols_stretch=[self.tr('Lemmatizers')]) table_lemmatizers.verticalHeader().setHidden(True) table_lemmatizers.setRowCount(len(settings_global)) for i, lang in enumerate(settings_global): table_lemmatizers.setItem( i, 0, QTableWidgetItem(wl_conversion.to_lang_text(self.main, lang))) self.__dict__[ f'combo_box_lemmatizer_{lang}'] = wl_box.Wl_Combo_Box(self) self.__dict__[f'combo_box_lemmatizer_{lang}'].addItems( settings_global[lang]) table_lemmatizers.setCellWidget( i, 1, self.__dict__[f'combo_box_lemmatizer_{lang}']) group_box_lemmatizer_settings.setLayout(wl_layout.Wl_Layout()) group_box_lemmatizer_settings.layout().addWidget( table_lemmatizers, 0, 0) # Preview group_box_preview = QGroupBox(self.tr('Preview'), self) self.label_lemmatization_preview_lang = QLabel( self.tr('Select language:'), self) self.combo_box_lemmatization_preview_lang = wl_box.Wl_Combo_Box(self) self.button_lemmatization_start_processing = QPushButton( self.tr('Start processing'), self) self.text_edit_lemmatization_preview_samples = QTextEdit(self) self.text_edit_lemmatization_preview_results = QTextEdit(self) self.combo_box_lemmatization_preview_lang.addItems( wl_conversion.to_lang_text(self.main, list(settings_global.keys()))) self.button_lemmatization_start_processing.setFixedWidth(150) self.text_edit_lemmatization_preview_samples.setAcceptRichText(False) self.text_edit_lemmatization_preview_results.setReadOnly(True) self.combo_box_lemmatization_preview_lang.currentTextChanged.connect( self.preview_changed) self.button_lemmatization_start_processing.clicked.connect( self.preview_results_changed) self.text_edit_lemmatization_preview_samples.textChanged.connect( self.preview_changed) self.text_edit_lemmatization_preview_results.textChanged.connect( self.preview_changed) layout_preview_settings = wl_layout.Wl_Layout() layout_preview_settings.addWidget( self.label_lemmatization_preview_lang, 0, 0) layout_preview_settings.addWidget( self.combo_box_lemmatization_preview_lang, 0, 1) layout_preview_settings.addWidget( self.button_lemmatization_start_processing, 0, 3) layout_preview_settings.setColumnStretch(2, 1) group_box_preview.setLayout(wl_layout.Wl_Layout()) group_box_preview.layout().addLayout(layout_preview_settings, 0, 0, 1, 2) group_box_preview.layout().addWidget( self.text_edit_lemmatization_preview_samples, 1, 0) group_box_preview.layout().addWidget( self.text_edit_lemmatization_preview_results, 1, 1) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_lemmatizer_settings, 0, 0) self.layout().addWidget(group_box_preview, 1, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(0, 3) self.layout().setRowStretch(1, 2)
def __init__(self, main): super().__init__(main) # Line Chart group_box_figs_line_chart = QGroupBox(self.tr('Line Chart'), self) self.label_figs_line_chart_font = QLabel(self.tr('Font:'), self) self.combo_box_figs_line_chart_font = wl_box.Wl_Combo_Box_Font_Family(self) group_box_figs_line_chart.setLayout(wl_layout.Wl_Layout()) group_box_figs_line_chart.layout().addWidget(self.label_figs_line_chart_font, 0, 0) group_box_figs_line_chart.layout().addWidget(self.combo_box_figs_line_chart_font, 0, 1) group_box_figs_line_chart.layout().setColumnStretch(2, 1) # Word Cloud group_box_figs_word_cloud = QGroupBox(self.tr('Word Cloud'), self) self.label_figs_word_cloud_font = QLabel(self.tr('Font:'), self) self.combo_box_figs_word_cloud_font = wl_box.Wl_Combo_Box(self) self.label_figs_word_cloud_bg_color = QLabel(self.tr('Background Color:'), self) (self.label_figs_word_cloud_bg_color_pick, self.button_figs_word_cloud_bg_color_pick) = wl_widgets.wl_widgets_pick_color(self) self.combo_box_figs_word_cloud_font.addItems([ 'DroidSansMono', 'Code2000', 'Unifont' ]) group_box_figs_word_cloud.setLayout(wl_layout.Wl_Layout()) group_box_figs_word_cloud.layout().addWidget(self.label_figs_word_cloud_font, 0, 0) group_box_figs_word_cloud.layout().addWidget(self.combo_box_figs_word_cloud_font, 0, 1, 1, 2) group_box_figs_word_cloud.layout().addWidget(self.label_figs_word_cloud_bg_color, 1, 0) group_box_figs_word_cloud.layout().addWidget(self.label_figs_word_cloud_bg_color_pick, 1, 1) group_box_figs_word_cloud.layout().addWidget(self.button_figs_word_cloud_bg_color_pick, 1, 2) group_box_figs_word_cloud.layout().setColumnStretch(3, 1) # Network Graph group_box_figs_network_graph = QGroupBox(self.tr('Network Graph'), self) self.label_figs_network_graph_layout = QLabel(self.tr('Layout:'), self) self.combo_box_figs_network_graph_layout = wl_box.Wl_Combo_Box(self) self.label_figs_network_graph_node_font = QLabel(self.tr('Node Font:'), self) self.combo_box_figs_network_graph_node_font = wl_box.Wl_Combo_Box_Font_Family(self) self.label_figs_network_graph_node_font_size = QLabel(self.tr('Node Font Size:'), self) self.spin_box_figs_network_graph_node_font_size = wl_box.Wl_Spin_Box_Font_Size(self) self.label_figs_network_graph_edge_font = QLabel(self.tr('Edge Font:'), self) self.combo_box_figs_network_graph_edge_font = wl_box.Wl_Combo_Box_Font_Family(self) self.label_figs_network_graph_edge_font_size = QLabel(self.tr('Edge Font Size:'), self) self.spin_box_figs_network_graph_edge_font_size = wl_box.Wl_Spin_Box_Font_Size(self) self.label_figs_network_graph_edge_color = QLabel(self.tr('Edge Color:'), self) (self.label_figs_network_graph_edge_color_pick, self.combo_box_figs_network_graph_color_pick) = wl_widgets.wl_widgets_pick_color(self) self.combo_box_figs_network_graph_layout.addItems([ self.tr('Circular'), self.tr('Kamada-Kawai'), self.tr('Planar'), self.tr('Random'), self.tr('Shell'), self.tr('Spring'), self.tr('Spectral') ]) group_box_figs_network_graph.setLayout(wl_layout.Wl_Layout()) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_layout, 0, 0) group_box_figs_network_graph.layout().addWidget(self.combo_box_figs_network_graph_layout, 0, 1, 1, 2) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_node_font, 1, 0) group_box_figs_network_graph.layout().addWidget(self.combo_box_figs_network_graph_node_font, 1, 1, 1, 2) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_node_font_size, 2, 0) group_box_figs_network_graph.layout().addWidget(self.spin_box_figs_network_graph_node_font_size, 2, 1, 1, 2) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_edge_font, 3, 0) group_box_figs_network_graph.layout().addWidget(self.combo_box_figs_network_graph_edge_font, 3, 1, 1, 2) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_edge_font_size, 4, 0) group_box_figs_network_graph.layout().addWidget(self.spin_box_figs_network_graph_edge_font_size, 4, 1, 1, 2) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_edge_color, 5, 0) group_box_figs_network_graph.layout().addWidget(self.label_figs_network_graph_edge_color_pick, 5, 1) group_box_figs_network_graph.layout().addWidget(self.combo_box_figs_network_graph_color_pick, 5, 2) group_box_figs_network_graph.layout().setColumnStretch(3, 1) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_figs_line_chart, 0, 0) self.layout().addWidget(group_box_figs_word_cloud, 1, 0) self.layout().addWidget(group_box_figs_network_graph, 2, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(3, 1)
def __init__(self, main): super().__init__(main) # Tables group_box_export_tables = QGroupBox(self.tr('Tables'), self) self.label_export_tables_default_path = QLabel( self.tr('Default Path:'), self) self.line_edit_export_tables_default_path = QLineEdit(self) self.button_export_tables_default_path = QPushButton( self.tr('Browse'), self) self.label_export_tables_default_type = QLabel( self.tr('Default Type:'), self) self.combo_box_export_tables_default_type = wl_box.Wl_Combo_Box(self) self.label_export_tables_default_encoding = QLabel( self.tr('Default Encoding:'), self) self.combo_box_export_tables_default_encoding = wl_box.Wl_Combo_Box_Encoding( self.main) self.combo_box_export_tables_default_type.addItems( self.main.settings_global['file_types']['export_tables']) self.button_export_tables_default_path.clicked.connect( self.browse_tables) self.combo_box_export_tables_default_type.currentTextChanged.connect( self.tables_default_type_changed) group_box_export_tables.setLayout(wl_layout.Wl_Layout()) group_box_export_tables.layout().addWidget( self.label_export_tables_default_path, 0, 0) group_box_export_tables.layout().addWidget( self.line_edit_export_tables_default_path, 0, 1) group_box_export_tables.layout().addWidget( self.button_export_tables_default_path, 0, 2) group_box_export_tables.layout().addWidget( self.label_export_tables_default_type, 1, 0) group_box_export_tables.layout().addWidget( self.combo_box_export_tables_default_type, 1, 1, 1, 2) group_box_export_tables.layout().addWidget( self.label_export_tables_default_encoding, 2, 0) group_box_export_tables.layout().addWidget( self.combo_box_export_tables_default_encoding, 2, 1, 1, 2) # Search Terms group_box_export_search_terms = QGroupBox(self.tr('Search Terms'), self) self.label_export_search_terms_default_path = QLabel( self.tr('Default Path:'), self) self.line_edit_export_search_terms_default_path = QLineEdit(self) self.button_export_search_terms_default_path = QPushButton( self.tr('Browse'), self) self.label_export_search_terms_default_encoding = QLabel( self.tr('Default Encoding:'), self) self.combo_box_export_search_terms_default_encoding = wl_box.Wl_Combo_Box_Encoding( self) self.button_export_search_terms_default_path.clicked.connect( self.browse_search_terms) group_box_export_search_terms.setLayout(wl_layout.Wl_Layout()) group_box_export_search_terms.layout().addWidget( self.label_export_search_terms_default_path, 0, 0) group_box_export_search_terms.layout().addWidget( self.line_edit_export_search_terms_default_path, 0, 1) group_box_export_search_terms.layout().addWidget( self.button_export_search_terms_default_path, 0, 2) group_box_export_search_terms.layout().addWidget( self.label_export_search_terms_default_encoding, 1, 0) group_box_export_search_terms.layout().addWidget( self.combo_box_export_search_terms_default_encoding, 1, 1, 1, 2) # Stop Words group_box_export_stop_words = QGroupBox(self.tr('Stop Words'), self) self.label_export_stop_words_default_path = QLabel( self.tr('Default Path:'), self) self.line_edit_export_stop_words_default_path = QLineEdit(self) self.button_export_stop_words_default_path = QPushButton( self.tr('Browse'), self) self.label_export_stop_words_default_encoding = QLabel( self.tr('Default Encoding:'), self) self.combo_box_export_stop_words_default_encoding = wl_box.Wl_Combo_Box_Encoding( self) self.button_export_stop_words_default_path.clicked.connect( self.browse_stop_words) group_box_export_stop_words.setLayout(wl_layout.Wl_Layout()) group_box_export_stop_words.layout().addWidget( self.label_export_stop_words_default_path, 0, 0) group_box_export_stop_words.layout().addWidget( self.line_edit_export_stop_words_default_path, 0, 1) group_box_export_stop_words.layout().addWidget( self.button_export_stop_words_default_path, 0, 2) group_box_export_stop_words.layout().addWidget( self.label_export_stop_words_default_encoding, 1, 0) group_box_export_stop_words.layout().addWidget( self.combo_box_export_stop_words_default_encoding, 1, 1, 1, 2) self.setLayout(wl_layout.Wl_Layout()) self.layout().addWidget(group_box_export_tables, 0, 0) self.layout().addWidget(group_box_export_search_terms, 1, 0) self.layout().addWidget(group_box_export_stop_words, 2, 0) self.layout().setContentsMargins(6, 4, 6, 4) self.layout().setRowStretch(3, 1) self.tables_default_type_changed()
def __init__(self, main): super().__init__(main, main.tr('Acknowledgments'), width=550) with open('wl_acks/wl_acks_general.csv', 'r', encoding='utf_8', newline='') as f: csv_reader = csv.reader(f, delimiter='|') self.ACKS_GENERAL = [row for row in csv_reader] with open('wl_acks/wl_acks_nlp.csv', 'r', encoding='utf_8', newline='') as f: csv_reader = csv.reader(f, delimiter='|') self.ACKS_NLP = [row for row in csv_reader] with open('wl_acks/wl_acks_lang_data.csv', 'r', encoding='utf_8', newline='') as f: csv_reader = csv.reader(f, delimiter='|') self.ACKS_LANG_DATA = [row for row in csv_reader] with open('wl_acks/wl_acks_plotting.csv', 'r', encoding='utf_8', newline='') as f: csv_reader = csv.reader(f, delimiter='|') self.ACKS_PLOTTING = [row for row in csv_reader] with open('wl_acks/wl_acks_misc.csv', 'r', encoding='utf_8', newline='') as f: csv_reader = csv.reader(f, delimiter='|') self.ACKS_MISC = [row for row in csv_reader] self.label_acks = wl_label.Wl_Label_Dialog( self.tr(''' <div> I would like to extend my sincere gratitude to the following open-source projects without which this project would not have been possible: </div> '''), self) self.label_browse_category = QLabel(self.tr('Browse by category:'), self) self.combo_box_browse_category = wl_box.Wl_Combo_Box(self) self.table_acks = wl_table.Wl_Table(self, headers=[ self.tr('Name'), self.tr('Version'), self.tr('Author(s)'), self.tr('License') ]) self.combo_box_browse_category.addItems([ self.tr('General'), self.tr('Natural Language Processing'), self.tr('Language Data'), self.tr('Plotting'), self.tr('Miscellaneous') ]) self.table_acks.setFixedHeight(250) self.combo_box_browse_category.currentTextChanged.connect( self.browse_category_changed) layout_browse_category = wl_layout.Wl_Layout() layout_browse_category.addWidget(self.label_browse_category, 0, 0) layout_browse_category.addWidget(self.combo_box_browse_category, 0, 1) layout_browse_category.setColumnStretch(2, 1) self.wrapper_info.layout().addWidget(self.label_acks, 0, 0) self.wrapper_info.layout().addLayout(layout_browse_category, 1, 0) self.wrapper_info.layout().addWidget(self.table_acks, 2, 0) self.load_settings() self.set_fixed_height()