class documentation

class BrillTemplateI: (source)

Known subclasses: nltk.tbl.template.Template

View In Hierarchy

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.

Method applicable_rules Return a list of the transformational rules that would correct the i*th subtoken's tag in the given token. In particular, return a list of zero or more rules that would change *tokens*[i][1] to *correctTag...
Method get_neighborhood Returns the set of indices i such that applicable_rules(token, i, ...) depends on the value of the index*th token of *token.
@abstractmethod
def applicable_rules(self, tokens, i, correctTag): (source)

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

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

Parameters
tokens:list(tuple)The tagged tokens being tagged.
i:intThe index of the token whose tag should be corrected.
correctTag:anyThe correct tag for the *i*th token.
Returns
list(BrillRule)Undocumented
@abstractmethod
def get_neighborhood(self, token, index): (source)

Returns the set of indices i such that applicable_rules(token, i, ...) depends on the value of the index*th token of *token.

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

Parameters
token:list(tuple)The tokens being tagged.
index:intThe index whose neighborhood should be returned.
Returns
setUndocumented