class documentation
class TrigramTagger(NgramTagger): (source)
Constructor: TrigramTagger(train, model, backoff, cutoff, verbose)
A tagger that chooses a token's tag based its word string and on the preceding two words' tags. In particular, a tuple consisting of the previous two tags and the word is looked up in a table, and the corresponding tag is returned.
Parameters | |
train | The corpus of training data, a list of tagged sentences |
model | The tagger model |
backoff | Another tagger which this tagger will consult when it is unable to tag a word |
cutoff | The number of instances of training data the tagger must see in order not to use the backoff tagger |
Method | __init__ |
No summary |
Class Variable | json |
Undocumented |
Inherited from NgramTagger
:
Class Method | decode |
Undocumented |
Method | context |
No summary |
Method | encode |
Undocumented |
Instance Variable | _n |
Undocumented |
Inherited from ContextTagger
(via NgramTagger
):
Method | __repr__ |
Undocumented |
Method | choose |
Decide which tag should be used for the specified token, and return that tag. If this tagger is unable to determine a tag for the specified token, return None -- do not consult the backoff tagger. This method should be overridden by subclasses of SequentialBackoffTagger. |
Method | size |
No summary |
Method | _train |
Initialize this ContextTagger's _context_to_tag table based on the given training data. In particular, for each context c in the training data, set _context_to_tag[c] to the most frequent tag for that context... |
Instance Variable | _context |
Dictionary mapping contexts to tags. |
Inherited from SequentialBackoffTagger
(via NgramTagger
, ContextTagger
):
Method | tag |
Determine the most appropriate tag sequence for the given token sequence, and return a corresponding list of tagged tokens. A tagged token is encoded as a tuple (token, tag). |
Method | tag |
Determine an appropriate tag for the specified token, and return that tag. If this tagger is unable to determine a tag for the specified token, then its backoff tagger is consulted. |
Instance Variable | _taggers |
A list of all the taggers that should be tried to tag a token (i.e., self and its backoff taggers). |
Inherited from TaggerI
(via NgramTagger
, ContextTagger
, SequentialBackoffTagger
):
Method | evaluate |
Score the accuracy of the tagger against the gold standard. Strip the tags from the gold standard text, retag it using the tagger, then compute the accuracy score. |
Method | tag |
Apply self.tag() to each element of sentences. I.e.: |
Method | _check |
Undocumented |
overrides
nltk.tag.sequential.NgramTagger.__init__
Parameters | |
train | Undocumented |
model | Undocumented |
backoff | The backoff tagger that should be used for this tagger. |
cutoff | Undocumented |
verbose | Undocumented |
context | A dictionary mapping contexts to tags. |