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

Type BrillRuleI

object --+
         |
        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.
Method Summary
  __eq__(self)
  __hash__(self)
Boolean applies(self, tokens, index)
Return true if the rule would change the tag of tokens[index], False otherwise
int apply_at(self, tokens, positions)
Apply this rule at every position in positions where it applies to the corpus.
list of int apply_to(self, tokens)
Apply this rule everywhere it applies in the corpus.
any original_tag(self)
Return the tag which this BrillRuleI may cause to be replaced.
any replacement_tag(self)
Return the tag with which this BrillRuleI may replace another tag.
Inherited from object: __init__, __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Method Details

applies(self, tokens, index)

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

apply_at(self, tokens, positions)

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 - The tagged corpus
           (type=list of Token)
positions - The positions where the transformation is to be tried.
           (type=list of int)
Returns:
The indices of tokens whose tags were changed by this rule.
           (type=int)

apply_to(self, tokens)

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 - The tagged corpus
           (type=list of tuple)
Returns:
The indices of tokens whose tags were changed by this rule.
           (type=list of int)

original_tag(self)

Returns:
The tag which this BrillRuleI may cause to be replaced.
           (type=any)

replacement_tag(self)

Returns:
the tag with which this BrillRuleI may replace another tag.
           (type=any)

Generated by Epydoc 2.1 on Tue Sep 5 09:37:22 2006 http://epydoc.sf.net