def simple_tagger_eval(eval_path, gold_path, out_f = sys.stdout, csv=True): eval_c = POSCorpus.read_simpletagger(eval_path) gold_c = POSCorpus.read_simpletagger(gold_path) poseval(eval_c, gold_c, out_f)
def conll_to_slashtags(infiles, outpath): ''' This will @param infiles: A list of CONLL pathnames to convert. @param outpath: A single output pathname for the slashtags. ''' main_c = POSCorpus() for f in infiles: from intent.corpora.conll import ConllCorpus cp = ConllCorpus.read(f) main_c.extend(c) st = c.slashtags('/', lowercase=True) # Create the containing path if it doesn't already exist os.makedirs(os.path.dirname(outpath), exist_ok=True) of = open(outpath, 'w', encoding='utf-8') of.write(st) of.close()
def slashtags_eval(goldpath, testpath, delimiter, out_f=sys.stdout, tagmap=None, matrix=False, details=False, length_limit=None): ''' Evaluate a "slashtags" format file :param goldpath: :type goldpath: :param testpath: :type testpath: :param delimiter: :type delimiter: :param out_f: :type out_f: :param tagmap: :type tagmap: :rtype: POSEvalDict ''' gold_c = POSCorpus.read_slashtags(goldpath) test_c = POSCorpus.read_slashtags(testpath) poseval(test_c, gold_c, out_f, matrix=matrix, details=details, length_limit=length_limit)
def slashtags_to_simpletagger(in_path, out_path): p = POSCorpus.read_slashtags(in_path) out_f = open(out_path, 'w', encoding='utf-8') for inst in p: sf = SequenceFeature(inst) while sf: out_f.write('%s ' % sf.form) # out_f.write('word-%s ' % sf.form) # out_f.write('pre-3-%s ' % sf.prefix(3)) # out_f.write('pre-2-%s ' % sf.prefix(2)) # # out_f.write('suf-3-%s ' % sf.suffix(3)) # out_f.write('suf-2-%s ' % sf.suffix(2)) # # #=================================================================== # # Context Features # #=================================================================== # out_f.write('prev-%s ' % sf.prev().form) # out_f.write('next-%s ' % sf.next().form) # # #=================================================================== # # More Context # #=================================================================== # out_f.write('prev-prev-%s ' % sf.prev().prev().form) # out_f.write('next-next-%s ' % sf.next().next().form) # Finally, write out the label out_f.write('%s\n' % sf.label) sf = sf.next() out_f.write('\n') out_f.close()