Package nltk_lite :: Package contrib :: Package mit :: Package six863 :: Package semantics :: Module chart :: Class EarleyChartParse
[hide private]
[frames] | no frames]

Class EarleyChartParse

source code

        object --+        
                 |        
   __init__.ParseI --+    
                     |    
__init__.AbstractParse --+
                         |
                        EarleyChartParse

A chart parser implementing the Earley parsing algorithm:

EarleyChartParse 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, lexicon, trace=0)
Create a new Earley chart parser, that uses grammar to parse texts.
source code
list of Tree
get_parse_list(self, tokens, tree_class=<class 'nltk_lite.parse.tree.Tree'>)
Returns: A list of the parse trees for the sentence.
source code

Inherited from __init__.AbstractParse: batch_test, get_parse, grammar, parse

Inherited from __init__.ParseI: get_parse_dict, get_parse_probs

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grammar, lexicon, trace=0)
(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.
  • lexicon (dict from string to (list of string)) - A lexicon of words that records the parts of speech that each word can have. Each key is a word, and the corresponding value is a list of parts of speech.
  • 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.
Overrides: __init__.AbstractParse.__init__

get_parse_list(self, tokens, tree_class=<class 'nltk_lite.parse.tree.Tree'>)

source code 
Returns: list of Tree
A list of the parse trees for the sentence. When possible, this list should be sorted from most likely to least likely.
Overrides: __init__.AbstractParse.get_parse_list