nltk.grammar.Nonterminal¶
- class nltk.grammar.Nonterminal[source]¶
Bases:
objectA non-terminal symbol for a context free grammar.
Nonterminalis a wrapper class for node values; it is used byProductionobjects to distinguish node values from leaf values. The node value that is wrapped by aNonterminalis known as its “symbol”. Symbols are typically strings representing phrasal categories (such as"NP"or"VP"). However, more complex symbol types are sometimes used (e.g., for lexicalized grammars). Since symbols are node values, they must be immutable and hashable. TwoNonterminalsare considered equal if their symbols are equal.- See
CFG,Production- Variables
_symbol – The node value corresponding to this
Nonterminal. This value must be immutable and hashable.