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
447a4a5e
Commit
447a4a5e
authored
Mar 04, 2015
by
Long Duong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polish the code
parent
94c23505
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
nltk/tag/crfsuite.py
+9
-12
No files found.
nltk/tag/crfsuite.py
View file @
447a4a5e
...
@@ -106,15 +106,14 @@ class CRFTagger(TaggerI):
...
@@ -106,15 +106,14 @@ class CRFTagger(TaggerI):
# We need the list of sentences instead of the list generator for matching the input and output
# We need the list of sentences instead of the list generator for matching the input and output
result
=
[]
result
=
[]
for
sent
in
sents
:
for
sent
in
sents
:
features
=
[]
features
=
[
self
.
_get_features
(
data
)
for
data
in
sent
]
for
data
in
sent
:
labels
=
tagger
.
tag
(
features
)
features
.
append
(
self
.
_get_features
(
data
))
labels
=
tagger
.
tag
(
features
)
if
len
(
labels
)
!=
len
(
sent
):
if
len
(
labels
)
!=
len
(
sent
):
raise
Exception
(
' Predicted Length Not Matched, Expect Errors !'
)
raise
Exception
(
' Predicted Length Not Matched, Expect Errors !'
)
tagged_sent
=
[]
for
i
in
range
(
len
(
labels
)):
tagged_sent
=
[(
sent
[
i
],
labels
[
i
])
for
i
in
range
(
len
(
labels
))]
tagged_sent
.
append
((
sent
[
i
],
labels
[
i
]))
result
.
append
(
tagged_sent
)
result
.
append
(
tagged_sent
)
return
result
return
result
...
@@ -131,11 +130,9 @@ class CRFTagger(TaggerI):
...
@@ -131,11 +130,9 @@ class CRFTagger(TaggerI):
y_train
=
[]
y_train
=
[]
for
sent
in
train_data
:
for
sent
in
train_data
:
features
=
[]
features
=
[
self
.
_get_features
(
data
)
for
data
,
label
in
sent
]
labels
=
[]
labels
=
[
label
for
data
,
label
in
sent
]
for
data
,
label
in
sent
:
features
.
append
(
self
.
_get_features
(
data
))
labels
.
append
(
label
)
X_train
.
append
(
features
)
X_train
.
append
(
features
)
y_train
.
append
(
labels
)
y_train
.
append
(
labels
)
...
...
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