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

type CachedTopDownPredictRule

source code

   object --+            
            |            
   ChartRuleI --+        
                |        
AbstractChartRule --+    
                    |    
   TopDownPredictRule --+
                        |
                       CachedTopDownPredictRule
Known Subclasses:

A cached version of TopDownPredictRule. After the first time this rule is applied to an edge with a given end and next, it will not generate any more edges for edges with that end and next.

If chart or grammar are changed, then the cache is flushed.

Instance Methods [hide private]
 
__init__(self) source code
iter of EdgeI
apply_iter(self, chart, grammar, edge)
Returns: A generator that will add edges licensed by this rule and the given edges to the chart, one at a time.
source code

Inherited from AbstractChartRule: __str__, apply, apply_everywhere, apply_everywhere_iter

Class Variables [hide private]

Inherited from TopDownPredictRule: NUM_EDGES

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

apply_iter(self, chart, grammar, edge)

source code 
Parameters:
  • edges - 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.
Overrides: ChartRuleI.apply_iter
(inherited documentation)