Class SymmetricProximateTokensTemplate
source code
object --+
|
BrillTemplateI --+
|
SymmetricProximateTokensTemplate
Simulates two ProximateTokensTemplates which are symmetric across the
location of the token. For rules of the form "If the nth token is tagged A
, and any tag
preceding or following the nth token by a
distance between x and y is
B
, and ... , then change the tag of the nth token from
A
to C
."
One ProximateTokensTemplate
is formed by passing in the
same arguments given to this class's constructor: tuples representing
intervals in which a tag may be found. The other
ProximateTokensTemplate
is constructed with the negative of
all the arguments in reversed order. For example, a
SymmetricProximateTokensTemplate
using the pair (-2,-1) and
the constructor ProximateTagsTemplate
generates the same
rules as a ProximateTagsTemplate
using (-2,-1) plus a second
ProximateTagsTemplate
using (1,2).
This is useful because we typically don't want templates to specify
only "following" or only "preceding"; we'd like our
rules to be able to look in either direction.
|
__init__(self,
rule_class,
*boundaries)
Construct a template for generating proximate token brill rules. |
source code
|
|
list of ProximateTokensRule
|
|
Set
|
get_neighborhood(self,
tokens,
index)
Returns the set of indices i such that
applicable_rules(token, index, ...) depends on the value
of the i th subtoken of token . |
source code
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
__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__
|
Returns the set of indices i such that
applicable_rules(token, index, ...) depends on the value of
the i th subtoken of token .
This method is used by the "fast" Brill tagger trainer.
- Returns:
Set
- Overrides:
BrillTemplateI.get_neighborhood
- (inherited documentation)
|