nltk.PCFG.__init__

PCFG.__init__(start, productions, calculate_leftcorners=True)[source]

Create a new context-free grammar, from the given start state and set of ProbabilisticProductions.

Parameters:
  • start (Nonterminal) – The start symbol
  • productions (list(Production)) – The list of productions that defines the grammar
  • calculate_leftcorners (bool) – False if we don’t want to calculate the leftcorner relation. In that case, some optimized chart parsers won’t work.
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.