nltk.Production
¶
-
class
nltk.
Production
(lhs, rhs)[source]¶ 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 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.
Methods¶
__init__ (lhs, rhs) |
Construct a new Production . |
is_lexical () |
Return True if the right-hand contain at least one terminal token. |
is_nonlexical () |
Return True if the right-hand side only contains Nonterminals |
lhs () |
Return the left-hand side of this Production . |
rhs () |
Return the right-hand side of this Production . |
unicode_repr () |
Return a concise string representation of the Production . |