nltk.parse.SteppingChartParser

class nltk.parse.SteppingChartParser(grammar, strategy=[], trace=0)[source]

A ChartParser that allows you to step through the parsing process, adding a single edge at a time. It also allows you to change the parser’s strategy or grammar midway through parsing a text.

The initialize method is used to start parsing a text. step adds a single edge to the chart. set_strategy changes the strategy used by the chart parser. parses returns the set of parses that has been found by the chart parser.

Variables:_restart – Records whether the parser’s strategy, grammar, or chart has been changed. If so, then step must restart the parsing algorithm.

Methods

__init__(grammar[, strategy, trace])
chart() Return the chart that is used by this parser.
chart_parse(tokens[, trace]) Return the final parse Chart from which all possible parse trees can be extracted.
current_chartrule() Return the chart rule used to generate the most recent edge.
grammar() Return the grammar used by this parser.
initialize(tokens) Begin parsing the given tokens.
parse(tokens[, tree_class])
parse_all(sent, *args, **kwargs)
rtype:list(Tree)
parse_one(sent, *args, **kwargs)
rtype:Tree or None
parse_sents(sents, *args, **kwargs) Apply self.parse() to each element of sents.
parses([tree_class]) Return the parse trees currently contained in the chart.
set_chart(chart) Load a given chart into the chart parser.
set_grammar(grammar) Change the grammar used by the parser.
set_strategy(strategy) Change the strategy that the parser uses to decide which edges to add to the chart.
step() Return a generator that adds edges to the chart, one at a time.
strategy() Return the strategy used by this parser.