Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-306

ROUGE-1 Recall

Problem

Return the ROUGE-1 recall between candidate and reference token lists. Count unigram matches with multiplicity clipping, then divide by the number of reference tokens.

Return 1.0 when both lists are empty and 0.0 when only the reference is empty.

Hint

Clip each matched unigram against its remaining count in the reference.

Test cases

case 1
in: [["a","b","c"],["a","b","c"]]
expected: 1
case 2
in: [["a","b"],["a","b","b"]]
expected: 0.6666666666666666
case 3
in: [["x"],["a","b"]]
expected: 0
case 4
in: [[],[]]
expected: 1
case 5
in: [["a","a"],["a"]]
expected: 1
Starter codePython
def rouge1_recall(candidate, reference):
    # Your code here
    pass

5 test cases · run your code against them in the editor