class ChartParser(ParserI): (source)
Known subclasses: nltk.parse.chart.BottomUpChartParser, nltk.parse.chart.BottomUpLeftCornerChartParser, nltk.parse.chart.LeftCornerChartParser, nltk.parse.chart.SteppingChartParser, nltk.parse.chart.TopDownChartParser, nltk.parse.earleychart.IncrementalChartParser, nltk.parse.featurechart.FeatureChartParser
Constructor: ChartParser(grammar, strategy, trace, trace_chart_width, ...)
A generic chart parser. A "strategy", or list of ChartRuleI instances, is used to decide what edges to add to the chart. In particular, ChartParser uses the following algorithm to parse texts:
| Method | __init__ |
Create a new chart parser, that uses grammar to parse texts. |
| Method | chart |
Return the final parse Chart from which all possible parse trees can be extracted. |
| Method | grammar |
No summary |
| Method | parse |
When possible this list is sorted from most likely to least likely. |
| Method | _trace |
Undocumented |
| Instance Variable | _axioms |
Undocumented |
| Instance Variable | _chart |
Undocumented |
| Instance Variable | _grammar |
Undocumented |
| Instance Variable | _inference |
Undocumented |
| Instance Variable | _strategy |
Undocumented |
| Instance Variable | _trace |
Undocumented |
| Instance Variable | _trace |
Undocumented |
| Instance Variable | _use |
Undocumented |
Inherited from ParserI:
| Method | parse |
No summary |
| Method | parse |
No summary |
| Method | parse |
Apply self.parse() to each element of sents. :rtype: iter(iter(Tree)) |
nltk.parse.chart.BottomUpChartParser, nltk.parse.chart.BottomUpLeftCornerChartParser, nltk.parse.chart.LeftCornerChartParser, nltk.parse.chart.SteppingChartParser, nltk.parse.chart.TopDownChartParser, nltk.parse.earleychart.IncrementalChartParser, nltk.parse.featurechart.FeatureChartParserCreate a new chart parser, that uses grammar to parse texts.
| Parameters | |
| grammar:CFG | The grammar used to parse texts. |
| strategy:list(ChartRuleI) | A list of rules that should be used to decide what edges to add to the chart (top-down strategy by default). |
| 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 | The default total width reserved for the chart in trace output. The remainder of each line will be used to display edges. |
| use | Use an optimized agenda-based algorithm, if possible. |
| chart | The class that should be used to create the parse charts. |
nltk.parse.earleychart.IncrementalChartParserReturn the final parse Chart from which all possible parse trees can be extracted.
| Parameters | |
| tokens:list(str) | The sentence to be parsed |
| trace | Undocumented |
| Returns | |
| Chart | Undocumented |
nltk.parse.api.ParserI.grammarnltk.parse.chart.SteppingChartParser| Returns | |
| The grammar used by this parser. |
nltk.parse.api.ParserI.parsenltk.parse.chart.SteppingChartParserWhen possible this list is sorted from most likely to least likely.
| Parameters | |
| tokens | Undocumented |
| tree | Undocumented |
| sent:list(str) | The sentence to be parsed |
| Returns | |
| iter(Tree) | An iterator that generates parse trees for the sentence. |