Skip to main content

A high-performance Python package for calculating Word Error Rate (WER), powered by Rust.

Project description

logo-werx

⚡Lightning fast Word Error Rate Calculations

Meta       uv  Ruff  Powered by Rust  Analytics in Motion

What is WERx?

WERx is a high-performance Python package for calculating Word Error Rate (WER), built with Rust for unmatched speed, memory efficiency, and stability. WERx delivers accurate results with exceptional performance, making it ideal for large-scale evaluation tasks.


🚀 Why Use WERx?

Blazing Fast: Rust-powered core delivers outstanding performance, optimized for large datasets

🧩 Robust: Designed to handle edge cases gracefully, including empty strings and mismatched sequences

📐 Insightful: Provides rich word-level error breakdowns, including substitutions, insertions, deletions, and weighted error rates

🛡️ Production-Ready: Minimal dependencies, memory-efficient, and engineered for stability


⚙️ Installation

You can install WERx either with 'uv' or 'pip'.

Using uv (recommended):

uv pip install werx

Using pip:

pip install werx

✨ Usage

Import the WERx package

Python Code:

import werx

Examples:

1. Single sentence comparison

Python Code:

wer = werx.wer('i love cold pizza', 'i love pizza')
print(wer)

Results Output:

0.25

2. Corpus level Word Error Rate Calculation

Python Code:

ref = ['i love cold pizza','the sugar bear character was popular']
hyp = ['i love pizza','the sugar bare character was popular']
wer = werx.wer(ref, hyp)
print(wer)

Results Output:

0.2

3. Weighted Word Error Rate Calculation

Python Code:

ref = ['i love cold pizza', 'the sugar bear character was popular']
hyp = ['i love pizza', 'the sugar bare character was popular']

# Apply lower weight to insertions and deletions, standard weight for substitutions
wer = werx.weighted_wer(
    ref, 
    hyp, 
    insertion_weight=0.5, 
    deletion_weight=0.5, 
    substitution_weight=1.0
)
print(wer)

Results Output:

0.15

4. Complete Word Error Rate Breakdown

The analysis() function provides a complete breakdown of word error rates, supporting both standard WER and weighted WER calculations.

It delivers detailed, per-sentence metrics—including insertions, deletions, substitutions, and word-level error tracking, with the flexibility to customize error weights.

Results are easily accessible through standard Python objects or can be conveniently converted into Pandas and Polars DataFrames for further analysis and reporting.

4a. Getting Started

Python Code:

ref = ["the quick brown fox"]
hyp = ["the quick brown dog"]

results = werx.analysis(ref, hyp)

print("Inserted:", results[0].inserted_words)
print("Deleted:", results[0].deleted_words)
print("Substituted:", results[0].substituted_words)

Results Output:

Inserted Words   : []
Deleted Words    : []
Substituted Words: [('fox', 'dog')]

4b. Converting Analysis Results to a DataFrame

Note: To use this module, you must have either pandas or polars (or both) installed.

Install Pandas / Polars for DataFrame Conversion

uv pip install pandas
uv pip install polars

Python Code:

ref = ["i love cold pizza", "the sugar bear character was popular"]
hyp = ["i love pizza", "the sugar bare character was popular"]
results = werx.analysis(
    ref, hyp,
    insertion_weight=2,
    deletion_weight=2,
    substitution_weight=1
)

We’ve created a special utility to make working with DataFrames seamless. Just import the following helper:

import werx
from werx.utils import to_polars, to_pandas

You can then easily convert analysis results to get output using Polars:

# Convert to Polars DataFrame
df_polars = to_polars(results)
print(df_polars)

Alternatively, you can also use Pandas depending on your preference:

# Convert to Pandas DataFrame
df_pandas = to_pandas(results)
print(df_pandas)

Results Output:

wer wwer ld n_ref insertions deletions substitutions inserted_words deleted_words substituted_words
0.25 0.50 1 4 0 1 0 [] ['cold'] []
0.1667 0.1667 1 6 0 0 1 [] [] [('bear', 'bare')]

📄 License

This project is licensed under the Apache License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

werx-0.3.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

werx-0.3.0-cp313-cp313-win_amd64.whl (184.9 kB view details)

Uploaded CPython 3.13Windows x86-64

