def printVocab(self, lexiconPath): xml = openXml(lexiconPath, 'utf-8') xml.open('lexicon') xml.empty('phoneme-inventory') xml.comment('special lemmas') for special, orthEval in self.special.iteritems(): xml.open('lemma', special=special) for orth in orthEval[0]: xml.element('orth', orth) xml.empty('phon') if orthEval[1] is None: xml.empty('eval') else: xml.open('eval') xml.element('tok', orthEval[1]) xml.close() xml.close() xml.comment('regular lemmas') for orth in self.vocab: xml.open('lemma') xml.element('orth', orth) xml.empty('phon') xml.close() xml.close() closeXml(xml) if self.isLog: print >> sys.stderr, '-->', lexiconPath
def parse(self, pathIn, pathOut, encoding): self.category_ = [] self.processLine_ = self.processHeaderLine_ fd = uopen(pathIn, encoding, 'r') for line in fd: self.processLine_(line) uclose(fd) xml = openXml(pathOut, encoding) self.writeBliss_(xml) closeXml(xml) if self.isLog: print >> sys.stderr, pathIn, '-->', pathOut
def convert(self): """ reads the old cart tree and converts it to the new xml-format """ self._writer = openXml(self._pathToNewTree, self._newEncoding) self._setNumberOfCartClasses() self._reader = uopen(self._pathToOldTree) self._writer.open("decision-tree") self._convertPhonemeList() self._convertQuestionList() self._convertBinaryTree() self._writer.close("decision-tree") closeXml(self._writer) uclose(self._reader)
## print >> stderr, 'Warning: exit status of \"' + aligner + '\" is', str(exitCode) cmd = aligner + ' ' + ' '.join(argv) print >> stderr, 'Run', '"' + cmd + '"' os.system(cmd) assert os.path.exists(alignmentPath) print >> stderr, '\"' + alignmentPath + '\" created' else: print >> stderr, 'Alignment file \"' + alignmentPath + '\" is up to date' print >> stderr # calculate overall wer resultPath = getNormalizedPath( getValue(options.resultPath, getDefaultResultPath(os.path.curdir, corpusFilename))) if options.force or not valid(resultPath, alignmentPath): print >> stderr, 'Calculate result from \"' + alignmentPath + '\" ...' accu, stats = calculateErrorStatistics(alignmentPath, True, True, corpusPath) xml = openXml(resultPath, accu.encoding) stats.writeXml(xml) closeXml(xml) assert os.path.exists(resultPath) print >> stderr, '\"' + resultPath + '\" created' del accu del stats else: print >> stderr, 'Result file \"' + resultPath + '\" is up to date' print >> stderr uclose(stderr)
optparser.add_option("-s", "--speaker", dest="bySpeaker", action="store_true", default=False, help="dump statistics by speaker") optparser.add_option("-c", "--condition", dest="byCondition", action="store_true", default=False, help="dump statistics by condition") optparser.add_option( "-b", "--corpus", dest="corpusPath", default=None, help="bliss corpus; used to get speaker and condition names", metavar="FILE") if len(sys.argv) == 1: optparser.print_help() sys.exit(0) options, args = optparser.parse_args() accu, stats = calculateErrorStatistics(args[0], options.bySpeaker, options.byCondition, options.corpusPath) xml = openXml(options.output, accu.encoding) stats.writeXml(xml) closeXml(xml)
def openCorpus(self): self.xml = openXml(self.corpusFile) self.xml.open('corpus', name=self.name) # speaker # condition self.segFd = uwrite(self.segFile)
def startFile(self, path, encoding): self.xml = openXml(self.outPath, encoding)