BLEU (Bilingual Evaluation Understudy) is the standard metric for evaluating machine translation quality. It measures how many n-grams in the candidate translation appear in the reference, with a penalty for translations that are too short.
Given a candidate translation, a reference translation (both as token lists), and a maximum n-gram order, compute the BLEU score.
If any precision is zero, BLEU is zero.
Return the BLEU score as a float between zero and one.
Input: candidate = ["the", "cat", "sat", "on", "the", "mat"], reference = ["the", "cat", "sat", "on", "the", "mat"], max_n = 4
Output: 1.0
Explanation: Every modified precision equals one and no brevity penalty applies.
Input: candidate = ["the", "cat", "is", "here"], reference = ["the", "cat", "was", "here"], max_n = 2
Output: 0.5
Use tuples as n-gram keys and clip each candidate count by its reference count.
Return zero for any zero precision; otherwise combine log precisions and the brevity penalty.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
BLEU (Bilingual Evaluation Understudy) is the standard metric for evaluating machine translation quality. It measures how many n-grams in the candidate translation appear in the reference, with a penalty for translations that are too short.
Given a candidate translation, a reference translation (both as token lists), and a maximum n-gram order, compute the BLEU score.
If any precision is zero, BLEU is zero.
Return the BLEU score as a float between zero and one.
Input: candidate = ["the", "cat", "sat", "on", "the", "mat"], reference = ["the", "cat", "sat", "on", "the", "mat"], max_n = 4
Output: 1.0
Explanation: Every modified precision equals one and no brevity penalty applies.
Input: candidate = ["the", "cat", "is", "here"], reference = ["the", "cat", "was", "here"], max_n = 2
Output: 0.5
Use tuples as n-gram keys and clip each candidate count by its reference count.
Return zero for any zero precision; otherwise combine log precisions and the brevity penalty.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number