Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
dcd225fa
Commit
dcd225fa
authored
Apr 21, 2014
by
Steven Bird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some import statements, added test code
parent
daf4d0f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
4 deletions
+17
-4
nltk/tbl/demo.py
+3
-3
nltk/tbl/feature.py
+6
-1
nltk/tbl/rule.py
+5
-0
nltk/tbl/template.py
+3
-0
No files found.
nltk/tbl/demo.py
View file @
dcd225fa
...
@@ -209,11 +209,11 @@ def postag(
...
@@ -209,11 +209,11 @@ def postag(
# defaults
# defaults
baseline_backoff_tagger
=
baseline_backoff_tagger
or
REGEXP_TAGGER
baseline_backoff_tagger
=
baseline_backoff_tagger
or
REGEXP_TAGGER
if
templates
is
None
:
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
# 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:
# for instance:
templates
=
postagging
.
brill24
()
templates
=
brill24
()
(
training_data
,
baseline_data
,
gold_data
,
testing_data
)
=
\
(
training_data
,
baseline_data
,
gold_data
,
testing_data
)
=
\
_demo_prepare_data
(
tagged_data
,
train
,
num_sents
,
randomize
,
separate_baseline_data
)
_demo_prepare_data
(
tagged_data
,
train
,
num_sents
,
randomize
,
separate_baseline_data
)
...
...
nltk/tbl/feature.py
View file @
dcd225fa
...
@@ -60,7 +60,7 @@ class Feature(object):
...
@@ -60,7 +60,7 @@ class Feature(object):
>>> Pos(2, 1)
>>> Pos(2, 1)
Traceback (most recent call last):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <module>
File "nltk/t
ag/t
bl/template.py", line 306, in __init__
File "nltk/tbl/template.py", line 306, in __init__
raise TypeError
raise TypeError
ValueError: illegal interval specification: (start=2, end=1)
ValueError: illegal interval specification: (start=2, end=1)
...
@@ -258,3 +258,8 @@ class Feature(object):
...
@@ -258,3 +258,8 @@ class Feature(object):
:rtype: any (but usually scalar)
:rtype: any (but usually scalar)
"""
"""
raise
NotImplementedError
raise
NotImplementedError
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
(
optionflags
=
doctest
.
NORMALIZE_WHITESPACE
)
nltk/tbl/rule.py
View file @
dcd225fa
...
@@ -307,3 +307,8 @@ class Rule(TagRule):
...
@@ -307,3 +307,8 @@ class Rule(TagRule):
conditions
=
(
' if '
if
self
.
_conditions
else
""
)
+
', and '
.
join
(
conditions
=
(
' if '
if
self
.
_conditions
else
""
)
+
', and '
.
join
(
[
condition_to_str
(
f
,
v
)
for
(
f
,
v
)
in
self
.
_conditions
])
[
condition_to_str
(
f
,
v
)
for
(
f
,
v
)
in
self
.
_conditions
])
return
replacement
+
conditions
return
replacement
+
conditions
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
(
optionflags
=
doctest
.
NORMALIZE_WHITESPACE
)
nltk/tbl/template.py
View file @
dcd225fa
...
@@ -306,3 +306,6 @@ class Template(BrillTemplateI):
...
@@ -306,3 +306,6 @@ class Template(BrillTemplateI):
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
(
optionflags
=
doctest
.
NORMALIZE_WHITESPACE
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment