Package nltk_lite :: Package parse :: Module cfg :: Class Production
[show private | hide private]
[frames | no frames]

Type Production

object --+
         |
        Production

Known Subclasses:
Production

A context-free grammar production. Each production expands a single Nonterminal (the left-hand side) to a sequence of terminals and Nonterminals (the right-hand side). terminals can be any immutable hashable object that is not a Nonterminal. Typically, terminals are strings representing word types, such as "dog" or "under".

Abstractly, a Grammar production indicates that the right-hand side is a possible instantiation of the left-hand side. Grammar productions are context-free, in the sense that this instantiation should not depend on the context of the left-hand side or of the right-hand side.
See Also:
Grammar, Nonterminal
Method Summary
  __init__(self, lhs, rhs)
Construct a new Production.
  __cmp__(self, other)
boolean __eq__(self, other)
Return true if this Production is equal to other.
int __hash__(self)
Return a hash value for the Production.
  __ne__(self, other)
string __repr__(self)
Return a concise string representation of the Production.
string __str__(self)
Return a verbose string representation of the Production.
Nonterminal lhs(self)
Return the left-hand side of this Production.
sequence of (Nonterminal and (terminal)) rhs(self)
Return the right-hand side of this Production.
Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Method Details

__init__(self, lhs, rhs)
(Constructor)

Construct a new Production.
Parameters:
lhs - The left-hand side of the new Production.
           (type=Nonterminal)
rhs - The right-hand side of the new Production.
           (type=sequence of (Nonterminal and (terminal)))
Overrides:
__builtin__.object.__init__

__eq__(self, other)
(Equality operator)

Returns:
true if this Production is equal to other.
           (type=boolean)

__hash__(self)
(Hashing function)

Returns:
A hash value for the Production.
           (type=int)
Overrides:
__builtin__.object.__hash__

__repr__(self)
(Representation operator)

Returns:
A concise string representation of the Production.
           (type=string)
Overrides:
__builtin__.object.__repr__

__str__(self)
(Informal representation operator)

Returns:
A verbose string representation of the Production.
           (type=string)
Overrides:
__builtin__.object.__str__

lhs(self)

Returns:
the left-hand side of this Production.
           (type=Nonterminal)

rhs(self)

Returns:
the right-hand side of this Production.
           (type=sequence of (Nonterminal and (terminal)))

Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 http://epydoc.sf.net