Package parser_course :: Package small_parsers :: Module simple_earley_parser :: Class chart_edge_info
[hide private]
[frames] | no frames]

Class chart_edge_info

source code

Basic chart edge data structure.
mother_cat:  the catgeory (being) built
 first_cat:  the next category needed
             equal to '*completed*' for completed edges
 rest_cats:  the list of additional categories needed to
             build a mother_cat
     start: the starting index of the edge
Note that there is no end attribute because edges are indexed
by their ends, hence always retrieved in sets ending at the same
index.
To create edge e1 ending (anywhere) starting at start, building
     mother cat mather_cat with first needed cat first_cat and
     additional needed cats rest_cats:
     e1 = chart_edge_info(first_cat,rest_cats,mother_cat,start)
To display e1: e1.display()
To test if e1 is incomplete: e1.incomplete()
To test if e2 and e1 are equivalent: e1 == e2
                                   : e1.__eq__(e2)
To test if an edge equivalent to e1 occurs in  list L:
                                     e1 in L
To find the index of an edge equivalent to e1 in  list L:
                                     L.index(e1)
        Note: Raises ValueError if L contains no such edge.

Instance Methods [hide private]
 
__init__(self, first_cat, rest_cats, mother_cat, start) source code
 
display(self) source code
 
incomplete(self) source code
 
__eq__(self, other) source code
 
__hash__(self)
Playing with fire.
source code
Method Details [hide private]

__hash__(self)
(Hashing function)

source code 
Playing with fire.  __hash__ must be defined for
any object instances for which __eq__ is defined, if
these object instances are to be used as dictionary keys.
chart_edge_info instances are of course used as keys by dtr_dict.
Restriction: Only one edge per edge equivalence class is ever thus used,
 which restriction is enforced by add_edge, so edge number
is a safe key.  I think.       Alternative key:
(self.mother_cat,self.first_cat,str(self.start))+tuple(self.rest_cats)