Exemple #1
0
    def inspect(self):
        if self.textType is not None and os.path.exists(self.pathWidget.value()):
            if self.textType == 'csv':
                try:
                    atts, coldelim = inspect_csv(self.pathWidget.value())
                except PCTError:
                    self.columnFrame.updateColumnFrame([])
                    return
                self.columnDelimiterEdit.setText(coldelim.encode('unicode_escape').decode('utf-8'))
                self.columnFrame.updateColumnFrame(atts)
            else:
                if self.textType == 'textgrid':
                    anno_types = inspect_discourse_textgrid(self.pathWidget.value())
                elif self.textType == 'ilg':
                    anno_types = inspect_discourse_ilg(self.pathWidget.value())
                    self.lineNumberEdit.setText(str(len(anno_types)))
                elif self.textType == 'transcription':
                    anno_types = inspect_discourse_transcription(self.pathWidget.value())
                elif self.textType == 'spelling':
                    anno_types = inspect_discourse_spelling(self.pathWidget.value())
                elif self.textType in ['buckeye','timit']:

                    anno_types = inspect_discourse_multiple_files(self.pathWidget.value(), self.textType)
                self.columnFrame.updateColumnFrame(anno_types)

        else:
            self.columnFrame.updateColumnFrame([])
Exemple #2
0
    def inspect(self):
        if self.textType is not None and os.path.exists(
                self.pathWidget.value()):
            if self.textType == 'csv':
                try:
                    atts, coldelim = inspect_csv(self.pathWidget.value())
                except PCTError:
                    self.columnFrame.updateColumnFrame([])
                    return
                self.columnDelimiterEdit.setText(
                    coldelim.encode('unicode_escape').decode('utf-8'))
                self.columnFrame.updateColumnFrame(atts)
            else:
                if self.textType == 'textgrid':
                    anno_types = inspect_discourse_textgrid(
                        self.pathWidget.value())
                elif self.textType == 'ilg':
                    anno_types = inspect_discourse_ilg(self.pathWidget.value())
                    self.lineNumberEdit.setText(str(len(anno_types)))
                elif self.textType == 'transcription':
                    anno_types = inspect_discourse_transcription(
                        self.pathWidget.value())
                elif self.textType == 'spelling':
                    anno_types = inspect_discourse_spelling(
                        self.pathWidget.value())
                elif self.textType in ['buckeye', 'timit']:

                    anno_types = inspect_discourse_multiple_files(
                        self.pathWidget.value(), self.textType)
                self.columnFrame.updateColumnFrame(anno_types)

        else:
            self.columnFrame.updateColumnFrame([])
def test_stressed(csv_test_dir):
    stressed_path = os.path.join(csv_test_dir, 'stressed.txt')
    ats,_ = inspect_csv(stressed_path, coldelim = ',')
    print(ats)
    ats[1].number_behavior = 'stress'
    c = load_corpus_csv('stressed',stressed_path,',', ats)
    assert(c.inventory['uw'].symbol == 'uw')
    assert(c.inventory.stresses == {'1': set(['uw','iy']),
                                    '0': set(['uw','iy','ah'])})
def test_inspect_example(csv_test_dir):
    example_path = os.path.join(csv_test_dir, 'example.txt')
    atts, coldelim = inspect_csv(example_path)
    assert(coldelim == ',')
    for a in atts:
        if a.name == 'frequency':
            assert(a.attribute.att_type == 'numeric')
        elif a.name == 'transcription':
            assert(a.attribute.att_type == 'tier')
            assert(a.delimiter == '.')
        elif a.name == 'spelling':
            assert(a.attribute.att_type == 'spelling')
Exemple #5
0
 def forceInspect(self, b):
     if os.path.exists(self.pathWidget.value()):
         if self.textType == 'csv':
             colDelim = codecs.getdecoder("unicode_escape")(self.columnDelimiterEdit.text())[0]
             if not colDelim:
                 colDelim = None
             atts, coldelim = inspect_csv(self.pathWidget.value(),
                     coldelim = colDelim)
             self.updateColumnFrame(atts)
         elif self.textType == 'ilg':
             number = self.lineNumberEdit.text()
             if number == '':
                 number = None
             else:
                 try:
                     number = int(number)
                 except:
                     number = None
             annotation_types = inspect_discourse_ilg(self.pathWidget.value(), number = number)
             self.columnFrame.updateColumnFrame(annotation_types)
Exemple #6
0
 def forceInspect(self, b):
     if os.path.exists(self.pathWidget.value()):
         if self.textType == 'csv':
             colDelim = codecs.getdecoder("unicode_escape")(
                 self.columnDelimiterEdit.text())[0]
             if not colDelim:
                 colDelim = None
             atts, coldelim = inspect_csv(self.pathWidget.value(),
                                          coldelim=colDelim)
             self.updateColumnFrame(atts)
         elif self.textType == 'ilg':
             number = self.lineNumberEdit.text()
             if number == '':
                 number = None
             else:
                 try:
                     number = int(number)
                 except:
                     number = None
             annotation_types = inspect_discourse_ilg(
                 self.pathWidget.value(), number=number)
             self.columnFrame.updateColumnFrame(annotation_types)