TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

167. ROUGE-L

Medium

Compute the F1 score of the Longest Common Subsequence between a reference and candidate token list.

Signature: def rouge_l(reference: list, candidate: list) -> float

Steps:

  1. Compute LCS length with O(m*n) dynamic programming.
  2. precision = lcs / len(candidate)
  3. recall = lcs / len(reference)
  4. F1 = 2 * p * r / (p + r)

Return 0.0 if either input is empty or LCS is 0.

Math

ROUGE-L=LCS⋅(∣c∣+∣r∣)2⋅LCS2​

Asked at

NumPy

import numpy as np

 

def rouge_l(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?