About Lesson
In this Python NLP lesson we are going to learn about Python NLP Backoff Tagging, so back of tagging is one of the features from SequentialBackOffTagger. using Back of tagging we can chain taggers together, so if that one tagger does not know how to tag a word, it pass the word to the next back off tagger, if that one was not able to tag the word it can pass that to another Back Of Tagger, so this is the work for BackOff Tagging.
1 2 3 4 5 6 7 8 9 10 11 |
from nltk.tag import UnigramTagger, DefaultTagger from nltk.corpus import treebank train_sents = treebank.tagged_sents()[:2000] test_sents = treebank.tagged_sents()[2000:] tagger1 = DefaultTagger('NN') tagger2 = UnigramTagger(train_sents, backoff=tagger1) print("Back of Accuracy : " , tagger2.evaluate(test_sents)) |
After runing the code you can see that we have good accuracy and it is 85 percent.
1 |
Back of Accuracy : 0.8547119075476733 |
Along with UnigramTagger, there are two more taggers that we can use, we have BigramTagger and TriGramTagger.