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

Class EarleyParser

source code

small_parser.SmallParser --+
                           |
                          EarleyParser


Recognize strings in self.data using Earley's algorithm.

 To create EarleyParser instance p1 with grammar g1: p1 = EarleyParser(g1)
 To find edge(first_cat,rest_cats,mother_cat,start,end) (after parsing!):
            p1.find_parse_edge(first_cat,rest_cats,mother_cat,start,end)
 To draw all parse trees fore edge (after parsing!):
      p1.draw_nltk_parse_trees_for_edge(first_cat,rest_cats,mother_cat,start,end)
 

Instance Methods [hide private]
 
initialize_chart(self) source code
 
process(self)
Abstract method.
source code
 
predictor(self, goal_cat, index) source code
 
scanner(self, edge, goal_cat, index) source code
 
completer(self, edge, index) source code
 
add_to_chart(self, start, end, first_cat, rest_cats, mother_cat, rule) source code
 
update_dtr_records(self, incomplete_edge, complete_edge, edge_of_record)
Store a list of lists of dtr edges (a list of ldes), one lde for each local parse tree that edge_of_record spans.
source code
 
find_parse_edge(self, first_cat, rest_cats, mother_cat, start, end)
Retrieve unique edge matching description from chart.
source code
 
find_spanning_edge(self)
Abstract method: Shd be defined to return a spanning edge from which dtr edges can be recursively retrieved from self.dtr_dict
source code
 
matching_edge(self, index, edge_info)
Return edge_info structure matching edge_info if there is one.
source code
 
display_chart(self)
Abstract method: Shd be defined with parser-specific print methods to print each edge in the chart.
source code
 
display_dtr_dict(self) source code
 
draw_nltk_parse_trees_for_edge(self, first_cat, rest_cats, mother_cat, start, end) source code
 
add_to_chart_trace(self, rule, mother_cat, start, end, first_cat, rest_cats)
Scanner edges always end at the index AFTER the one currently being processed, so store them in self.trace_messages[end] and print them out first thing when you get there.
source code

Inherited from small_parser.SmallParser: __init__, draw_list_parses, draw_nltk_parses, find_list_parses, find_nltk_parses, find_parses, get_list_parse_trees, get_nltk_parse_trees, parse_exists, parse_input, print_nltk_parses, reset_input, tex_output_parses, tokenize

Method Details [hide private]

initialize_chart(self)

source code 
Overrides: small_parser.SmallParser.initialize_chart

process(self)

source code 

Abstract method. Implements a particular a particular chart parsing algorithm.

Overrides: small_parser.SmallParser.process
(inherited documentation)

update_dtr_records(self, incomplete_edge, complete_edge, edge_of_record)

source code 

Store a list of lists of dtr edges (a list of ldes), one lde for each local parse tree that edge_of_record spans. Edge_of_record is the new edge to be added to the chart. incomplete_edge is a parameter because it is needed to retrieve the daughter lists found thus far in building this partial constituent. complete_edge is the new daughter to be distributed across them.

find_parse_edge(self, first_cat, rest_cats, mother_cat, start, end)

source code 

Retrieve unique edge matching description from chart. Complete edge descriptions only.

find_spanning_edge(self)

source code 

Abstract method: Shd be defined to return a spanning edge from which dtr edges can be recursively retrieved from self.dtr_dict

Overrides: small_parser.SmallParser.find_spanning_edge
(inherited documentation)

matching_edge(self, index, edge_info)

source code 

Return edge_info structure matching edge_info if there is one. Else return False

display_chart(self)

source code 

Abstract method: Shd be defined with parser-specific print methods to print each edge in the chart.

Overrides: small_parser.SmallParser.display_chart
(inherited documentation)