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
1049f583
Commit
1049f583
authored
May 18, 2014
by
Steven Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some fixes to bleu python compatibility
parent
06804eb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
nltk/align/bleu.py
+4
-4
No files found.
nltk/align/bleu.py
View file @
1049f583
...
...
@@ -89,8 +89,8 @@ class BLEU(object):
@staticmethod
def
compute
(
candidate
,
references
,
weights
):
candidate
=
map
(
lambda
x
:
x
.
lower
(),
candidate
)
references
=
map
(
lambda
x
:
[
c
.
lower
()
for
c
in
x
],
references
)
candidate
=
list
(
map
(
lambda
x
:
x
.
lower
(),
candidate
))
references
=
list
(
map
(
lambda
x
:
[
c
.
lower
()
for
c
in
x
],
references
)
)
n
=
len
(
weights
)
...
...
@@ -109,7 +109,7 @@ class BLEU(object):
@staticmethod
def
modified_precision
(
candidate
,
references
,
n
):
candidate_ngrams
=
ngrams
(
candidate
,
n
)
candidate_ngrams
=
list
(
ngrams
(
candidate
,
n
)
)
if
len
(
candidate_ngrams
)
==
0
:
return
0
...
...
@@ -121,7 +121,7 @@ class BLEU(object):
count_max
=
0
for
reference
in
references
:
reference_ngrams
=
ngrams
(
reference
,
n
)
reference_ngrams
=
list
(
ngrams
(
reference
,
n
)
)
count
=
reference_ngrams
.
count
(
word
)
+
1
if
count
>
count_max
:
...
...
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