All problems
BLEU Clipped Unigram Precision
Problem
Clipped unigram precision counts each candidate token at most as many times as it appears in the reference, then divides by the candidate length.
Given the candidate tokens and reference tokens, return the precision.
Hint
Clip each candidate token count against the reference count.
Test cases
case 1
in: [["a","b","a"],["a","b"]]
expected: 0.6666666666666666
case 2
in: [["x"],["y"]]
expected: 0
case 3
in: [["a","a"],["a","a"]]
expected: 1
Starter codePython
def bleu_clipped_unigram_precision(candidate, reference):
# Your code here
pass3 test cases · run your code against them in the editor