nltk.parse.ChartParser
¶
-
class
nltk.parse.
ChartParser
(grammar, strategy=[<nltk.parse.chart.LeafInitRule object at 0x2b21a94e1250>, <nltk.parse.chart.EmptyPredictRule object at 0x2b21a94e1290>, <nltk.parse.chart.BottomUpPredictCombineRule object at 0x2b21a94e12d0>, <nltk.parse.chart.SingleEdgeFundamentalRule object at 0x2b21a94e1310>], trace=0, trace_chart_width=50, use_agenda=True, chart_class=<class 'nltk.parse.chart.Chart'>)[source]¶ 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:Until no new edges are added:For each rule in strategy:Apply rule to any applicable edges in the chart.Return any complete parses in the chart
Methods¶
__init__ (grammar[, strategy, trace, ...]) |
Create a new chart parser, that uses grammar to parse texts. |
||
chart_parse (tokens[, trace]) |
Return the final parse Chart from which all possible parse trees can be extracted. |
||
grammar () |
|||
parse (tokens[, tree_class]) |
|||
parse_all (sent, *args, **kwargs) |
|
||
parse_one (sent, *args, **kwargs) |
|
||
parse_sents (sents, *args, **kwargs) |
Apply self.parse() to each element of sents . |