class nltk.tag.CRFTagger(feature_func=None, verbose=False, training_opt={})[source]

A module for POS tagging using CRFSuite

>>> from nltk.tag import CRFTagger
>>> ct = CRFTagger()
>>> train_data = [[('University','Noun'), ('is','Verb'), ('a','Det'), ('good','Adj'), ('place','Noun')],
... [('dog','Noun'),('eat','Verb'),('meat','Noun')]]
>>> ct.train(train_data,'model.crf.tagger')
>>> ct.tag_sents([['dog','is','good'], ['Cat','eat','meat']])
[[('dog', 'Noun'), ('is', 'Verb'), ('good', 'Adj')], [('Cat', 'Noun'), ('eat', 'Verb'), ('meat', 'Noun')]]
>>> gold_sentences = [[('dog','Noun'),('is','Verb'),('good','Adj')] , [('Cat','Noun'),('eat','Verb'), ('meat','Noun')]] 
>>> ct.evaluate(gold_sentences) 

Setting learned model file >>> ct = CRFTagger() >>> ct.set_model_file(‘model.crf.tagger’) >>> ct.evaluate(gold_sentences) 1.0


__init__([feature_func, verbose, training_opt]) Initialize the CRFSuite tagger :param feature_func: The function that extracts features for each token of a sentence.
evaluate(gold) Score the accuracy of the tagger against the gold standard.
tag(tokens) Tag a sentence using Python CRFSuite Tagger.
tag_sents(sents) Tag a list of sentences.
train(train_data, model_file) Train the CRF tagger using CRFSuite :params train_data : is the list of annotated sentences.