Package nltk :: Package parse :: Module util :: Class TestGrammar
[hide private]
[frames] | no frames]

Class TestGrammar

source code

object --+
         |
        TestGrammar

Unit tests for CFG.

Instance Methods [hide private]
 
__init__(self, grammar, suite, accept=None, reject=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
run(self, show_trees=False)
Sentences in the test suite are divided into two classes:
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grammar, suite, accept=None, reject=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

run(self, show_trees=False)

source code 

Sentences in the test suite are divided into two classes:

  • grammatical (accept) and
  • ungrammatical (reject).

If a sentence should parse accordng to the grammar, the value of trees will be a non-empty list. If a sentence should be rejected according to the grammar, then the value of trees will be None.