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 Production
s. 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.Production s. |
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. |
__init__(self,
start,
productions)
(Constructor)
Create a new context-free grammar, from the given start state and
set of cfg.Production s.
-
- 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__
|
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:
|