Package nltk :: Package parse :: Module featurechart :: Class EarleyChartParser
[hide private]
[frames] | no frames]

Class EarleyChartParser

source code

 object --+    
          |    
api.ParserI --+
              |
             EarleyChartParser
Known Subclasses:

A chart parser implementing the Earley parsing algorithm:

EarleyChartParser uses a lexicon to decide whether a leaf has a given part of speech. This lexicon is encoded as a dictionary that maps each word to a list of parts of speech that word can have.

Instance Methods [hide private]
 
__init__(self, grammar, trace=0, chart_class=<class 'nltk.parse.chart.Chart'>)
Create a new Earley chart parser, that uses grammar to parse texts.
source code
 
grammar(self)
Returns: The grammar used by this parser.
source code
 
lexicon(self)
Returns: The lexicon used by this parser.
source code
list of Tree
nbest_parse(self, tokens, n=None, tree_class=<class 'nltk.tree.Tree'>)
Returns: A list of parse trees that represent possible structures for the given sentence.
source code
 
_starter_edge(self, start_sym)
Return a 'starter edge' that expands to the start symbol.
source code
 
_parses(self, chart, start_sym, tree_class)
Return a list of parses in the given chart.
source code
 
_check_lexicon_coverage(self, tokens) source code

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

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

    Deprecated

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

Class Variables [hide private]
  _trace_chart_width = 40
The default total width reserved for the chart in trace output.
Instance Variables [hide private]
  _predictor_class
The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
  _completer_class
The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
  _scanner_class
The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grammar, trace=0, chart_class=<class 'nltk.parse.chart.Chart'>)
(Constructor)

source code 

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

Parameters:
  • grammar (cfg.Grammar) - 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.
  • chart_class - The class that should be used to create the charts used by this parser.
Overrides: object.__init__

grammar(self)

source code 
Returns:
The grammar used by this parser.
Overrides: api.ParserI.grammar
(inherited documentation)

lexicon(self)

source code 
Returns:
The lexicon used by this parser.

nbest_parse(self, tokens, n=None, tree_class=<class 'nltk.tree.Tree'>)

source code 
Parameters:
  • sent - The sentence to be parsed
  • n - The maximum number of trees to return.
Returns: list of Tree
A list of parse trees that represent possible structures for the given sentence. When possible, this list is sorted from most likely to least likely. If n is specified, then the returned list will contain at most n parse trees.
Overrides: api.ParserI.nbest_parse
(inherited documentation)

Class Variable Details [hide private]

_trace_chart_width

The default total width reserved for the chart in trace output. The remainder of each line will be used to display edges.

Value:
40

Instance Variable Details [hide private]

_predictor_class

The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
Value:
nltk.parse.chart.PredictorRule

_completer_class

The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
Value:
nltk.parse.chart.CompleterRule

_scanner_class

The classes that are used to implement the three rules used by the Earley algorithm, Replacement rules can be specified by subclasses (such as FeatureEarleyChartParser).
Value:
nltk.parse.chart.ScannerRule