Introduction
ROUGE helps us check how good a computer summary is by comparing it to a human summary. It measures how much they overlap in words or phrases.
Jump into concepts and practice - no test required
from rouge_score import rouge_scorer scorer = rouge_scorer.RougeScorer(['rouge1', 'rougeL'], use_stemmer=True) scores = scorer.score(reference_text, generated_text)
scorer = rouge_scorer.RougeScorer(['rouge1'], use_stemmer=True) scores = scorer.score('The cat sat on the mat.', 'The cat is on the mat.')
scorer = rouge_scorer.RougeScorer(['rougeL'], use_stemmer=False) scores = scorer.score('A quick brown fox.', 'A quick fox.')
from rouge_score import rouge_scorer reference = "The quick brown fox jumps over the lazy dog." generated = "A fast brown fox leaps over a lazy dog." scorer = rouge_scorer.RougeScorer(['rouge1', 'rougeL'], use_stemmer=True) scores = scorer.score(reference, generated) print(f"ROUGE-1: Precision={scores['rouge1'].precision:.2f}, Recall={scores['rouge1'].recall:.2f}, F1={scores['rouge1'].fmeasure:.2f}") print(f"ROUGE-L: Precision={scores['rougeL'].precision:.2f}, Recall={scores['rougeL'].recall:.2f}, F1={scores['rougeL'].fmeasure:.2f}")
"the cat sat on the mat" and generated text: "the cat lay on rug", what is the ROUGE-1 precision score?