Package nltk :: Package parse :: Module chart :: Class ChartRuleI
[hide private]
[frames] | no frames]

Class ChartRuleI

source code

object --+
         |
        ChartRuleI

A rule that specifies what new edges are licensed by any given set of existing edges. Each chart rule expects a fixed number of edges, as indicated by the class variable NUM_EDGES. In particular:

Instance Methods [hide private]
list of EdgeI
apply(self, chart, grammar, *edges)
Add the edges licensed by this rule and the given edges to the chart.
source code
iter of EdgeI
apply_iter(self, chart, grammar, *edges)
Returns: A generator that will add edges licensed by this rule and the given edges to the chart, one at a time.
source code
list of EdgeI
apply_everywhere(self, chart, grammar)
Add all the edges licensed by this rule and the edges in the chart to the chart.
source code
iter of EdgeI
apply_everywhere_iter(self, chart, grammar)
Returns: A generator that will add all edges licensed by this rule, given the edges that are currently in the chart, one at a time.
source code

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

Class Variables [hide private]
int NUM_EDGES
The number of existing edges that this rule uses to license new edges.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

apply(self, chart, grammar, *edges)

source code 

Add the edges licensed by this rule and the given edges to the chart.

Parameters:
  • edges (list of EdgeI) - A set of existing edges. The number of edges that should be passed to apply is specified by the NUM_EDGES class variable.
Returns: list of EdgeI
A list of the edges that were added.

apply_iter(self, chart, grammar, *edges)

source code 
Parameters:
  • edges (list of EdgeI) - A set of existing edges. The number of edges that should be passed to apply is specified by the NUM_EDGES class variable.
Returns: iter of EdgeI
A generator that will add edges licensed by this rule and the given edges to the chart, one at a time. Each time the generator is resumed, it will either add a new edge and yield that edge; or return.

apply_everywhere(self, chart, grammar)

source code 

Add all the edges licensed by this rule and the edges in the chart to the chart.

Returns: list of EdgeI
A list of the edges that were added.

apply_everywhere_iter(self, chart, grammar)

source code 
Returns: iter of EdgeI
A generator that will add all edges licensed by this rule, given the edges that are currently in the chart, one at a time. Each time the generator is resumed, it will either add a new edge and yield that edge; or return.

Class Variable Details [hide private]

NUM_EDGES

The number of existing edges that this rule uses to license new edges. Typically, this number ranges from zero to two.
Type:
int