class Nonterminal(object): (source)
Known subclasses: nltk.grammar.FeatStructNonterminal
Constructor: Nonterminal(symbol)
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. |
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:Nonterminal | The nonterminal used to form the right hand side of the new nonterminal. |
Returns | |
Nonterminal | Undocumented |
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 | |
bool | Undocumented |
Construct a new non-terminal from the given symbol.
Parameters | |
symbol:any | The node value corresponding to this Nonterminal. This value must be immutable and hashable. |
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:Nonterminal | The nonterminal used to form the right hand side of the new nonterminal. |
Returns | |
Nonterminal | Undocumented |
nltk.grammar.FeatStructNonterminal
Return the node value corresponding to this Nonterminal.
Returns | |
(any) | Undocumented |