nltk.parse.FeatureBottomUpLeftCornerChartParser

class nltk.parse.FeatureBottomUpLeftCornerChartParser[source]

Bases: FeatureChartParser

__init__(grammar, **parser_args)[source]

Create 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_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.

  • use_agenda (bool) – Use an optimized agenda-based algorithm, if possible.

  • chart_class – The class that should be used to create the parse charts.

chart_parse(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

Return type

Chart

grammar()[source]
Returns

The grammar used by this parser.

parse(tokens, tree_class=<class 'nltk.tree.tree.Tree'>)[source]
Returns

An iterator that generates parse trees for the sentence. When possible this list is sorted from most likely to least likely.

Parameters

sent (list(str)) – The sentence to be parsed

Return type

iter(Tree)

parse_all(sent, *args, **kwargs)[source]
Return type

list(Tree)

parse_one(sent, *args, **kwargs)[source]
Return type

Tree or None

parse_sents(sents, *args, **kwargs)[source]

Apply self.parse() to each element of sents. :rtype: iter(iter(Tree))