Package nltk :: Package parse :: Module featurechart :: Class InstantiateVarsChart
[hide private]
[frames] | no frames]

type InstantiateVarsChart

source code

 object --+        
          |        
chart.Chart --+    
              |    
   FeatureChart --+
                  |
                 InstantiateVarsChart

A specialized chart that 'instantiates' variables whose names start with '@', by replacing them with unique new variables. In particular, whenever a complete edge is added to the chart, any variables in the edge's lhs whose names start with '@' will be replaced by unique new Variables.

Instance Methods [hide private]
 
__init__(self, tokens)
Construct a new chart.
source code
 
initialize(self)
Clear the chart.
source code
 
insert(self, edge, child_pointer_list)
Add a new edge to the chart.
source code
 
instantiate_edge(self, edge)
If the edge is a FeatureTreeEdge, and it is complete, then instantiate all variables whose names start with '@', by replacing them with unique new variables.
source code
 
inst_vars(self, edge) source code

Inherited from FeatureChart: parses, select

Inherited from chart.Chart: __iter__, child_pointer_lists, dot_digraph, edges, insert_with_backpointer, iteredges, leaf, leaves, num_edges, num_leaves, pp, pp_edge, pp_leaves, trees

Inherited from chart.Chart (private): _append_edge, _choose_children, _trees

Instance Variables [hide private]
Method Details [hide private]

__init__(self, tokens)
(Constructor)

source code 

Construct a new chart. The chart is initialized with the leaf edges corresponding to the terminal leaves.

Parameters:
  • tokens - The sentence that this chart will be used to parse.
Overrides: chart.Chart.__init__
(inherited documentation)

initialize(self)

source code 

Clear the chart.

Overrides: chart.Chart.initialize
(inherited documentation)

insert(self, edge, child_pointer_list)

source code 

Add a new edge to the chart.

@type edge: L{EdgeI}
@param edge: The new edge
@type child_pointer_lists: C(sequence} of C{tuple} of L{EdgeI} 
@param child_pointer_lists: A sequence of lists of the edges that 
    were used to form this edge.  This list is used to reconstruct 
    the trees (or partial trees) that are associated with C{edge}.
@rtype: C{bool}
@return: True if this operation modified the chart.  In
    particular, return true iff the chart did not already
    contain C{edge}, or if it did not already associate
    C{child_pointer_lists} with C{edge}.

Overrides: chart.Chart.insert
(inherited documentation)

instantiate_edge(self, edge)

source code 

If the edge is a FeatureTreeEdge, and it is complete, then instantiate all variables whose names start with '@', by replacing them with unique new variables.

Note that instantiation is done in-place, since the parsing algorithms might already hold a reference to the edge for future use.