Package nltk :: Package parse :: Module earleychart :: Class IncrementalChartParser
[hide private]
[frames] | no frames]

type IncrementalChartParser

source code

   object --+        
            |        
  api.ParserI --+    
                |    
chart.ChartParser --+
                    |
                   IncrementalChartParser
Known Subclasses:

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

Instance Methods [hide private]
 
__init__(self, grammar, strategy=BU_LC_INCREMENTAL_STRATEGY, trace=0, trace_chart_width=50, chart_class=<class 'nltk.parse.earleychart.IncrementalChart'>)
Create a new Earley chart parser, that uses grammar to parse texts.
source code
Chart
chart_parse(self, tokens, trace=None)
Returns: The final parse Chart, from which all possible parse trees can be extracted.
source code

Inherited from chart.ChartParser: grammar, nbest_parse

Inherited from chart.ChartParser (private): _trace_new_edges

Inherited from api.ParserI: batch_iter_parse, batch_nbest_parse, batch_parse, batch_prob_parse, iter_parse, parse, prob_parse

    Deprecated

Inherited from api.ParserI: batch_test, get_parse, get_parse_dict, get_parse_list, get_parse_prob

Method Details [hide private]

__init__(self, grammar, strategy=BU_LC_INCREMENTAL_STRATEGY, trace=0, trace_chart_width=50, chart_class=<class 'nltk.parse.earleychart.IncrementalChart'>)
(Constructor)

source code 

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

Parameters:
  • grammar (ContextFreeGrammar) - The grammar used to parse texts.
  • trace (int) - The 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 (int) - The default total width reserved for the chart in trace output. The remainder of each line will be used to display edges.
  • chart_class - The class that should be used to create the charts used by this parser.
Overrides: chart.ChartParser.__init__

chart_parse(self, tokens, trace=None)

source code 
Parameters:
  • tokens - The sentence to be parsed
Returns: Chart
The final parse Chart, from which all possible parse trees can be extracted.
Overrides: chart.ChartParser.chart_parse
(inherited documentation)