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

type TestGrammar

source code

object --+
         |
        TestGrammar

Unit tests for CFG.

Instance Methods [hide private]
 
__init__(self, grammar, suite, accept=None, reject=None) source code
 
run(self, show_trees=False)
Sentences in the test suite are divided into two classes:
source code
Method Details [hide private]

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

source code 
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.