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

type FeatureTreeEdge

source code

 object --+        
          |        
chart.EdgeI --+    
              |    
 chart.TreeEdge --+
                  |
                 FeatureTreeEdge

A specialized tree edge that allows shared variable bindings between nonterminals on the left-hand side and right-hand side.

Each FeatureTreeEdge contains a set of bindings, i.e., a dictionary mapping from variables to values. If the edge is not complete, then these bindings are simply stored. However, if the edge is complete, then the constructor applies these bindings to every nonterminal in the edge whose symbol implements the interface SubstituteBindingsI.

Instance Methods [hide private]
 
__init__(self, span, lhs, rhs, dot=0, bindings=None)
Construct a new edge.
source code
FeatureTreeEdge
move_dot_forward(self, new_end, bindings=None)
Returns: A new FeatureTreeEdge formed from this edge.
source code
 
_bind(self, nt, bindings) source code
 
next_with_bindings(self) source code
 
bindings(self)
Return a copy of this edge's bindings dictionary.
source code
set of Variable
variables(self)
Returns: The set of variables used by this edge.
source code
 
__str__(self) source code
 
__cmp__(self, other) source code
 
__hash__(self) source code

Inherited from chart.TreeEdge: __repr__, dot, end, is_complete, is_incomplete, length, lhs, next, rhs, span, start

Static Methods [hide private]
TreeEdge
from_production(production, index)
Returns: A new TreeEdge formed from the given production.
source code
Method Details [hide private]

__init__(self, span, lhs, rhs, dot=0, bindings=None)
(Constructor)

source code 

Construct a new edge. If the edge is incomplete (i.e., if dot<len(rhs)), then store the bindings as-is. If the edge is complete (i.e., if dot==len(rhs)), then apply the bindings to all nonterminals in lhs and rhs, and then clear the bindings. See TreeEdge for a description of the other arguments.

Parameters:
  • span - A tuple (s,e), where subtokens[s:e] is the portion of the sentence that is consistent with the new edge's structure.
  • lhs - The new edge's left-hand side, specifying the hypothesized tree's node value.
  • rhs - The new edge's right-hand side, specifying the hypothesized tree's children.
  • dot - The position of the new edge's dot. This position specifies what prefix of the production's right hand side is consistent with the text. In particular, if sentence is the list of subtokens in the sentence, then subtokens[span[0]:span[1]] can be spanned by the children specified by rhs[:dot].
Overrides: chart.EdgeI.__init__

from_production(production, index)
Static Method

source code 
Returns: TreeEdge
A new TreeEdge formed from the given production. The new edge's left-hand side and right-hand side will be taken from production; its span will be (index,index); and its dot position will be 0.
Overrides: chart.TreeEdge.from_production

move_dot_forward(self, new_end, bindings=None)

source code 
Parameters:
  • new_end (int) - The new end index.
  • bindings (dict) - Bindings for the new edge.
Returns: FeatureTreeEdge
A new FeatureTreeEdge formed from this edge. The new edge's dot position is increased by 1, and its end index will be replaced by new_end.
Overrides: chart.TreeEdge.move_dot_forward

variables(self)

source code 
Returns: set of Variable
The set of variables used by this edge.

__str__(self)
(Informal representation operator)

source code 
Overrides: chart.TreeEdge.__str__

__cmp__(self, other)
(Comparison operator)

source code 
Overrides: chart.EdgeI.__cmp__

__hash__(self)
(Hashing function)

source code 
Overrides: chart.EdgeI.__hash__