A measure of similarity between two strings. It returns a value in the interval [0.0, 1.0], where 0.0 indicates that the two strings are completely different and 1.0 indicates that they are identical.
This transformation function uses the Jaro–Winkler algorithm to measure the similarity between two strings. The Jaro–Winkler distance is a string similarity metric derived from the Jaro distance, which is calculated as follows:
1/3 * (m/|s1| m/|s2| (m-t)/m)
where:
- m is the number of matching characters between the two strings. Two characters match if they are the same and their positions differ by no more than
(max(|s1|, |s2|)/2)-1).
- t is the number of transpositions (matching characters that appear in a different order, such as ET and TE).
If the number of matching characters (m) is zero, the similarity score is 0.0.
Winkler extended the Jaro algorithm to give higher similarity scores to strings that match from the beginning. The Winkler adjustment is applied only when the Jaro distance exceeds a specified threshold (default value: 0.7).
The Jaro–Winkler distance is best suited for measuring the similarity between short strings, such as personal names.
The algorithm’s time complexity is
O(n
2)