nltk.Nonterminal

class nltk.Nonterminal(symbol)[source]

A non-terminal symbol for a context free grammar. Nonterminal is a wrapper class for node values; it is used by Production objects to distinguish node values from leaf values. The node value that is wrapped by a Nonterminal 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. Two Nonterminals 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.

Methods

__init__(symbol) Construct a new non-terminal from the given symbol.
symbol() Return the node value corresponding to this Nonterminal.
unicode_repr() Return a string representation for this Nonterminal.