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

Class TreeEdge

source code

object --+    
         |    
     EdgeI --+
             |
            TreeEdge
Known Subclasses:

An edge that records the fact that a tree is (partially) consistent with the sentence. A tree edge consists of:

For more information about edges, see the EdgeI interface.

Instance Methods [hide private]
 
__init__(self, span, lhs, rhs, dot=0)
Construct a new TreeEdge.
source code
 
lhs(self)
Returns: This edge's left-hand side, which specifies what kind of structure is hypothesized by this edge.
source code
(int, int)
span(self)
Returns: A tuple (s,e), where subtokens[s:e] is the portion of the sentence that is consistent with this edge's structure.
source code
int
start(self)
Returns: The start index of this edge's span.
source code
int
end(self)
Returns: The end index of this edge's span.
source code
int
length(self)
Returns: The length of this edge's span.
source code
 
rhs(self)
Returns: This edge's right-hand side, which specifies the content of the structure hypothesized by this edge.
source code
int
dot(self)
Returns: This edge's dot position, which indicates how much of the hypothesized structure is consistent with the sentence.
source code
boolean
is_complete(self)
Returns: True if this edge's structure is fully consistent with the text.
source code
boolean
is_incomplete(self)
Returns: True if this edge's structure is partially consistent with the text.
source code
Nonterminal or terminal or None
next(self)
Returns: The element of this edge's right-hand side that immediately follows its dot.
source code
 
__cmp__(self, other) source code
 
__hash__(self)
hash(x)
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

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

Inherited from object: __class__

Method Details [hide private]

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

source code 

Construct a new TreeEdge.

Parameters:
  • span ((int, int)) - A tuple (s,e), where subtokens[s:e] is the portion of the sentence that is consistent with the new edge's structure.
  • lhs (Nonterminal) - The new edge's left-hand side, specifying the hypothesized tree's node value.
  • rhs (list of (Nonterminal and string)) - The new edge's right-hand side, specifying the hypothesized tree's children.
  • dot (int) - 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: EdgeI.__init__

from_production(production, index)
Static Method

 
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.

lhs(self)

source code 
Returns:
This edge's left-hand side, which specifies what kind of structure is hypothesized by this edge.
Overrides: EdgeI.lhs
(inherited documentation)

span(self)

source code 
Returns: (int, int)
A tuple (s,e), where subtokens[s:e] is the portion of the sentence that is consistent with this edge's structure.
Overrides: EdgeI.span
(inherited documentation)

start(self)

source code 
Returns: int
The start index of this edge's span.
Overrides: EdgeI.start
(inherited documentation)

end(self)

source code 
Returns: int
The end index of this edge's span.
Overrides: EdgeI.end
(inherited documentation)

length(self)

source code 
Returns: int
The length of this edge's span.
Overrides: EdgeI.length
(inherited documentation)

rhs(self)

source code 
Returns:
This edge's right-hand side, which specifies the content of the structure hypothesized by this edge.
Overrides: EdgeI.rhs
(inherited documentation)

dot(self)

source code 
Returns: int
This edge's dot position, which indicates how much of the hypothesized structure is consistent with the sentence. In particular, self.rhs[:dot] is consistent with subtoks[self.start():self.end()].
Overrides: EdgeI.dot
(inherited documentation)

is_complete(self)

source code 
Returns: boolean
True if this edge's structure is fully consistent with the text.
Overrides: EdgeI.is_complete
(inherited documentation)

is_incomplete(self)

source code 
Returns: boolean
True if this edge's structure is partially consistent with the text.
Overrides: EdgeI.is_incomplete
(inherited documentation)

next(self)

source code 
Returns: Nonterminal or terminal or None
The element of this edge's right-hand side that immediately follows its dot.
Overrides: EdgeI.next
(inherited documentation)

__cmp__(self, other)
(Comparison operator)

source code 
Overrides: EdgeI.__cmp__

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: EdgeI.__hash__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)