Evaluate ASR and MT output with alternative-aware metrics.
Project description
altmetrics
altmetrics is a Python toolkit for evaluating speech and text generation systems when multiple orthographically valid references exist. It extends classic metrics such as WER, CER, BLEU, and chrF by expanding bracketed reference alternatives and picking the combination that yields the best score for each hypothesis.
Why altmetrics?
Traditional metrics assume a single canonical reference. In practice, many languages and transcription guidelines permit several spellings (matta vs matten), optional fillers, or regional variants. altmetrics lets you encode these choices in square brackets and automatically evaluates with the most favourable reference for each sentence.
[jenta|jenten] [jogga|jogget] på [broa|broen|brua|bruen]
Installation
pip install altmetrics
Usage
from altmetrics import wer, cer, bleu, chrf
references = [
"[jenta|jenten] [jogga|jogget] på [broa|broen|brua|bruen]",
"[katten|katta] ligger på [matta|matten]",
"Det var en fin dag."
]
hypotheses = [
"jenta jogga på broa",
"katten ligger på matta",
"Det var en fin dag."
]
print("WER :", wer(references, hypotheses, lowercase=True))
print("CER :", cer(references, hypotheses))
print("BLEU:", bleu(references, hypotheses))
print("chrF:", chrf(references, hypotheses))
Features
- Accepts both modern
[optionA|optionB]and legacy["optionA","optionB"]reference syntax. - Works with multiple metrics via a shared expansion and optimisation pipeline.
- Compatible with recent versions of
jiwerandsacrebleu. - Optional preprocessing: lowercase, punctuation removal, and placeholder control for empty hypotheses.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file altmetrics-0.1.0.tar.gz.
File metadata
- Download URL: altmetrics-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e082da58858df8d6a7f80ead55cd03975bf68e4cd3172d30f170b47178ceb510
|
|
| MD5 |
c4dbea5f22ea6bf16a57cdcd6d26302a
|
|
| BLAKE2b-256 |
009df8be14b1faf26f5cd40cb8f8432febf9750e1e47b05a669fc41340f66eef
|
File details
Details for the file altmetrics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: altmetrics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f3feb3f46e4366ea5e1118c5a86358a8e18b45287c15388e9734fa28ce74c19
|
|
| MD5 |
3730c6d36f337aa54f728afbb7f4899f
|
|
| BLAKE2b-256 |
05fc5a61da8e9bf7998713a39334dd13ac79bf753bba03676e65cc59d55feb33
|