Commit dcd225fa by Steven Bird

fixed some import statements, added test code

parent daf4d0f7
......@@ -209,11 +209,11 @@ def postag(
# defaults
baseline_backoff_tagger = baseline_backoff_tagger or REGEXP_TAGGER
if templates is None:
from nltk.tag.tbl.task import postagging
from nltk.tag.brill import describe_template_sets, brill24
# some pre-built template sets taken from typical systems or publications are
# available. Print a list with postagging.describe_template_sets()
# available. Print a list with describe_template_sets()
# for instance:
templates = postagging.brill24()
templates = brill24()
(training_data, baseline_data, gold_data, testing_data) = \
_demo_prepare_data(tagged_data, train, num_sents, randomize, separate_baseline_data)
......
......@@ -60,7 +60,7 @@ class Feature(object):
>>> Pos(2, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nltk/tag/tbl/template.py", line 306, in __init__
File "nltk/tbl/template.py", line 306, in __init__
raise TypeError
ValueError: illegal interval specification: (start=2, end=1)
......@@ -258,3 +258,8 @@ class Feature(object):
:rtype: any (but usually scalar)
"""
raise NotImplementedError
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)
......@@ -307,3 +307,8 @@ class Rule(TagRule):
conditions = (' if ' if self._conditions else "") + ', and '.join(
[condition_to_str(f,v) for (f,v) in self._conditions])
return replacement + conditions
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)
......@@ -306,3 +306,6 @@ class Template(BrillTemplateI):
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment