nltk.grammar.Nonterminal¶
- class nltk.grammar.Nonterminal[source]¶
Bases:
object
A non-terminal symbol for a context free grammar.
Nonterminal
is a wrapper class for node values; it is used byProduction
objects to distinguish node values from leaf values. The node value that is wrapped by aNonterminal
is 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. TwoNonterminals
are 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.