Exact string matching is too rigid for generated text: two summaries can express the same idea with different wording or word order. ROUGE instead rewards lexical overlap between a prediction and a reference, making it especially useful for automatic summarization. section 4.2.1
ROUGE provides several overlap views:
- ROUGE-N compares matching N-grams; larger overlap produces a higher score. section 4.2.1
- ROUGE-L compares longest common subsequences, while skip-bigram variants preserve word order without requiring adjacency. section 4.2.1
Listing 4.1 Using ROUGE
from rouge_score import rouge_scorer
target = "The game 'The Legend of Zelda' follows the adventures of the \
hero Link in the magical world of Hyrule."
prediction = "Link embarks on epic quests and battles evil forces to \
save Princess Zelda and restore peace in the land of Hyrule."
scorer = rouge_scorer.RougeScorer(["rouge1", "rougeL"], use_stemmer=True) #1
scores = scorer.score(target, prediction)
print(scores)
# {'rouge1': Score(precision=0.28571428, recall=0.31578947, fmeasure=0.3),
# 'rougeL': Score(precision=0.238095238, recall=0.26315789, fmeasure=0.25)}
A short Python example scores Zelda summaries with ROUGE-1 and ROUGE-L, reporting precision, recall, and F-measure. section 4.2.1

