class documentation

An incremental chart parser implementing Jay Earley's parsing algorithm:

For each index end in [0, 1, ..., N]:
For each edge such that edge.end = end:
If edge is incomplete and edge.next is not a part of speech:
Apply PredictorRule to edge
If edge is incomplete and edge.next is a part of speech:
Apply ScannerRule to edge
If edge is complete:
Apply CompleterRule to edge
Return any complete parses in the chart
Method __init__ Create a new Earley chart parser, that uses grammar to parse texts.
Method chart_parse Return the final parse Chart from which all possible parse trees can be extracted.
Instance Variable _axioms Undocumented
Instance Variable _chart_class Undocumented
Instance Variable _grammar Undocumented
Instance Variable _inference_rules Undocumented
Instance Variable _trace Undocumented
Instance Variable _trace_chart_width Undocumented

Inherited from ChartParser:

Method grammar No summary
Method parse When possible this list is sorted from most likely to least likely.
Method _trace_new_edges Undocumented
Instance Variable _strategy Undocumented
Instance Variable _use_agenda Undocumented

Inherited from ParserI (via ChartParser):

Method parse_all No summary
Method parse_one No summary
Method parse_sents Apply self.parse() to each element of sents. :rtype: iter(iter(Tree))
def __init__(self, grammar, strategy=BU_LC_INCREMENTAL_STRATEGY, trace=0, trace_chart_width=50, chart_class=IncrementalChart): (source)

Create a new Earley chart parser, that uses grammar to parse texts.

Parameters
grammar:CFGThe grammar used to parse texts.
strategyUndocumented
trace:intThe level of tracing that should be used when parsing a text. 0 will generate no tracing output; and higher numbers will produce more verbose tracing output.
trace_chart_width:intThe default total width reserved for the chart in trace output. The remainder of each line will be used to display edges.
chart_classThe class that should be used to create the charts used by this parser.
def chart_parse(self, tokens, trace=None): (source)

Return the final parse Chart from which all possible parse trees can be extracted.

Parameters
tokens:list(str)The sentence to be parsed
traceUndocumented
Returns
ChartUndocumented
_axioms: list = (source)

Undocumented

_inference_rules: list = (source)
_trace_chart_width = (source)