class EdgeI(object): (source)
Known subclasses: nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
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:
- A span, indicating what part of the sentence is consistent with the hypothesized structure.
- A left-hand side, specifying what kind of structure is hypothesized.
- A right-hand side, specifying the contents of the hypothesized structure.
- A dot position, indicating how much of the hypothesized structure is consistent with the sentence.
Every edge is either complete or incomplete:
- An edge is complete if its structure is fully consistent with the sentence.
- An edge is incomplete if its structure is partially consistent with the sentence. For every incomplete edge, the span specifies a possible prefix for the edge's structure.
There are two kinds of edge:
- A TreeEdge records which trees have been found to be (partially) consistent with the text.
- A LeafEdge records the tokens occurring in the text.
The EdgeI interface provides a common interface to both types of edge, allowing chart parsers to treat them in a uniform manner.
Method | __eq__ |
Undocumented |
Method | __hash__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __lt__ |
Undocumented |
Method | __ne__ |
Undocumented |
Method | dot |
Return 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 tokens[self.start():self.end()]... |
Method | end |
Return the end index of this edge's span. |
Method | is |
Return True if this edge's structure is fully consistent with the text. |
Method | is |
Return True if this edge's structure is partially consistent with the text. |
Method | length |
Return the length of this edge's span. |
Method | lhs |
Return this edge's left-hand side, which specifies what kind of structure is hypothesized by this edge. |
Method | nextsym |
Return the element of this edge's right-hand side that immediately follows its dot. |
Method | rhs |
Return this edge's right-hand side, which specifies the content of the structure hypothesized by this edge. |
Method | span |
Return a tuple (s, e), where tokens[s:e] is the portion of the sentence that is consistent with this edge's structure. |
Method | start |
Return the start index of this edge's span. |
Instance Variable | _hash |
Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Undocumented
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return 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 tokens[self.start():self.end()].
Returns | |
int | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return the end index of this edge's span.
Returns | |
int | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return True if this edge's structure is fully consistent with the text.
Returns | |
bool | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return True if this edge's structure is partially consistent with the text.
Returns | |
bool | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return the length of this edge's span.
Returns | |
int | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return 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. |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return the element of this edge's right-hand side that immediately follows its dot.
Returns | |
Nonterminal or terminal or None | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return 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. |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return a tuple (s, e), where tokens[s:e] is the portion of the sentence that is consistent with this edge's structure.
Returns | |
tuple(int, int) | Undocumented |
nltk.ccg.chart.CCGEdge
, nltk.ccg.chart.CCGLeafEdge
, nltk.parse.chart.LeafEdge
, nltk.parse.chart.TreeEdge
Return the start index of this edge's span.
Returns | |
int | Undocumented |