Backoff tagging is one of the core features of SequentialBackoffTagger
. It allows you to chain taggers together so that if one tagger doesn't know how to tag a word, it can pass the word on to the next backoff tagger. If that one can't do it, it can pass the word on to the next backoff tagger, and so on until there are no backoff taggers left to check.
Every subclass of SequentialBackoffTagger
can take a backoff
keyword argument whose value is another instance of a SequentialBackoffTagger
. So we will use the
DefaultTagger
from the Default tagging recipe as the backoff
to the UnigramTagger
from the Training a unigram part-of-speech tagger recipe. Refer to both recipes for details on train_sents
and test_sents
.
>>> tagger1 = DefaultTagger('NN') >>> tagger2 = UnigramTagger(train_sents, backoff=tagger1) >>> tagger2.evaluate(test_sents) 0.87459529462551266
By using a default tag of NN
whenever the UnigramTagger
is...