All problems
ROUGE-2 F1
Problem
Return the bigram-overlap F1 between candidate and reference token lists. Count clipped matches per distinct bigram, then F1 = 2PR/(P+R) with precision = matches / candidate bigrams and recall = matches / reference bigrams.
Return 0.0 when either list has fewer than two tokens or there are no matches.
Hint
Clipped matching counts each bigram at most as often as it appears in the reference.
Test cases
case 1
in: [["a","b","c"],["a","b","c"]]
expected: 1
case 2
in: [["a","b","c"],["a","b","d"]]
expected: 0.5
case 3
in: [["a","b"],["c","d"]]
expected: 0
case 4
in: [["a"],["a"]]
expected: 0
case 5
in: [["a","b","c","d"],["a","b","c"]]
expected: 0.8
Starter codePython
def rouge2_f1(candidate, reference):
# Your code here
pass5 test cases · run your code against them in the editor