Bird
0
0

Why does this ROUGE score calculation code raise an error?

medium📝 Debug Q7 of 15
NLP - Text Generation
Why does this ROUGE score calculation code raise an error?
from rouge_score import rouge_scorer
scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2'], use_stemmer=True)
score = scorer.score('machine learning', 'machine learning models')
print(score)
AThe score method expects both inputs as tokenized lists, not raw strings
BThe rouge_scorer module does not support 'rouge2' metric
CThe use_stemmer parameter must be set to False
DThe rouge_scorer.RougeScorer class is deprecated
Step-by-Step Solution
Solution:
  1. Step 1: Check input types

    The score method requires both candidate and reference as tokenized word lists, not raw strings.
  2. Step 2: Identify cause of error

    Passing raw strings causes a type error or unexpected behavior.
  3. Step 3: Verify other options

    ROUGE-2 is supported, use_stemmer=True is valid, and RougeScorer is not deprecated.
  4. Final Answer:

    The score method expects both inputs as tokenized lists, not raw strings -> Option A
  5. Quick Check:

    ROUGE scorer needs tokenized inputs [OK]
Quick Trick: ROUGE scorer inputs must be token lists, not plain strings [OK]
Common Mistakes:
MISTAKES
  • Passing raw strings instead of token lists
  • Misunderstanding supported ROUGE metrics
  • Incorrect use of use_stemmer parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes