class documentation

class ChartRuleI(object): (source)

Known subclasses: nltk.parse.chart.AbstractChartRule

View In Hierarchy

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:

  • A chart rule with NUM_EDGES=0 specifies what new edges are licensed, regardless of existing edges.
  • A chart rule with NUM_EDGES=1 specifies what new edges are licensed by a single existing edge.
  • A chart rule with NUM_EDGES=2 specifies what new edges are licensed by a pair of existing edges.
Method apply Return 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.
Method apply_everywhere Return 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 NUM_EDGES The number of existing edges that this rule uses to license new edges. Typically, this number ranges from zero to two.
def apply(self, chart, grammar, *edges): (source)

Return 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.

Parameters
chartUndocumented
grammarUndocumented
*edges:list(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(EdgeI)Undocumented
def apply_everywhere(self, chart, grammar): (source)

Return 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.

Returns
iter(EdgeI)Undocumented