Package nltk_lite :: Package contrib :: Package mit :: Package six863 :: Package semantics :: Module cfg :: Class Grammar
[hide private]
[frames] | no frames]

Class Grammar

source code

object --+
         |
        Grammar

A context-free grammar. A Grammar consists of a start state and a set of productions. The set of terminals and nonterminals is implicitly specified by the productions.

If you need efficient key-based access to productions, you can use a subclass to implement it.

Instance Methods [hide private]
 
__init__(self, start, productions)
Create a new context-free grammar, from the given start state and set of Productions.
source code
 
start(self) source code
 
productions(self, lhs=None, rhs=None) source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, start, productions)
(Constructor)

source code 

Create a new context-free grammar, from the given start state and set of Productions.

Parameters:
  • start (Nonterminal) - The start symbol
  • productions (list of Production) - The list of productions that defines the grammar
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)