Finds the Jaro Winkler Distance indicating a distance or similarity score between two strings.
pip install pyjarowinklerJaro Winkler Distance
Finds a non-euclidean distance or similarity between two strings.
Jaro and Jaro-Winkler equations provide a score between two short strings where errors are more prone at the end of the string. Jaro's equation measure is the weighted sum of the percentage of matching and transposed characters from each string. Winkler's factor adds weight in Jaro's formula to increase the calculated measure when there is a sequence of characters (a prefix) in both strings.
This version is based on the original C implementation of strcmp95 implementation but does not attempt to normalize homoglyph (e.g.: O vs. 0).
- Impact of the prefix is limited to 4 characters, as originally defined by Winkler.
- Input strings are not modified beyond whitespace trimming.
- In-word whitespace and characters case will optionally impact score.
- Supports optional UTF-8 normalization and homoglyph sanitization.
- Returns a floating point number rounded to the desired decimals (defaults to
2) using Python'sround. - Consider usual floating point arithmetic characteristics when working with this module.
Implementation
The complexity of this algorithm resides in finding the matching and transposed characters. That is because of the interpretation of what are the matching conditions and the definition of transposed. Definitions of those two will make the score vary between implementations of this algorithm.
Here is how matching and are defined in this module: