class documentation
class Production(object): (source)
Known subclasses: nltk.grammar.DependencyProduction
, nltk.grammar.ProbabilisticProduction
Constructor: Production(lhs, rhs)
A grammar production. Each production maps a single symbol on the "left-hand side" to a sequence of symbols on the "right-hand side". (In the case of context-free productions, the left-hand side must be a Nonterminal, and the right-hand side is a sequence of terminals and Nonterminals.) "terminals" can be any immutable hashable object that is not a Nonterminal. Typically, terminals are strings representing words, such as "dog" or "under".
See Also | |
CFG | |
DependencyGrammar | |
Nonterminal |
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 Production. |
Method | __len__ |
Return the length of the right-hand side. |
Method | __lt__ |
Undocumented |
Method | __ne__ |
Undocumented |
Method | __repr__ |
Return a concise string representation of the Production. |
Method | __str__ |
Return a verbose 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. |
overridden in
nltk.grammar.ProbabilisticProduction
Return True if this Production is equal to other.
Returns | |
bool | Undocumented |
overridden in
nltk.grammar.ProbabilisticProduction
Return a hash value for the Production.
Returns | |
int | Undocumented |
overridden in
nltk.grammar.ProbabilisticProduction
Construct a new Production.
Parameters | |
lhs:Nonterminal | The left-hand side of the new Production. |
rhs:sequence(Nonterminal and terminal) | The right-hand side of the new Production. |