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

type EdgeI

source code

object --+
         |
        EdgeI
Known Subclasses:

A hypothesis about the structure of part of a sentence. Each edge records the fact that a structure is (partially) consistent with the sentence. An edge contains:

Every edge is either complete or incomplete:

There are two kinds of edge:

The EdgeI interface provides a common interface to both types of edge, allowing chart parsers to treat them in a uniform manner.

Instance Methods [hide private]
 
__init__(self) 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
 
lhs(self)
Returns: This edge's left-hand side, which specifies what kind of structure is hypothesized by this edge.
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
Nonterminal or terminal or None
next(self)
Returns: The element of this edge's right-hand side that immediately follows its dot.
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
 
__cmp__(self, other) source code
 
__hash__(self, other) source code
Method Details [hide private]

__init__(self)
(Constructor)

source code 
Overrides: object.__init__
(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.

start(self)

source code 
Returns: int
The start index of this edge's span.

end(self)

source code 
Returns: int
The end index of this edge's span.

length(self)

source code 
Returns: int
The length of this edge's span.

lhs(self)

source code 
Returns:
This edge's left-hand side, which specifies what kind of structure is hypothesized by this edge.

See Also: TreeEdge and LeafEdge for a description of the left-hand side values for each edge type.

rhs(self)

source code 
Returns:
This edge's right-hand side, which specifies the content of the structure hypothesized by this edge.

See Also: TreeEdge and LeafEdge for a description of the right-hand side values for each edge type.

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()].

next(self)

source code 
Returns: Nonterminal or terminal or None
The element of this edge's right-hand side that immediately follows its dot.

is_complete(self)

source code 
Returns: boolean
True if this edge's structure is fully consistent with the text.

is_incomplete(self)

source code 
Returns: boolean
True if this edge's structure is partially consistent with the text.

__hash__(self, other)
(Hashing function)

source code 
Overrides: object.__hash__
(inherited documentation)