class documentation

class Nonterminal(object): (source)

Known subclasses: nltk.grammar.FeatStructNonterminal

Constructor: Nonterminal(symbol)

View In Hierarchy

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 Also
CFG, Production
Method __div__ Return a new nonterminal whose symbol is A/B, where A is the symbol for this nonterminal, and B is the symbol for rhs.
Method __eq__ Return True if this non-terminal is equal to other. In particular, return True if other is a Nonterminal and this non-terminal's symbol is equal to other 's symbol.
Method __hash__ Undocumented
Method __init__ Construct a new non-terminal from the given symbol.
Method __lt__ Undocumented
Method __ne__ Undocumented
Method __repr__ Return a string representation for this Nonterminal.
Method __str__ Return a string representation for this Nonterminal.
Method __truediv__ Return a new nonterminal whose symbol is A/B, where A is the symbol for this nonterminal, and B is the symbol for rhs. This function allows use of the slash / operator with the future import of division.
Method symbol Return the node value corresponding to this Nonterminal.
Instance Variable _symbol The node value corresponding to this Nonterminal. This value must be immutable and hashable.
def __div__(self, rhs): (source)

Return a new nonterminal whose symbol is A/B, where A is the symbol for this nonterminal, and B is the symbol for rhs.

Parameters
rhs:NonterminalThe nonterminal used to form the right hand side of the new nonterminal.
Returns
NonterminalUndocumented
def __eq__(self, other): (source)

Return True if this non-terminal is equal to other. In particular, return True if other is a Nonterminal and this non-terminal's symbol is equal to other 's symbol.

Returns
boolUndocumented
def __hash__(self): (source)

Undocumented

def __init__(self, symbol): (source)

Construct a new non-terminal from the given symbol.

Parameters
symbol:anyThe node value corresponding to this Nonterminal. This value must be immutable and hashable.
def __lt__(self, other): (source)

Undocumented

def __ne__(self, other): (source)

Undocumented

def __repr__(self): (source)

Return a string representation for this Nonterminal.

Returns
strUndocumented
def __str__(self): (source)

Return a string representation for this Nonterminal.

Returns
strUndocumented
def __truediv__(self, rhs): (source)

Return a new nonterminal whose symbol is A/B, where A is the symbol for this nonterminal, and B is the symbol for rhs. This function allows use of the slash / operator with the future import of division.

Parameters
rhs:NonterminalThe nonterminal used to form the right hand side of the new nonterminal.
Returns
NonterminalUndocumented
def symbol(self): (source)

Return the node value corresponding to this Nonterminal.

Returns
(any)Undocumented
_symbol: any = (source)

The node value corresponding to this Nonterminal. This value must be immutable and hashable.