Package parser_course :: Package small_parsers :: Module very_simple_cky_parser :: Class CKYParser
[hide private]
[frames] | no frames]

Class CKYParser

source code

small_parser.SmallParser --+
                           |
                          CKYParser

Parse strings in self.data using CKY algorithm (see SmallParser methods too):

To create CKYParser instance p1 with grammar g1: p1 = CKYParser(g1) To find edge(mother_cat,start,end) (after parsing!):

           p1.find_parse_edge(end, start,mother_cat)

To pretty print all parse trees after parsing:

           p1.print_nltk_parses()

To draw all parse trees after parsing (in fancy graphix window):

           p1.draw_nltk_parses()

To draw all parses for edge(mother_cat,start,end) (after parsing!):

       p1.draw_nltk_parse_trees_for_edge (self,end,start,mother_cat)
Instance Methods [hide private]
 
initialize_chart(self) source code
 
process(self)
Abstract method.
source code
 
add_to_chart(self, end, start, mother_cat, dtrs) source code
 
add_lexical_edge(self, cat, j) source code
 
update_dtr_records(self, len, start, cat, dtrs) source code
 
find_parse_edge(self, end, start, mother_cat)
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, edge_info)
Return True if edge matching edge_info triple exists in chart.
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, end, start, mother_cat) source code
 
_trace_print_binary_rule_(self, mother_cat, dtr_pair) source code
 
_trace_print_unary_rule_(self, mother_cat, dtr) source code
 
_trace_print_end_(self, end) source code
 
_trace_print_start_(self, start, end) source code
 
word_span(self, end, start) 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)

find_parse_edge(self, end, start, mother_cat)

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, edge_info)

source code 

Return True if edge matching edge_info triple exists in chart. Else return Fale.

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)