class ProbabilisticProduction(Production, ImmutableProbabilisticMixIn): (source)
Constructor: ProbabilisticProduction(lhs, rhs, **prob)
A probabilistic context free grammar production. A PCFG ProbabilisticProduction is essentially just a Production that has an associated probability, which represents how likely it is that this production will be used. In particular, the probability of a ProbabilisticProduction records the likelihood that its right-hand side is the correct instantiation for any given occurrence of its left-hand side.
See Also | |
Production |
Method | __eq__ |
Return True if this Production is equal to other. |
Method | __hash__ |
Return a hash value for the Production. |
Method | __init__ |
Construct a new ProbabilisticProduction. |
Method | __ne__ |
Undocumented |
Method | __str__ |
Return a verbose string representation of the Production. |
Inherited from Production
:
Method | __len__ |
Return the length of the right-hand side. |
Method | __lt__ |
Undocumented |
Method | __repr__ |
Return a concise string representation of the Production. |
Method | is |
Return True if the right-hand contain at least one terminal token. |
Method | is |
Return True if the right-hand side only contains Nonterminals |
Method | lhs |
Return the left-hand side of this Production. |
Method | rhs |
Return the right-hand side of this Production. |
Instance Variable | _lhs |
The left-hand side of the production. |
Instance Variable | _rhs |
The right-hand side of the production. |
Inherited from ImmutableProbabilisticMixIn
(via Production
):
Method | set |
Set the log probability associated with this object to logprob. I.e., set the probability associated with this object to 2**(logprob). |
Method | set |
Set the probability associated with this object to prob. |
Inherited from ProbabilisticMixIn
(via Production
, ImmutableProbabilisticMixIn
):
Method | logprob |
Return log(p), where p is the probability associated with this object. |
Method | prob |
Return the probability associated with this object. |
Instance Variable | __logprob |
Undocumented |
Instance Variable | __prob |
Undocumented |
nltk.grammar.Production.__eq__
Return True if this Production is equal to other.
Returns | |
bool | Undocumented |
nltk.grammar.Production.__hash__
Return a hash value for the Production.
Returns | |
int | Undocumented |
nltk.grammar.Production.__init__
Construct a new ProbabilisticProduction.
Parameters | |
lhs:Nonterminal | The left-hand side of the new ProbabilisticProduction. |
rhs:sequence(Nonterminal and terminal) | The right-hand side of the new ProbabilisticProduction. |
**prob | Probability parameters of the new ProbabilisticProduction. |
nltk.grammar.Production.__str__
Return a verbose string representation of the Production.
Returns | |
str | Undocumented |