Repository navigation
Release 3.4.0
Bug Fixes
-
Blank references inside a list or numpy array are now rejected by
error_handler(), matching the existing check for a single blank reference string. The message names the index of the first blank reference, and thewer(),wers(),werp(),werps(),summary()andsummaryp()functions print that message and returnNone. Previously a blank reference inside a sequence contributed a Word Error Rate of0.0. -
Added a zero guard to the per-row weighted Word Error Rate calculation in
summaryp(), matching the guard already used inwerps(), so a reference with zero words no longer raises an uncaughtZeroDivisionError.
Enhancements
-
Corrected the docstrings of
wer(),wers(),werp(),werps(),summary()andsummaryp()to state that the functions print a message and returnNonewhen the input is invalid. The return type annotation ofwer()is nowfloat | None. In version 4.0.0 invalid input will raise an exception instead of returningNone. -
Pinned the build requirements in
pyproject.tomlto exact versions ofmeson-python,mesonandCython, and removedwheelfrom the build requirements. -
The compiled extension is now built against a stated NumPy C API version (
NPY_TARGET_VERSION=NPY_1_25_API_VERSION), the API level provided by NumPy 1.26. -
Added a
linetraceMeson build option, off by default, that compilesmetrics.pyxwith Cython line tracing for coverage measurement. -
The default Meson build type is now
releasewithb_ndebug=if-release, and the license inmeson.buildis declared with the SPDX identifierBSD-3-Clause. -
Added the
<cnp.int32_t>casts to the two buffer assignments in_calculations_wer_only_reuse_ptr()that did not carry them, matching the other calculation paths, and replaced themetrics.pyxmodule docstring with a description of the three calculation paths and their return shapes. -
The Windows wheel no longer contains the MSVC import library (
.lib) of the compiled extension. -
The source distribution no longer contains the CI configuration, documentation, benchmark and development files.
-
The generated
werpy/metrics.cfile produced by a line tracing build is ignored. -
Every token of a reference and hypothesis pair is now mapped to one canonical object per distinct word before the edit distance is computed, so the dynamic programming loops in
metrics.pyxcompare words by pointer equality instead of by string comparison. The results of every calculation path are unchanged. -
When the reference and the hypothesis are the same string, the calculation functions return a zero edit distance and zero counts directly, without building the token mapping or the edit distance table.
-
The Word Error Rate batch path no longer splits every hypothesis in a preliminary pass to size its buffers. The row buffers are sized on demand as the batch is processed.
-
The Word Error Rate batch path now shares one token buffer across every pair in the batch, grown on demand and freed once when the batch is finished, instead of allocating and freeing a buffer for each pair.
-
The punctuation translation table used by
normalize()is now built once when the module is imported rather than on every call. -
Added support for Python 3.14. The package builds and passes its test suite on CPython 3.14, wheels for CPython 3.14 are now built for Linux, macOS and Windows, and the
Programming Language :: Python :: 3.14classifier was added topyproject.toml. -
Added
werpy/metrics.pyi, a stub file for the compiledwerpy.metricsmodule, installed with the package alongsidepy.typed. It declares the parameter and return types ofcalculations(),metrics(),calculations_fast(),metrics_fast(),calculations_wer_only()andmetrics_wer_only(). -
Added type annotations to
normalize(),error_handler(),wer(),wers(),werp(),werps(),summary()andsummaryp(). Thereferenceandhypothesisparameters are annotated asstr,list[str]or a NumPy array of strings, the types accepted byerror_handler().wers()andwerps()declare afloatreturn for a pair of strings and alist[float]return for a pair of lists or arrays, andnormalize()declares astrreturn for a string and alist[str]return for a list, tuple or array. -
Linux wheels are now built on the
manylinux_2_28image and require glibc 2.28 or newer. Previously they were built on themanylinux2014image, which requires glibc 2.17.