Package nltk :: Package tag :: Module brill :: Class BrillTemplateI
[hide private]
[frames] | no frames]

Class BrillTemplateI

source code

object --+
         |
        BrillTemplateI
Known Subclasses:

An interface for generating lists of transformational rules that apply at given sentence positions. BrillTemplateI is used by Brill training algorithms to generate candidate rules.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
list of BrillRule
applicable_rules(self, tokens, i, correctTag)
Return a list of the transformational rules that would correct the ith subtoken's tag in the given token.
source code
Set
get_neighborhood(self, token, index)
Returns the set of indices i such that applicable_rules(token, i, ...) depends on the value of the indexth subtoken of token.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

applicable_rules(self, tokens, i, correctTag)

source code 

Return a list of the transformational rules that would correct the ith subtoken's tag in the given token. In particular, return a list of zero or more rules that would change tagged_tokens[i][1] to correctTag, if applied to token.

If the ith subtoken already has the correct tag (i.e., if tagged_tokens[i][1] == correctTag), then applicable_rules should return the empty list.

Parameters:
  • tokens (list of tuple) - The tagged tokens being tagged.
  • i (int) - The index of the token whose tag should be corrected.
  • correctTag ((any)) - The correct tag for the ith token.
Returns: list of BrillRule

get_neighborhood(self, token, index)

source code 

Returns the set of indices i such that applicable_rules(token, i, ...) depends on the value of the indexth subtoken of token.

This method is used by the "fast" Brill tagger trainer.

Parameters:
  • token (list of tuple) - The tokens being tagged.
  • index (int) - The index whose neighborhood should be returned.
Returns: Set