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

Class TrigramTagger

source code

         object --+                
                  |                
        api.TaggerI --+            
                      |            
SequentialBackoffTagger --+        
                          |        
              ContextTagger --+    
                              |    
                 object --+   |    
                          |   |    
            yaml.YAMLObject --+    
                              |    
                    NgramTagger --+
                                  |
                                 TrigramTagger

A tagger that chooses a token's tag based its word string and on the preceeding 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. Trigram taggers are typically trained them 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

Inherited from NgramTagger: context

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.TrigramTagger'

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)