class documentation

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

  • A span, indicating what part of the sentence is consistent with the hypothesized tree.
  • A left-hand side, specifying the hypothesized tree's node value.
  • A right-hand side, specifying the hypothesized tree's children. Each element of the right-hand side is either a terminal, specifying a token with that terminal as its leaf value; or a nonterminal, specifying a subtree with that nonterminal's symbol as its node value.
  • A dot position, indicating which children are consistent with part of the sentence. In particular, if dot is the dot position, rhs is the right-hand size, (start,end) is the span, and sentence is the list of tokens in the sentence, then tokens[start:end] can be spanned by the children specified by rhs[:dot].

For more information about edges, see the EdgeI interface.

Static Method from_production Return 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.
Method __init__ Construct a new TreeEdge.
Method __repr__ Undocumented
Method __str__ 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_complete Return True if this edge's structure is fully consistent with the text.
Method is_incomplete 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 move_dot_forward Return a new TreeEdge formed from this edge. The new edge's dot position is increased by 1, and its end index will be replaced by new_end.
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 _comparison_key Undocumented
Instance Variable _dot Undocumented
Instance Variable _lhs Undocumented
Instance Variable _rhs Undocumented
Instance Variable _span Undocumented

Inherited from EdgeI:

Method __eq__ Undocumented
Method __hash__ Undocumented
Method __lt__ Undocumented
Method __ne__ Undocumented
Instance Variable _hash Undocumented
@staticmethod
def from_production(production, index): (source)

Return 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.

Returns
TreeEdgeUndocumented
def __init__(self, span, lhs, rhs, dot=0): (source)

Construct a new TreeEdge.

Parameters
span:tuple(int, int)A tuple (s, e), where tokens[s:e] is the portion of the sentence that is consistent with the new edge's structure.
lhs:NonterminalThe new edge's left-hand side, specifying the hypothesized tree's node value.
rhs:list(Nonterminal and str)The new edge's right-hand side, specifying the hypothesized tree's children.
dot:intThe 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 tokens in the sentence, then okens[span[0]:span[1]] can be spanned by the children specified by rhs[:dot].
def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def dot(self): (source)

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
intUndocumented
def end(self): (source)

Return the end index of this edge's span.

Returns
intUndocumented
def is_complete(self): (source)

Return True if this edge's structure is fully consistent with the text.

Returns
boolUndocumented
def is_incomplete(self): (source)

Return True if this edge's structure is partially consistent with the text.

Returns
boolUndocumented
def length(self): (source)

Return the length of this edge's span.

Returns
intUndocumented
def lhs(self): (source)

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.
def move_dot_forward(self, new_end): (source)

Return a new TreeEdge formed from this edge. The new edge's dot position is increased by 1, and its end index will be replaced by new_end.

Parameters
new_end:intThe new end index.
Returns
TreeEdgeUndocumented
def nextsym(self): (source)

Return the element of this edge's right-hand side that immediately follows its dot.

Returns
Nonterminal or terminal or NoneUndocumented
def rhs(self): (source)

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.
def span(self): (source)

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
def start(self): (source)

Return the start index of this edge's span.

Returns
intUndocumented

Undocumented

Undocumented

Undocumented

Undocumented