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

Class ProximateTokensTemplate

source code

    object --+    
             |    
BrillTemplateI --+
                 |
                ProximateTokensTemplate

An brill templates that generates a list of ProximateTokensRules that apply at a given sentence position. In particular, each ProximateTokensTemplate is parameterized by a proximate token brill rule class and a list of boundaries, and generates all rules that:

Instance Methods [hide private]
 
__init__(self, rule_class, *boundaries)
Construct a template for generating proximate token brill rules.
source code
list of BrillRule
applicable_rules(self, tokens, index, correct_tag)
Return a list of the transformational rules that would correct the ith subtoken's tag in the given token.
source code
 
_applicable_conditions(self, tokens, index, start, end)
Returns: A set of all conditions for proximate token rules that are applicable to tokens[index], given boundaries of (start, end).
source code
Set
get_neighborhood(self, tokens, 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, rule_class, *boundaries)
(Constructor)

source code 

Construct a template for generating proximate token brill rules.

Parameters:
  • rule_class (class) - The proximate token brill rule class that should be used to generate new rules. This class must be a subclass of ProximateTokensRule.
  • boundaries (tuple of (int, int)) - A list of tuples (start, end), each of which specifies a range for which a condition should be created by each rule.
Raises:
  • ValueError - If start>end for any boundary.
Overrides: BrillTemplateI.__init__

applicable_rules(self, tokens, index, correct_tag)

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 - The tagged tokens being tagged.
  • i - The index of the token whose tag should be corrected.
  • correctTag - The correct tag for the ith token.
Returns: list of BrillRule
Overrides: BrillTemplateI.applicable_rules
(inherited documentation)

_applicable_conditions(self, tokens, index, start, end)

source code 
Returns:
A set of all conditions for proximate token rules that are applicable to tokens[index], given boundaries of (start, end). I.e., return a list of all tuples (start, end, value), such the property value of at least one token between index+start and index+end (inclusive) is value.

get_neighborhood(self, tokens, 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 - The tokens being tagged.
  • index - The index whose neighborhood should be returned.
Returns: Set
Overrides: BrillTemplateI.get_neighborhood
(inherited documentation)