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

type SequentialBackoffTagger

source code

 object --+    
          |    
api.TaggerI --+
              |
             SequentialBackoffTagger
Known Subclasses:

An abstract base class for taggers that tags words sequentially, left to right. Tagging of individual words is performed by the method choose_tag(), which should be defined by subclasses. If a tagger is unable to determine a tag for the specified token, then its backoff tagger is consulted.

Instance Methods [hide private]
 
__init__(self, backoff=None) source code
 
_get_backoff(self) source code
list of (token, tag)
tag(self, tokens)
Determine the most appropriate tag sequence for the given token sequence, and return a corresponding list of tagged tokens.
source code
str
tag_one(self, tokens, index, history)
Determine an appropriate tag for the specified token, and return that tag.
source code
str
choose_tag(self, tokens, index, history)
Decide which tag should be used for the specified token, and return that tag.
source code

Inherited from api.TaggerI: batch_tag, evaluate

Inherited from api.TaggerI (private): _check_params

Instance Variables [hide private]
  _taggers
A list of all the taggers that should be tried to tag a token (i.e., self and its backoff taggers).
Properties [hide private]
  backoff
The backoff tagger for this tagger.
Method Details [hide private]

__init__(self, backoff=None)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

tag(self, tokens)

source code 

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).

Returns: list of (token, tag)
Overrides: api.TaggerI.tag
(inherited documentation)

tag_one(self, tokens, index, history)

source code 

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.

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 of str) - A list of the tags for all words before index.
Returns: str

choose_tag(self, tokens, index, history)

source code 

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 of str) - A list of the tags for all words before index.
Returns: str

Property Details [hide private]

backoff

The backoff tagger for this tagger.

Get Method:
_get_backoff(self)