A powerful yet lightweight Python package to calculate and analyze the Word Error Rate (WER).
Project description
Word Error Rate for Python
Meta | |
Testing | |
Package |
What is werpy?
werpy is a powerful yet lightweight Python package that rapidly calculates and analyzes the Word Error Rate (WER) between two sets of text.
It has been designed with the flexibility to handle multiple input data types such as strings, lists and NumPy arrays.
The package also includes a full set of features such as normalizing the input text to account for data collection variability and the capability to easily assign different weights/penalties to specific error classifications (insertions, deletions, and substitutions).
Additionally, the summary function provides a comprehensive breakdown of the calculated results to assist in analyzing the specific errors quickly and in more detail.
Functions available in werpy
The following table provides an overview of the functions that can be used in werpy.
Function | Description |
---|---|
normalize(text) | Preprocess input text to remove punctuation, remove duplicated spaces, leading/trailing blanks and convert all words to lowercase. |
wer(reference, hypothesis) | Calculate the overall Word Error Rate for the entire reference and hypothesis texts. |
wers(reference, hypothesis) | Calculates a list of the Word Error Rates for each of the reference and hypothesis texts. |
werp(reference, hypothesis) | Calculates a weighted Word Error Rate for the entire reference and hypothesis texts. |
werps(reference, hypothesis) | Calculates a list of weighted Word Error Rates for each of the reference and hypothesis texts. |
summary(reference, hypothesis) | Provides a comprehensive breakdown of the calculated results including the WER, Levenshtein Distance and all the insertion, deletion and substitution errors. |
summaryp(reference, hypothesis) | Delivers an in-depth breakdown of the results, covering metrics like WER, Levenshtein Distance, and a detailed account of insertion, deletion, and substitution errors, inclusive of the weighted WER. |
Installation
You can install the latest werpy release with Python's pip package manager:
# Install werpy from PyPi
pip install werpy
Usage
Import the werpy package
Python Code:
import werpy
Example 1 - Normalize a list of text
Python Code:
input_data = ["It's very popular in Antarctica.","The Sugar Bear character"]
reference = werpy.normalize(input_data)
print(reference)
Results Output:
['its very popular in antarctica', 'the sugar bear character']
Example 2 - Calculate the overall Word Error Rate on a set of strings
Python Code:
wer = werpy.wer('i love cold pizza', 'i love pizza')
print(wer)
Results Output:
0.25
Example 3 - Calculate the overall Word Error Rate on a set of lists
Python Code:
ref = ['i love cold pizza','the sugar bear character was popular']
hyp = ['i love pizza','the sugar bare character was popular']
wer = werpy.wer(ref, hyp)
print(wer)
Results Output:
0.2
Example 4 - Calculate the Word Error Rates for each set of texts
Python Code:
ref = ['no one else could claim that','she cited multiple reasons why']
hyp = ['no one else could claim that','she sighted multiple reasons why']
wers = werpy.wers(ref, hyp)
print(wers)
Results Output:
[0.0, 0.2]
Example 5 - Calculate the weighted Word Error Rates for the entire set of text
Python Code:
ref = ['it was beautiful and sunny today']
hyp = ['it was a beautiful and sunny day']
werp = werpy.werp(ref, hyp, insertions_weight=0.5, deletions_weight=0.5, substitutions_weight=1)
print(werp)
Results Output:
0.25
Example 6 - Calculate a list of weighted Word Error Rates for each of the reference and hypothesis texts
Python Code:
ref = ['it blocked sight lines of central park', 'her father was an alderman in the city government']
hyp = ['it blocked sightlines of central park', 'our father was an elder man in the city government']
werps = werpy.werps(ref, hyp, insertions_weight = 0.5, deletions_weight = 0.5, substitutions_weight = 1)
print(werps)
Results Output:
[0.21428571428571427, 0.2777777777777778]
Example 7 - Provide a complete breakdown of the Word Error Rate calculations for each of the reference and hypothesis texts
Python Code:
ref = ['it is consumed domestically and exported to other countries', 'rufino street in makati right inside the makati central business district', 'its estuary is considered to have abnormally low rates of dissolved oxygen', 'he later cited his first wife anita as the inspiration for the song', 'no one else could claim that']
hyp = ['it is consumed domestically and exported to other countries', 'rofino street in mccauti right inside the macasi central business district', 'its estiary is considered to have a normally low rates of dissolved oxygen', 'he later sighted his first wife anita as the inspiration for the song', 'no one else could claim that']
summary = werpy.summary(ref, hyp)
print(summary)
Results Output:
Example 8 - Provide a complete breakdown of the Weighted Word Error Rate for each of the input texts
Python Code:
ref = ['the tower caused minor discontent because it blocked sight lines of central park', 'her father was an alderman in the city government', 'he was commonly referred to as the blacksmith of ballinalee']
hyp = ['the tower caused minor discontent because it blocked sightlines of central park', 'our father was an alderman in the city government', 'he was commonly referred to as the blacksmith of balen alley']
weighted_summary = werpy.summaryp(ref, hyp, insertions_weight = 0.5, deletions_weight = 0.5, substitutions_weight = 1)
print(weighted_summary)
Results Output:
Dependencies
- NumPy - Provides an assortment of routines for fast operations on arrays
- Pandas - Powerful data structures for data analysis, time series, and statistics
Licensing
werpy
is released under the terms of the BSD 3-Clause License. Please refer to the LICENSE file for full details.
This project also includes third-party packages distributed under the BSD-3-Clause license (NumPy, Pandas) and the Apache License 2.0 (Cython).
The full NumPy, Pandas and Cython licenses can be found in the LICENSES directory in this repository.
They can also be found directly in the following source codes:
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 Distributions
File details
Details for the file werpy-2.1.2.tar.gz
.
File metadata
- Download URL: werpy-2.1.2.tar.gz
- Upload date:
- Size: 219.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee97c798da48435b15f6b57906e3e6725a92017ec9a3f524de7aa5f49edbcf8 |
|
MD5 | 1109e01317196efaf17fc886628fd3f7 |
|
BLAKE2b-256 | c844272bf9df917228ca28c152c420aa0e432e2ac8d4b3e2a5194e720cba0af1 |
File details
Details for the file werpy-2.1.2-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 58.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8d753132994aae987ea9600a87b523ad38821267dae5eb768e02d842819e41 |
|
MD5 | bce113b147792f9e3a14e56938761eca |
|
BLAKE2b-256 | 396283e9fe7817c135f4ee1535187717b6d2c4318348f57b9815eaf532bedb65 |
File details
Details for the file werpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 47.7 kB
- Tags: CPython 3.12, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 084577da5039b5d8087cb42ddff7441f7f0fa5a2f5d1235e79e3ff48c5a7d0ed |
|
MD5 | b393eb1d930cab8440cbc58e55cc65c2 |
|
BLAKE2b-256 | 8251e02cbf870f1a002a6425ced64f88961ec87d5b3f2702545619f5d8f23c03 |
File details
Details for the file werpy-2.1.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 47.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a83a06f503397cedd78e803b27f6ce8e1c2de96958787706bf284675ccc497f9 |
|
MD5 | 48d4a1e897257173d2c20b371a1011f9 |
|
BLAKE2b-256 | 61c2ec8c3aea4c9fa105b0599547b70fa653d6430c30a8ecd676960da701608d |
File details
Details for the file werpy-2.1.2-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 40.0 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a3442efefe7cfdf3a4bc55f19d334a0e39e27414abb7303d0ca643113e9ed91 |
|
MD5 | c934c7e03bce9b475e81efb97eca1541 |
|
BLAKE2b-256 | 12fae6da27111c603cdfa2ff58baee8d956feb04db076f429def44e93890a254 |
File details
Details for the file werpy-2.1.2-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 57.8 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce48e29f3f083480211a268cd359e85fbc9e6cc09241b0d363b801f2ea333100 |
|
MD5 | 7861604ed576d00f0780512cf3cd7ba7 |
|
BLAKE2b-256 | f12adb32f82cdd7313355b6b4b480cfcb22f1eba72c745e0c4b30059898a8e3a |
File details
Details for the file werpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 47.1 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf53fa60b9dd6bb1e3ff3bc163d5c0b291929cf2a82d7fde364796c64bd3c51f |
|
MD5 | 9e99457eb125bf1e81550541eef53fe6 |
|
BLAKE2b-256 | b314078aca1fe7139f4c8eb9f33a86104dd95783e93e24992fccecf454ca1eb3 |
File details
Details for the file werpy-2.1.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 47.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46db2a7f676fc7fe715fa80ea39ad0362801f96d5e15eff586d08fdbfbfb071d |
|
MD5 | fea55a748ccbe2da5c6c2c9d108c5059 |
|
BLAKE2b-256 | ea5fb2eac0ca228b321e61d27d5d0f1ce5ad51d4bddb22cb88f54c4d933149b7 |
File details
Details for the file werpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 39.6 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb038c68c603c8b2c786cd03e5c17807f184f2fe032133bbcc2b0f6eade020d |
|
MD5 | 71ca3201be4ea539f6ca1b27e4a508bc |
|
BLAKE2b-256 | 7d300703ca5a6d3a19410783e6dfc26af2933bdb7d58c74f7e65b15c1c4e6941 |
File details
Details for the file werpy-2.1.2-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 57.2 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de6b686fac67b7cb27e29a8093b50b16b70ca7220f677c2dff2b72ec56b1f094 |
|
MD5 | 1ac0eea50682e213ceafc6ffd6434c72 |
|
BLAKE2b-256 | e962f2264e6edbd7a3b903d53cbc402909350589aefecf5cf5ed6bcfe05bf4f2 |
File details
Details for the file werpy-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 47.4 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16064bfb56509f114c3fc2dbea26ef64ef650dff83009b74789f99df82280ed8 |
|
MD5 | d01e8e9c308bd4a954d5a3483ae622cb |
|
BLAKE2b-256 | 04c5e4f1b1c7c4292911af7bb18134577e5b8776a1ef68e071208fb665de6528 |
File details
Details for the file werpy-2.1.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 46.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d259f7032496e5adf3f18ada991a62f33537618f95db9db9c0b00244ad117270 |
|
MD5 | 4d6aa04dd3c2d923f8506740acec2301 |
|
BLAKE2b-256 | 2548d5f9f02c769d66a8e8f90689bb6cb5772da963a66fc215081beeed89b158 |
File details
Details for the file werpy-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 39.8 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e87d354aee5f4fe5150b7130cc83dd84963f80c43a66654145d81682f1db1f5e |
|
MD5 | cc92e3b3becb4cda9a68274d9c7a9f5c |
|
BLAKE2b-256 | 91ca742aec714b9c411d2275968bcbdc46d6a4ce58a396fec3897fbe29968099 |
File details
Details for the file werpy-2.1.2-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 57.2 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6f4359e03fe81df8ef21e6296743d283d7466dbe3dfe5085a9bcf898dd263d4 |
|
MD5 | e952e7b8d0deb1a59e9ad2398c4c85fb |
|
BLAKE2b-256 | a8c646a93de35a47894a49751c31e4e8b77ed2c4db170b3c60dd324f7bae6a5e |
File details
Details for the file werpy-2.1.2-cp39-cp39-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp39-cp39-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 47.4 kB
- Tags: CPython 3.9, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96db7a629c9ae817072a61986a4ad4c67f0671649df7b55a30863b96d8de78f8 |
|
MD5 | 05bbd3eda7a975c1b38b5caed84031bc |
|
BLAKE2b-256 | ba10f9206c3b5e24e8c4e855a9b8b5eb9be5d219493cdb8705955cfe6f8de392 |
File details
Details for the file werpy-2.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 46.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d74b7d28b49c57f7734383f2946ee7f7664a4d22356e6762496e97afc0f4153 |
|
MD5 | 9ff0ef82e110b42db46a90ed4d52227a |
|
BLAKE2b-256 | 8d0bf2199e8a968137c11fa2f9cdbfe3c8a78c9fb1529d9ccfc73d506320c498 |
File details
Details for the file werpy-2.1.2-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 39.8 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31ce4109a642a21b76ee254edf61dbf6c8f8b6f5754b6dea15a444215a156a9 |
|
MD5 | d2d9a460ace68c6ecc6a40a1751ba775 |
|
BLAKE2b-256 | 0cf19e5027d08659a233425901da4cf6a5bca4bc76bd6826c17416da38b69c31 |
File details
Details for the file werpy-2.1.2-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 57.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acc0cf184f07cc645d417dbe93f88138a26837bc19df76d3e745352115daa373 |
|
MD5 | 54e0a28605dc8e2a1b6e02bb9494c55d |
|
BLAKE2b-256 | 00ccb21bc399c8fa514fe6a054f7fd94077ff6761910462122621881a68333d9 |
File details
Details for the file werpy-2.1.2-cp38-cp38-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp38-cp38-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 47.4 kB
- Tags: CPython 3.8, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b1ec4a2790f492e8500dc41d8f691e367f438e7128bfea79797180245559004 |
|
MD5 | eadc516ce31656df7892d7acf0c31e97 |
|
BLAKE2b-256 | 12878c9ea3cee9318cbbd7a3a6ede3a4faa765876966f52e1bc2fecdf1f88642 |
File details
Details for the file werpy-2.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 46.7 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa8ff7726db6317e1779defdf767375dcc0a88a780a5ba1645ba8c31fa7229bc |
|
MD5 | 59db66454b193c85b0c85ce15e408a85 |
|
BLAKE2b-256 | 274895a9c0a33d2d15e68ffdd27f76f3f6c6ea7f60e93481d454b4def0c80c43 |
File details
Details for the file werpy-2.1.2-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: werpy-2.1.2-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 39.8 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e24ecc1e1be3710da4e9822d1f80f5b14ca7ae0f4816f730c65c13afe4af2279 |
|
MD5 | edbd8aaf9d5b9bdadec91ba89c633413 |
|
BLAKE2b-256 | 224136a1dee9124142888f503c470a613c5f05ed8fc2dc7a77d2f4e314025208 |