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

Class LeafEdge

source code

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

An edge that records the fact that a leaf value is consistent with a word in the sentence. A leaf edge consists of:

A leaf edge's left-hand side is its leaf value, and its right hand side is (). Its span is [index, index+1], and its dot position is 0.

Instance Methods [hide private]
 
__init__(self, leaf, index)
Construct a new LeafEdge.
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__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, leaf, index)
(Constructor)

source code 

Construct a new LeafEdge.

Parameters:
  • leaf - The new edge's leaf value, specifying the word that is recorded by this edge.
  • index - The new edge's index, specifying the position of the word that is recorded by this edge.
Overrides: EdgeI.__init__

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)