The 'rouge' library provides a full, native Python implementation of the ROUGE (Recall-Oriented Understudy for Gisting Evaluation) metric, used for evaluating automatic text summarization and machine translation. Unlike some other ROUGE packages, it is not a wrapper around the original Perl script. The current stable version is 1.0.1, with releases occurring periodically to introduce features and fixes.
pip install rougeVerified import paths — ran on the pinned version, not inferred.
Calculate ROUGE scores (ROUGE-1, ROUGE-2, ROUGE-L) for a single hypothesis-reference pair. The `get_scores` method returns a list of dictionaries, each containing 'f' (F1-score), 'p' (precision), and 'r' (recall) for each ROUGE type.
Be aware of potential minor score differences. If strict adherence to ROUGE-155 results is required, consider using packages that wrap the Perl script or `rouge-score` by Google, which aims for Perl script replication.
Ensure you are importing `from rouge import Rouge` for this library. If you intend to use Google's implementation, install `rouge-score` and import `from rouge_score import rouge_scorer.RougeScorer`.
Pre-tokenize your input strings into space-separated words or n-grams before passing them to the `Rouge().get_scores()` method. For example, `hypothesis = 'word1 word2 word3'`.
Upgrade to version 0.3 or higher to ensure correct ROUGE-L calculations, especially for multi-sentence inputs.