Registry / data / jaro-winkler

jaro-winkler

JSON →
library2.0.3pypypi✓ verified 23d ago

The `jaro-winkler` library provides Python implementations of the Jaro and Jaro-Winkler string similarity metrics. It allows for comparison of two strings, returning a score from 0 (no match) to 1 (perfect match). The current version is 2.0.3, offering standard and customizable versions of the functions. While not explicitly stated, the project's release cadence appears to be moderate, with major updates occurring over several years.

pip install jaro-winkler
INSTALL
IMPORT
SIG · JARO-WINKLER
J
jaro-winkler
datapythonv2.0.3
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jaro_winkler_metric
from jaro import jaro_winkler_metric
from jarowinkler import jaro_winkler_similarity
The `jaro-winkler` package (with a hyphen) installs a module named `jaro`. There is a separate, similarly named package `jarowinkler` (no hyphen) that provides a `jarowinkler` module and `jaro_winkler_similarity` function. Importing from the wrong module is a common mistake.
jaro_metric
from jaro import jaro_metric
Imports the standard Jaro string metric.
original_metric
from jaro import original_metric
Imports the Jaro metric matching the reference C code, including typo tables and longer string adjustments.

This quickstart demonstrates how to import the `jaro` module and use its `jaro_winkler_metric` and `jaro_metric` functions to calculate string similarity scores. Scores range from 0 (no similarity) to 1 (identical).

import jaro # Calculate Jaro-Winkler similarity score_winkler = jaro.jaro_winkler_metric('SHACKLEFORD', 'SHACKELFORD') print(f"Jaro-Winkler Similarity: {score_winkler}") # Calculate Jaro similarity score_jaro = jaro.jaro_metric('MARTHA', 'MARHTA') print(f"Jaro Similarity: {score_jaro}")
Debug
Known issues
gotchaThere are two distinct Python packages with very similar names: `jaro-winkler` (this library, which imports as `jaro`) and `jarowinkler` (a different, often faster implementation by maxbachmann, which imports as `jarowinkler`). Users often confuse them, leading to `ModuleNotFoundError` or unexpected behavior if `pip install` one but `import` the other.
fix
Ensure you `pip install jaro-winkler` if you intend to `import jaro`, or `pip install jarowinkler` if you intend to `import jarowinkler`. Do not mix imports from the two different packages.
affects: All versions
gotchaThe Jaro-Winkler algorithm, by design, gives a higher weight to matching prefixes. This means strings with a common beginning will naturally score higher, even if other parts of the strings are very different. This behavior is usually desirable for name matching but can be unexpected in other contexts.
fix
Be aware of the prefix bias when interpreting similarity scores. If this bias is undesirable, consider alternative string similarity algorithms like Levenshtein distance which treats all character positions equally.
affects: All versions
gotchaWhile often referred to as a distance metric, the Jaro-Winkler 'distance' (1 - similarity) does not strictly adhere to the mathematical definition of a metric because it may not satisfy the triangle inequality.
fix
This is a theoretical characteristic; for most practical applications, it does not pose a problem. However, if you are building systems that rely on strict metric properties (e.g., in graph theory or certain clustering algorithms), you should be aware of this limitation.
affects: All versions
gotchaFor optimal performance, especially when dealing with very large datasets or requiring integration with tools like RapidFuzz, the `jarowinkler` (no hyphen) package by maxbachmann (which implements the RapidFuzz C-API) may offer significantly faster computation compared to this `jaro-winkler` library.
fix
Evaluate both `jaro-winkler` and `jarowinkler` if performance is critical. The `jarowinkler` library explicitly leverages C-API and bitparallelism for speed.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jaro'
The Python environment does not have the `jaro-winkler` package installed, or it's installed under a different name, or the import statement is incorrect. The `jaro-winkler` package is imported as `import jaro`.
fix
Ensure the correct package is installed and imported: `pip install jaro-winkler` then `import jaro`.
AttributeError: module 'jaro' has no attribute 'jaro_winkler'
The `jaro-winkler` library's Jaro-Winkler similarity function is named `jaro_winkler_metric`, not `jaro_winkler` or `jaro.jaro_winkler` directly.
fix
Use the correct function name: `import jaro; jaro.jaro_winkler_metric('string1', 'string2')`.
TypeError: ('string1', 'string2') is not a string
The `jaro-winkler` functions expect string inputs, but non-string types (e.g., tuples, integers, or None) were passed as arguments.
fix
Ensure both arguments passed to the Jaro-Winkler function are valid strings: `jaro.jaro_winkler_metric('hello', 'hallo')`.
NameError: name 'jarowinkler' is not defined
This error typically occurs when a module or class is imported (e.g., `from some_module import JaroWinkler`) but then an attempt is made to use the module name directly as a function or an uninstantiated class name as a function, or if a different library (`jarowinkler` vs `jaro-winkler`) was intended to be used and its API is different.
fix
If using the `jaro-winkler` library, ensure you import `jaro` and use its functions, e.g., `import jaro; jaro.jaro_winkler_metric('apple', 'aple')`. If you intended to use the `jarowinkler` library, ensure it's installed (`pip install jarowinkler`) and imported correctly, e.g., `from jarowinkler import jarowinkler_similarity; jarowinkler_similarity('apple', 'aple')`.
Upgrade
Version history
2.0.3latest on PyPI · released Aug 5, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources