nltk.grammar.Production¶
- class nltk.grammar.Production[source]¶
Bases:
objectA 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 andNonterminals.) “terminals” can be any immutable hashable object that is not aNonterminal. Typically, terminals are strings representing words, such as"dog"or"under".- See
CFG- See
DependencyGrammar- See
Nonterminal- Variables
_lhs – The left-hand side of the production.
_rhs – The right-hand side of the production.
- __init__(lhs, rhs)[source]¶
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.
- rhs()[source]¶
Return the right-hand side of this
Production.- Return type
sequence(Nonterminal and terminal)