werx-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl (313.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

werx-0.3.0-cp313-cp313-macosx_11_0_arm64.whl (271.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

werx-0.3.0-cp312-cp312-win_amd64.whl (184.9 kB view details)

Uploaded CPython 3.12Windows x86-64

werx-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl (313.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

werx-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (271.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

werx-0.3.0-cp311-cp311-win_amd64.whl (184.5 kB view details)

Uploaded CPython 3.11Windows x86-64

werx-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl (315.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

werx-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (273.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

werx-0.3.0-cp310-cp310-win_amd64.whl (184.6 kB view details)

Uploaded CPython 3.10Windows x86-64

werx-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl (315.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

werx-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (273.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file werx-0.3.0.tar.gz.

File metadata

  • Download URL: werx-0.3.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for werx-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c2478321104cbaadd993c0f10189581cb0ab8230fb70046585c85ad9112bf7fa
MD5 0cf56878fe801ae704c7529121603267
BLAKE2b-256 161442f8af0f8d8f29e89f9e32368af9b85f4dec291a31ba8ceb7573ef70cb18

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0.tar.gz:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 184.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for werx-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 08b59e0e99cc0d31c582bd556f043e5ddcfecea08fd2bfaf972ba2e282c23649
MD5 8d4072e0e7b50a29a9286a0ffa7e95da
BLAKE2b-256 cc3ffb17544005fecb1e034abafcbbb6352c989ac5c9a098fa13fd571779c584

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp313-cp313-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 32d60667162126a39449d7ebb90c53b392c0c03e66eab60b6e1fc79533c3aee3
MD5 6f6344c34c991daa33e4f094958def3c
BLAKE2b-256 55cc5291172c41258114aa431ca2fd7d181436b677e28665f327a61735c674a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c0a24f577c745f7056c95e187f1510be786f7473b5049047631f03defa0012f
MD5 b3503217dbea2701a121086a8120d7b4
BLAKE2b-256 067adbaf8822df84f4889e5e2b788a8e17ab7855f3ae432d0bb2d097a6258230

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 184.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for werx-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f227f566507497d5012ffb4ae8e5b8e3c62654e3a040732b661835ec0841e1bb
MD5 5c08f4ed58673703e9084edf9feb4bbf
BLAKE2b-256 9a0c326ec8d1ae93e2cb2e65285ea53368559c29965c44e446bc72027902d839

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp312-cp312-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c8afc45647b26ff0f219d103def731b00d43bba442103f126d6a56e0b05810f8
MD5 e818d278a180ae34926095157b7d0227
BLAKE2b-256 df36f74ba9f24a191c37b06a292ea565d9e3e11371b0101097f2d453b0a5f13f

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 942d085c960d49d54e5ba9125582cf27b54ae7c81279db684d03f3044ee0c1e9
MD5 960f55cc51826192fbfa999dcb2d8dd1
BLAKE2b-256 a11a6d90809e54bd8f53a987d497ed30f0aebbf8e5ce97270aa3d2b4f9eec652

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 184.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for werx-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4622b69cf4b57129ea9635e5d54f8ec82c1a72f96e2ff391161a3bb404f3d8b9
MD5 9641b438bb9062e52e1d7fc70ad7babe
BLAKE2b-256 a7066fb475945c7c08ae8374f5c8a6a5bccb0ca7192263cf71a3144126c90bce

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp311-cp311-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9e9f3d1a53560ea61d43d4a56b5bafe357273928525595622a379e0e66b50d5e
MD5 19c7a07195df040482adef432d596444
BLAKE2b-256 ad35d2e240bba021cfbca60908bcaacb7b4bfb9ee21ba67f53bffa39b6b62792

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 505478f8347e365e17e85af449e8301bdf7a76ffe2a36fb954e320e3fb49f4b8
MD5 0076ca65d57ff717c6b03eeb8673ae6a
BLAKE2b-256 d4f8d77909147642d08eb1cc96e3c2b1b52247abba383a6d24b86839a9f91684

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 184.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for werx-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8ad4860dd4d27fb6ed9a676dfa1e44cfeb1407538823dc7c39d76d75b8cd6d72
MD5 b7b14448166b0240fd343a103157b114
BLAKE2b-256 a961ae2163d1995dde6986720b80e55610692f9187c1e631250688c5bc300cdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp310-cp310-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1b182cf4fefaa433219f755c4c412ff4c172796d8299e34bd18c0b26e65342f5
MD5 8eba568c3bdc0bc2df95d48180f0f9ba
BLAKE2b-256 e82b304a37d9560bc705918bf27c132a8f08a83da408b7c80a63c28309d17190

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63252431c64b9137a2bf36316f51111ac255025bbbb490e03fc97df96bd60baf
MD5 ac5f53b2af017cde00af7e98f2abab04
BLAKE2b-256 bf5c517445e39f4869cc8d99d54dd57915eeb11c9cd43581ea06cf38893cf99c

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page