nltk.DefaultTagger¶
-
class
nltk.DefaultTagger(tag)[source]¶ 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 (str) – The tag to assign to each token
Methods¶
__init__(tag) |
|
choose_tag(tokens, index, history) |
|
decode_json_obj(obj) |
|
encode_json_obj() |
|
evaluate(gold) |
Score the accuracy of the tagger against the gold standard. |
tag(tokens) |
|
tag_one(tokens, index, history) |
Determine an appropriate tag for the specified token, and return that tag. |
tag_sents(sentences) |
Apply self.tag() to each element of sentences. |
unicode_repr() |