In [1]:
from nltk.corpus.reader import TaggedCorpusReader
from nltk.tag import tnt
import pickle
In [2]:
#trainer
reader = TaggedCorpusReader('.', 'latin_training_set.pos')
train_sents = reader.tagged_sents()
In [3]:
#tester
test_reader = TaggedCorpusReader('.', 'latin_testing_set.pos')
test_sents = reader.tagged_sents()
In [4]:
tnt_tagger = tnt.TnT()
tnt_tagger.train(train_sents)
In [5]:
with open('latin_tnt_tagger.pickle', 'wb') as f:
    pickle.dump(tnt_tagger, f)
In [6]:
tnt_tagger.evaluate(test_sents)
Out[6]:
0.9871855183184991