Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe the BLEU is wrong #2

Open
puzzledTao opened this issue Feb 3, 2018 · 1 comment
Open

Maybe the BLEU is wrong #2

puzzledTao opened this issue Feb 3, 2018 · 1 comment

Comments

@puzzledTao
Copy link

In the BLEU.py, function modified_precision(references, hypothesis, n):

def modified_precision(references, hypothesis, n):
# Extracts all ngrams in hypothesis.
counts = Counter(ngrams(hypothesis, n))
if not counts:
return Fraction(0)
# Extract a union of references' counts.
max_counts = reduce(or_, [Counter(ngrams(ref, n)) for ref in references])
# Assigns the intersection between hypothesis and references' counts.
clipped_counts = {ngram: min(count, max_counts[ngram]) for ngram, count in counts.items()}
return Fraction(sum(clipped_counts.values()), sum(counts.values()))

function Fraction() returns reduction of a fraction. Such as value = Fraction(3, 6), so value.numerator = 1,
value.denominator= 2. However, when we statistics the number of n-gram, we should add 3 not 1. Looking forward to your reply.

@cshanbo
Copy link
Owner

cshanbo commented Feb 4, 2018

Hmm, thank you for pointing out this, I will check it. Normally we use BLEU from nltk. A PR will be welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants