Package nltk :: Package tag :: Module sequential :: Class UnigramTagger
[hide private]
[frames] | no frames]

Class UnigramTagger

source code

         object --+                
                  |                
        api.TaggerI --+            
                      |            
SequentialBackoffTagger --+        
                          |        
              ContextTagger --+    
                              |    
                 object --+   |    
                          |   |    
            yaml.YAMLObject --+    
                              |    
                    NgramTagger --+
                                  |
                                 UnigramTagger
Known Subclasses:

A tagger that chooses a token's tag based its word string. Unigram taggers are typically trained on a tagged corpus.

Nested Classes [hide private]

Inherited from yaml.YAMLObject: __metaclass__, yaml_dumper, yaml_loader

Instance Methods [hide private]
 
__init__(self, train=None, model=None, backoff=None, cutoff=1, verbose=False)
Train a new NgramTagger using the given training data or the supplied model.
source code
(hashable)
context(self, tokens, index, history)
Returns: the context that should be used to look up the tag for the specified token; or None if the specified token should not be handled by this tagger.
source code

Inherited from ContextTagger: __repr__, choose_tag, size

Inherited from ContextTagger (private): _train

Inherited from SequentialBackoffTagger: tag, tag_one

Inherited from SequentialBackoffTagger (private): _get_backoff

Inherited from api.TaggerI: batch_tag

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

    Deprecated

Inherited from SequentialBackoffTagger: tag_sents

Class Methods [hide private]

Inherited from yaml.YAMLObject: from_yaml, to_yaml

Class Variables [hide private]
  yaml_tag = '!nltk.UnigramTagger'

Inherited from yaml.YAMLObject: yaml_flow_style

Instance Variables [hide private]

Inherited from ContextTagger (private): _context_to_tag

Inherited from SequentialBackoffTagger (private): _taggers

Properties [hide private]

Inherited from SequentialBackoffTagger: backoff

Inherited from object: __class__

Method Details [hide private]

__init__(self, train=None, model=None, backoff=None, cutoff=1, verbose=False)
(Constructor)

source code 

Train a new NgramTagger using the given training data or the supplied model. In particular, construct a new tagger whose table maps from each context (tag[i-n:i-1], word[i]) to the most frequent tag for that context. But exclude any contexts that are already tagged perfectly by the backoff tagger.

Parameters:
  • train - A tagged corpus. Each item should be a list of (word, tag) tuples.
  • backoff - A backoff tagger, to be used by the new tagger if it encounters an unknown context.
  • cutoff - If the most likely tag for a context occurs fewer than cutoff times, then exclude it from the context-to-tag table for the new tagger.
Overrides: NgramTagger.__init__
(inherited documentation)

context(self, tokens, index, history)

source code 
Returns: (hashable)
the context that should be used to look up the tag for the specified token; or None if the specified token should not be handled by this tagger.
Overrides: NgramTagger.context