class AbstractChartRule(ChartRuleI): (source)
Known subclasses: nltk.ccg.chart.BackwardTypeRaiseRule, nltk.ccg.chart.BinaryCombinatorRule, nltk.ccg.chart.ForwardTypeRaiseRule, nltk.parse.chart.BottomUpPredictRule, nltk.parse.chart.EmptyPredictRule, nltk.parse.chart.FundamentalRule, nltk.parse.chart.LeafInitRule, nltk.parse.chart.TopDownInitRule, nltk.parse.chart.TopDownPredictRule, nltk.parse.pchart.ProbabilisticBottomUpInitRule, nltk.parse.pchart.ProbabilisticBottomUpPredictRule, nltk.parse.pchart.ProbabilisticFundamentalRule, nltk.parse.pchart.SingleEdgeProbabilisticFundamentalRule
An abstract base class for chart rules. AbstractChartRule provides:
- A default implementation for apply.
- A default implementation for apply_everywhere, (Currently, this implementation assumes that ``NUM_EDGES``<=3.)
- A default implementation for __str__, which returns a name based on the rule's class name.
| Method | __str__ |
Undocumented |
| 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 |
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. |
Inherited from ChartRuleI:
| Class Variable | NUM |
The number of existing edges that this rule uses to license new edges. Typically, this number ranges from zero to two. |
nltk.parse.chart.ChartRuleI.applynltk.ccg.chart.BackwardTypeRaiseRule, nltk.ccg.chart.BinaryCombinatorRule, nltk.ccg.chart.ForwardTypeRaiseRule, nltk.parse.chart.BottomUpPredictRule, nltk.parse.chart.EmptyPredictRule, nltk.parse.chart.FundamentalRule, nltk.parse.chart.LeafInitRule, nltk.parse.chart.TopDownInitRule, nltk.parse.chart.TopDownPredictRule, nltk.parse.pchart.ProbabilisticBottomUpInitRule, nltk.parse.pchart.ProbabilisticBottomUpPredictRule, nltk.parse.pchart.ProbabilisticFundamentalRule, nltk.parse.pchart.SingleEdgeProbabilisticFundamentalRuleReturn 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 | |
| chart | Undocumented |
| grammar | Undocumented |
| *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 |