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
e0a00400
Commit
e0a00400
authored
Aug 22, 2012
by
Steven Bird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix variable name, to resolve issue 287
parent
b11e8b10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletions
+3
-1
nltk/tag/sequential.py
+3
-1
No files found.
nltk/tag/sequential.py
View file @
e0a00400
...
@@ -439,6 +439,8 @@ class RegexpTagger(SequentialBackoffTagger, yaml.YAMLObject):
...
@@ -439,6 +439,8 @@ class RegexpTagger(SequentialBackoffTagger, yaml.YAMLObject):
... (r'.*ed$', 'VBD'), # past tense verbs
... (r'.*ed$', 'VBD'), # past tense verbs
... (r'.*', 'NN') # nouns (default)
... (r'.*', 'NN') # nouns (default)
... ])
... ])
>>> regexp_tagger
<Regexp Tagger: size=9>
>>> regexp_tagger.tag(test_sent)
>>> regexp_tagger.tag(test_sent)
[('The', 'AT'), ('Fulton', 'NN'), ('County', 'NN'), ('Grand', 'NN'), ('Jury', 'NN'),
[('The', 'AT'), ('Fulton', 'NN'), ('County', 'NN'), ('Grand', 'NN'), ('Jury', 'NN'),
('said', 'NN'), ('Friday', 'NN'), ('an', 'AT'), ('investigation', 'NN'), ('of', 'NN'),
('said', 'NN'), ('Friday', 'NN'), ('an', 'AT'), ('investigation', 'NN'), ('of', 'NN'),
...
@@ -467,7 +469,7 @@ class RegexpTagger(SequentialBackoffTagger, yaml.YAMLObject):
...
@@ -467,7 +469,7 @@ class RegexpTagger(SequentialBackoffTagger, yaml.YAMLObject):
self
.
_map
=
dict
(
zip
(
labels
,
tags
))
self
.
_map
=
dict
(
zip
(
labels
,
tags
))
regexps_labels
=
[(
regex
,
label
)
for
((
regex
,
tag
),
label
)
in
zip
(
regexps
,
labels
)]
regexps_labels
=
[(
regex
,
label
)
for
((
regex
,
tag
),
label
)
in
zip
(
regexps
,
labels
)]
self
.
_regexs
=
re
.
compile
(
'|'
.
join
([
'(?P<
%
s>
%
s)'
%
(
label
,
regex
)
for
regex
,
label
in
regexps_labels
]))
self
.
_regexs
=
re
.
compile
(
'|'
.
join
([
'(?P<
%
s>
%
s)'
%
(
label
,
regex
)
for
regex
,
label
in
regexps_labels
]))
self
.
_size
=
len
(
regexs
)
self
.
_size
=
len
(
regex
p
s
)
def
choose_tag
(
self
,
tokens
,
index
,
history
):
def
choose_tag
(
self
,
tokens
,
index
,
history
):
m
=
self
.
_regexs
.
match
(
tokens
[
index
])
m
=
self
.
_regexs
.
match
(
tokens
[
index
])
...
...
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