def main(model_loc, test_loc): tagger = redshift.tagger.GreedyTagger(model_loc, trained=True) test_data = open(test_loc).read() to_tag = redshift.io_parse.read_pos(test_data, sep='|') t1 = time.time() tagger.add_tags(to_tag) t2 = time.time() print '%d sents took %0.3f ms' % (to_tag.length, (t2 - t1) * 1000.0) gold = redshift.io_parse.read_pos(test_data, sep='|') acc, c, n = redshift.io_parse.eval_tags(to_tag, gold) print '%.2f' % acc, c, n
def main(model_loc, test_loc): tagger = redshift.tagger.GreedyTagger(model_loc, trained=True) test_data = open(test_loc).read() to_tag = redshift.io_parse.read_pos(test_data, sep='|') t1 = time.time() tagger.add_tags(to_tag) t2 = time.time() print '%d sents took %0.3f ms' % (to_tag.length, (t2-t1)*1000.0) gold = redshift.io_parse.read_pos(test_data, sep='|') acc, c, n = redshift.io_parse.eval_tags(to_tag, gold) print '%.2f' % acc, c, n
def train_and_tag(tagger, train_strs, test_strs): train_sents = redshift.io_parse.read_conll(train_strs) test_sents = redshift.io_parse.read_conll(test_strs) tagger.train(train_sents) tagger.add_tags(test_sents) return test_sents.write_pos()