A fast and multiprocessing-enabled ROUGE-L scorer.
Project description
Plain ROUGE-L
Plain ROUGE-L is a Python package designed to compute ROUGE-L scores for evaluating the quality of generated text against reference text. It uses a simple space-based splitting for tokenization. No preprocessing like regex filtering, stemming, etc (useful for some non-English texts). This implementation is approximately 1.5 times faster than the official ROUGE-L implementation and supports multiprocessing for batch computations.
Installation
To install Plain ROUGE-L, simply clone the repository and install dependencies if any.
git clone https://github.com/oKatanaaa/Plain-ROUGE-L.git
cd Plain-ROUGE-L
pip install .
Usage
Here is a simple example to demonstrate how to use Plain ROUGE-L:
from plain_rougel import RougeLScorer
# Instantiate the scorer
rouge_l_scorer = RougeLScorer()
# Single pair score computation
generated_text = "the cat sat on the mat"
reference_text = "the cat is on the mat"
score = rouge_l_scorer.compute_rouge_l(generated_text, reference_text)
print(score) # Output: {'precision': 0.8, 'recall': 0.8, 'f1': 0.8}
# Batch score computation
generated_texts = ["the cat sat on the mat", "the dog sits on the rug"]
reference_texts = ["the cat is on the mat", "the dog is on the rug"]
batch_scores = rouge_l_scorer.compute_rouge_l_batch(generated_texts, reference_texts)
print(batch_scores)
# Output: [{'precision': 0.8, 'recall': 0.8, 'f1': 0.8}, {'precision': 0.8, 'recall': 0.8, 'f1': 0.8}]
# Filter generated texts by F-score threshold
filtered_pairs = rouge_l_scorer.filter_by_fscore(generated_texts, reference_texts, fscore_threshold=0.85)
print(filtered_pairs)
# Output: [('the cat sat on the mat', 'the cat is on the mat', {'precision': 0.8, 'recall': 0.8, 'f1': 0.8}), ('the dog sits on the rug', 'the dog is on the rug', {'precision': 0.8, 'recall': 0.8, 'f1': 0.8})]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file plain_rougel-0.1.0.tar.gz
.
File metadata
- Download URL: plain_rougel-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70b2c45454a1a150c974daae48fb00806a6affb4e26f043284bea6e59daeff8e |
|
MD5 | 1baf1e4585ad540286d5aa792632979b |
|
BLAKE2b-256 | 04338d0601a6e31aa50e7e2743f530540e742d4ef8ad28ca4cbb157c4c415605 |
File details
Details for the file plain_rougel-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: plain_rougel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23a92caabc4fb346ce68c138e92a5b7836e7507d68627de08cb7951ad3fc5982 |
|
MD5 | 81b677887566910d086b3560087b36e8 |
|
BLAKE2b-256 | c7b4443e1dc71623b34897fb13a3011581abad25cf54c9617d5fc9239752757b |