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
22b4c565
Commit
22b4c565
authored
Nov 07, 2014
by
Dmitrijs Milajevs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don’t lowercase the candidate and reference sentences.
parent
6bfa589d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
nltk/align/bleu.py
+2
-7
No files found.
nltk/align/bleu.py
View file @
22b4c565
...
...
@@ -20,12 +20,10 @@ from nltk.util import ngrams
def
bleu
(
candidate
,
references
,
weights
):
"""Calculate BLEU score.
:param
iter
(str)) candidate: A candidate sentence.
:param
iter(iter(str))
: Reference sentiences.
:param
list
(str)) candidate: A candidate sentence.
:param
list(list(str)) references
: Reference sentiences.
:param list(float) weights: Weights for unigrams, bigrams, trigrams and so on.
Note that words in candidate and reference sentences are lowercased!
Consider an example:
>>> weights = [0.25, 0.25, 0.25, 0.25]
...
...
@@ -62,9 +60,6 @@ def bleu(candidate, references, weights):
http://www.aclweb.org/anthology/P02-1040.pdf
"""
candidate
=
[
c
.
lower
()
for
c
in
candidate
]
references
=
[[
r
.
lower
()
for
r
in
reference
]
for
reference
in
references
]
p_ns
=
(
_modified_precision
(
candidate
,
references
,
i
)
for
i
,
_
in
enumerate
(
weights
,
start
=
1
)
...
...
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