def accept(self): filters = self.filterWidget.value() name = self.nameEdit.text() if name == '': reply = QMessageBox.critical(self, "Missing information", "Please specify a name for the new corpus.") return None if len(filters) == 0: reply = QMessageBox.critical(self, "Missing information", "Please specify at least one filter.") return None if name in get_corpora_list(self.parent().settings['storage']): msgBox = QMessageBox(QMessageBox.Warning, "Duplicate name", "A corpus named '{}' already exists. Overwrite?".format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Abort", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return new_corpus = self.corpus.subset(filters) new_corpus.name = name new_corpus.set_feature_matrix(self.corpus.specifier) save_binary(new_corpus, corpus_name_to_path(self.parent().settings['storage'],new_corpus.name)) QDialog.accept(self)
def accept(self): filters = self.filterWidget.value() name = self.nameEdit.text() if name == '': reply = QMessageBox.critical( self, "Missing information", "Please specify a name for the new corpus.") return None if len(filters) == 0: reply = QMessageBox.critical( self, "Missing information", "Please specify at least one filter.") return None if name in get_corpora_list(self.parent().settings['storage']): msgBox = QMessageBox( QMessageBox.Warning, "Duplicate name", "A corpus named '{}' already exists. Overwrite?".format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Abort", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return new_corpus = self.corpus.subset(filters) new_corpus.name = name new_corpus.set_feature_matrix(self.corpus.specifier) save_binary( new_corpus, corpus_name_to_path(self.parent().settings['storage'], new_corpus.name)) QDialog.accept(self)
def accept(self): name = self.corporaWidget.value() if name in get_corpora_list(self.settings['storage']): msgBox = QMessageBox( QMessageBox.Warning, "Overwrite corpus", "The corpus '{}' is already available. Would you like to overwrite it?" .format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Cancel", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return self.thread.setParams({ 'name': name, 'path': corpus_name_to_path(self.settings['storage'], name) }) self.thread.start() result = self.progressDialog.exec_() self.progressDialog.reset() if result: QDialog.accept(self)
def generateKwargs(self): path = self.pathWidget.value() if path == '': reply = QMessageBox.critical(self, "Missing information", "Please specify a file or directory.") return if not os.path.exists(path): reply = QMessageBox.critical(self, "Invalid information", "The specified path does not exist.") return name = self.nameEdit.text() if name == '': reply = QMessageBox.critical(self, "Missing information", "Please specify a name for the corpus.") return kwargs = {'corpus_name': name, 'path': path, 'isDirectory':self.isDirectory, 'text_type': self.textType} kwargs['annotation_types'] = [x.value() for x in reversed(self.columnFrame.columns)] if self.textType == 'csv': kwargs['delimiter'] = codecs.getdecoder("unicode_escape")( self.columnDelimiterEdit.text() )[0] kwargs['feature_system_path'] = self.csvFeatureSystem.path() elif self.textType == 'textgrid': kwargs['feature_system_path'] = self.tgFeatureSystem.path() elif self.textType == 'spelling': (kwargs['support_corpus_path'], kwargs['ignore_case']) = self.runningLookupWidget.value() elif self.textType == 'transcription': kwargs['feature_system_path'] = self.runningFeatureSystem.path() elif self.textType == 'ilg': kwargs['feature_system_path'] = self.ilgFeatureSystem.path() #(kwargs['support_corpus_path'], # kwargs['ignore_case']) = self.ilgLookupWidget.value() elif self.textType in ['buckeye', 'timit']: kwargs['feature_system_path'] = self.multFeatureSystem.path() if not self.isDirectory: base, ext = os.path.splitext(path) if ext == '.words': phone_path = base +'.phones' elif ext == '.wrd': phone_path = base + '.phn' if not os.path.exists(phone_path): reply = QMessageBox.critical(self, "Invalid information", "The phone file for the specifie words file does not exist.") return kwargs['word_path'] = kwargs.pop('path') kwargs['phone_path'] = phone_path if name in get_corpora_list(self.settings['storage']): msgBox = QMessageBox(QMessageBox.Warning, "Duplicate name", "A corpus named '{}' already exists. Overwrite?".format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Abort", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return None return kwargs
def accept(self): name = self.corporaWidget.value() if name in get_corpora_list(self.settings['storage']): msgBox = QMessageBox(QMessageBox.Warning, "Overwrite corpus", "The corpus '{}' is already available. Would you like to overwrite it?".format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Cancel", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return self.thread.setParams({'name':name, 'path':corpus_name_to_path(self.settings['storage'],name)}) self.thread.start() result = self.progressDialog.exec_() self.progressDialog.reset() if result: QDialog.accept(self)
def getAvailableCorpora(self): self.corporaList.clear() corpora = get_corpora_list(self.settings['storage']) for c in corpora: self.corporaList.addItem(c)
def generateKwargs(self): path = self.pathWidget.value() if path == '': reply = QMessageBox.critical( self, "Missing information", "Please specify a file or directory.") return if not os.path.exists(path): reply = QMessageBox.critical(self, "Invalid information", "The specified path does not exist.") return name = self.nameEdit.text() if name == '': reply = QMessageBox.critical( self, "Missing information", "Please specify a name for the corpus.") return kwargs = { 'corpus_name': name, 'path': path, 'isDirectory': self.isDirectory, 'text_type': self.textType } kwargs['annotation_types'] = [ x.value() for x in reversed(self.columnFrame.columns) ] if self.textType == 'csv': kwargs['delimiter'] = codecs.getdecoder("unicode_escape")( self.columnDelimiterEdit.text())[0] kwargs['feature_system_path'] = self.csvFeatureSystem.path() elif self.textType == 'textgrid': kwargs['feature_system_path'] = self.tgFeatureSystem.path() elif self.textType == 'spelling': (kwargs['support_corpus_path'], kwargs['ignore_case']) = self.runningLookupWidget.value() elif self.textType == 'transcription': kwargs['feature_system_path'] = self.runningFeatureSystem.path() elif self.textType == 'ilg': kwargs['feature_system_path'] = self.ilgFeatureSystem.path() #(kwargs['support_corpus_path'], # kwargs['ignore_case']) = self.ilgLookupWidget.value() elif self.textType in ['buckeye', 'timit']: kwargs['feature_system_path'] = self.multFeatureSystem.path() if not self.isDirectory: base, ext = os.path.splitext(path) if ext == '.words': phone_path = base + '.phones' elif ext == '.wrd': phone_path = base + '.phn' if not os.path.exists(phone_path): reply = QMessageBox.critical( self, "Invalid information", "The phone file for the specifie words file does not exist." ) return kwargs['word_path'] = kwargs.pop('path') kwargs['phone_path'] = phone_path if name in get_corpora_list(self.settings['storage']): msgBox = QMessageBox( QMessageBox.Warning, "Duplicate name", "A corpus named '{}' already exists. Overwrite?".format(name), QMessageBox.NoButton, self) msgBox.addButton("Overwrite", QMessageBox.AcceptRole) msgBox.addButton("Abort", QMessageBox.RejectRole) if msgBox.exec_() != QMessageBox.AcceptRole: return None return kwargs