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

Class 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)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
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

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

    Deprecated
 
tag_sents(*args, **kwargs) source code
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.

Inherited from object: __class__

Method Details [hide private]

__init__(self, backoff=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

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

tag_sents(*args, **kwargs)

source code 
Decorators:
  • @deprecated('Use batch_tag instead.')

Deprecated: Use batch_tag instead.


Property Details [hide private]

backoff

The backoff tagger for this tagger.

Get Method:
_get_backoff(self)