Package nltk_lite :: Package parse :: Module pcfg :: Class Grammar
[show private | hide private]
[frames | no frames]

Type Grammar

object --+    
         |    
   Grammar --+
             |
            Grammar


A probabilistic context-free grammar. A PCFG Grammar consists of a start state and a set of productions. The set of terminals and nonterminals is implicitly specified by the productions.

PCFG productions should be Productions. PCFG Grammars impose the constraint that the set of productions with any given left-hand-side must have probabilities that sum to 1.

If you need efficient key-based access to productions, you can use a subclass to implement it.
Method Summary
  __init__(self, start, productions)
Create a new context-free grammar, from the given start state and set of cfg.Productions.
Inherited from Grammar: __repr__, __str__, productions, start
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variable Summary
float EPSILON: The acceptable margin of error for checking that productions with a given left-hand side have probabilities that sum to 1.

Method Details

__init__(self, start, productions)
(Constructor)

Create a new context-free grammar, from the given start state and set of cfg.Productions.
Parameters:
start - The start symbol
           (type=Nonterminal)
productions - The list of productions that defines the grammar
           (type=list of Production)
Raises:
ValueError - if the set of productions with any left-hand-side do not have probabilities that sum to a value within EPSILON of 1.
Overrides:
nltk_lite.parse.cfg.Grammar.__init__

Class Variable Details

EPSILON

The acceptable margin of error for checking that productions with a given left-hand side have probabilities that sum to 1.
Type:
float
Value:
0.01                                                                  

Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 http://epydoc.sf.net