Registry / ai-ml / rouge
library1.0.1pypypi✓ verified 26d ago

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 rouge
INSTALL
IMPORT
SIG · ROUGE
R
rouge
ai-mlpythonv1.0.1
Install
1.6s avg
Import
13ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 18MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.012s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Rouge
✓ from rouge import Rouge

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.

from rouge import Rouge hypothesis = "the cat sat on the mat" reference = "the cat is on the mat" rouge = Rouge() scores = rouge.get_scores(hypothesis, reference) print(scores)
Debug
Known issues
gotchaThis 'rouge' library (pltrdy/rouge) is a native Python implementation and explicitly states its results may be slightly different from the 'official' ROUGE-155 Perl script. If exact replication of Perl ROUGE-155 is critical, or if using a different Python ROUGE implementation (like 'rouge-score' by Google) results in discrepancies, this is the expected behavior for this package.
fix
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.
affects: All versions
gotchaThere are multiple Python libraries for ROUGE, notably `rouge` (this package, from pltrdy) and `rouge-score` (from Google Research). They have different import paths and API interfaces. Confusing them is a common footgun.
fix
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`.
affects: All versions
gotchaThe library is language-agnostic and expects tokenized input. For optimal results, especially with non-English texts or specific NLP tasks, users should pre-process and tokenize the hypothesis and reference texts before passing them to the `get_scores` method.
fix
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'`.
affects: All versions
deprecatedPrior to version 0.3, there was an error in ROUGE-L calculation when handling sequences with multiple sentences. This was fixed in version 0.3.
fix
Upgrade to version 0.3 or higher to ensure correct ROUGE-L calculations, especially for multi-sentence inputs.
affects: <0.3
Upgrade
Version history
1.0.1latest on PyPI · released Jul 20, 2021
Audit
Dependencies
sixrequiredUsed for Python 2/3 compatibility, though Python 3 is the primary target for recent versions.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
rouge — pip install rouge · libregistry