Package nltk_lite :: Package tag :: Module brill :: Class BrillRuleI
[hide private]
[frames] | no frames]

Class BrillRuleI

source code

     object --+    
              |    
yaml.YAMLObject --+
                  |
                 BrillRuleI
Known Subclasses:
ProximateTokensRule

An interface for tag transformations on a tagged corpus, as performed by brill taggers. Each transformation finds all tokens in the corpus that are tagged with a specific original tag and satisfy a specific condition, and replaces their tags with a replacement tag. For any given transformation, the original tag, replacement tag, and condition are fixed. Conditions may depend on the token under consideration, as well as any other tokens in the corpus.

Brill rules must be comparable and hashable.

Nested Classes [hide private]

Inherited from yaml.YAMLObject: __metaclass__, yaml_dumper, yaml_loader

Instance Methods [hide private]
list of int
apply_to(self, tokens)
Apply this rule everywhere it applies in the corpus.
source code
int
apply_at(self, tokens, positions)
Apply this rule at every position in positions where it applies to the corpus.
source code
Boolean
applies(self, tokens, index)
Returns: True if the rule would change the tag of tokens[index], False otherwise
source code
any
original_tag(self)
Returns: The tag which this BrillRuleI may cause to be replaced.
source code
any
replacement_tag(self)
Returns: the tag with which this BrillRuleI may replace another tag.
source code
 
__eq__(self) source code
 
__hash__(self)
hash(x)
source code

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

Class Methods [hide private]

Inherited from yaml.YAMLObject: from_yaml, to_yaml

Class Variables [hide private]

Inherited from yaml.YAMLObject: yaml_flow_style, yaml_tag

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

apply_to(self, tokens)

source code 

Apply this rule everywhere it applies in the corpus. I.e., for each token in the corpus that is tagged with this rule's original tag, and that satisfies this rule's condition, set its tag to be this rule's replacement tag.

Parameters:
  • tokens (list of tuple) - The tagged corpus
Returns: list of int
The indices of tokens whose tags were changed by this rule.

apply_at(self, tokens, positions)

source code 

Apply this rule at every position in positions where it applies to the corpus. I.e., for each position p in positions, if tokens[p] is tagged with this rule's original tag, and satisfies this rule's condition, then set its tag to be this rule's replacement tag.

Parameters:
  • tokens (list of Token) - The tagged corpus
  • positions (list of int) - The positions where the transformation is to be tried.
Returns: int
The indices of tokens whose tags were changed by this rule.

applies(self, tokens, index)

source code 
Parameters:
  • tokens (list of Token) - A tagged corpus
  • index (int) - The index to check
Returns: Boolean
True if the rule would change the tag of tokens[index], False otherwise

original_tag(self)

source code 
Returns: any
The tag which this BrillRuleI may cause to be replaced.

replacement_tag(self)

source code 
Returns: any
the tag with which this BrillRuleI may replace another tag.

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)