Skip to main content

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 jiwer and sacrebleu.
  • Optional preprocessing: lowercase, punctuation removal, and placeholder control for empty hypotheses.

License

MIT

Metadata

Release files for altmetrics 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for altmetrics 0.1.0
File Size Uploaded Provenance Actions
altmetrics-0.1.0.tar.gz 6.6 kB Without provenance Details for altmetrics-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for altmetrics 0.1.0
File Interpreter ABI Platform Actions
altmetrics-0.1.0-py3-none-any.whl Python 3 none any Details for altmetrics-0.1.0-py3-none-any.whl

Total release size: 12.3 kB

Release files / altmetrics-0.1.0.tar.gz

Download URL altmetrics-0.1.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e082da58858df8d6a7f80ead55cd03975bf68e4cd3172d30f170b47178ceb510
BLAKE2b-256 checksum
How to use checksums
009df8be14b1faf26f5cd40cb8f8432febf9750e1e47b05a669fc41340f66eef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / altmetrics-0.1.0-py3-none-any.whl

Download URL altmetrics-0.1.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f3feb3f46e4366ea5e1118c5a86358a8e18b45287c15388e9734fa28ce74c19
BLAKE2b-256 checksum
How to use checksums
05fc5a61da8e9bf7998713a39334dd13ac79bf753bba03676e65cc59d55feb33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for altmetrics 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page