class documentation
class DefaultTagger(SequentialBackoffTagger): (source)
Constructor: DefaultTagger(tag)
A tagger that assigns the same tag to every token.
>>> from nltk.tag import DefaultTagger >>> default_tagger = DefaultTagger('NN') >>> list(default_tagger.tag('This is a test'.split())) [('This', 'NN'), ('is', 'NN'), ('a', 'NN'), ('test', 'NN')]
This tagger is recommended as a backoff tagger, in cases where a more powerful tagger is unable to assign a tag to the word (e.g. because the word was not seen during training).
| Parameters | |
| tag | The tag to assign to each token |
| Class Method | decode |
Undocumented |
| Method | __init__ |
Undocumented |
| 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 | encode |
Undocumented |
| Class Variable | json |
Undocumented |
| Instance Variable | _tag |
Undocumented |
Inherited from SequentialBackoffTagger:
| 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. |
| Property | backoff |
The backoff tagger for this tagger. |
| 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 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 |
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.
| Parameters | |
| tokens:list | The list of words that are being tagged. |
| index:int | The index of the word whose tag should be returned. |
| history:list(str) | A list of the tags for all words before index. |
| Returns | |
| str | Undocumented |