![]() |
VOOZH | about |
Jaro Similarity is the measure of similarity between two strings. The value of Jaro distance ranges from 0 to 1. where 1 means the strings are equal and 0 means no similarity between the two strings.
Examples:
Input: s1 = "CRATE", s2 = "TRACE";
Output: Jaro Similarity = 0.733333
Input: s1 = "DwAyNE", s2 = "DuANE";
Output: Jaro Similarity = 0.822222
Algorithm:
The Jaro Similarity is calculated using the following formula
where:
The characters are said to be matching if they are the same and the characters are not further than
Transpositions are half the number of matching characters in both strings but in a different order.
Calculation:
Below is the implementation of the above approach.
0.733333
Time Complexity: O(N * M), where N is the length of string s1 and M is the length of string s2.
Auxiliary Space: O(N + M)
The Jaro-Winkler similarity is a string metric measuring edit distance between two strings. Jaro - Winkler Similarity is much similar to Jaro Similarity. They both differ when the prefix of two string match. Jaro - Winkler Similarity uses a prefix scale 'p' which gives a more accurate answer when the strings have a common prefix up to a defined maximum length l.
Examples:
Input: s1 = "DwAyNE", s2 = "DuANE";
Output: Jaro-Winkler Similarity =0.84
Input: s1="TRATE", s2="TRACE";
Output: Jaro-Winkler similarity = 0.906667
Calculation:
Below is the implementation of the above approach.
Jaro-Winkler Similarity =0.906667
Time Complexity: O(N * M), where N is the length of string s1 and M is the length of string s2.
Auxiliary Space: O(N + M)