Jaro Winkler Similarity

Jaro Winkler Distance (wikipedia)

  • A string metric that measures an edit distance.

Algorithm:

simj={0m=013(ms1+ms2+mtm)otherwisesim_j = \begin{cases} \text{0} & \text{m=0} \\ \frac{1}{3} (\frac{m}{|s_1|}+\frac{m}{|s_2|}+\frac{m-t}{m}) & \text{otherwise} \end{cases}
  • Where si|s_i| is the length of string sis_i.
  • mm is the number of matching characters
  • tt is the number of transpositions

Jaro and Jaro-Winkler similarity (geeksforgeeks)

Jaro Similarity

measure of similarity between two strings. Value is between 0 and 1. Where 1 means they are equal and 0 means there is no similarity.

Examples: s1 = "CRATE", s2 = "TRACE"

  • Jaro similarity is 0.733333
    simj={0if m = 013(ms1+ms2+mtm)if m0sim_j = \begin{cases} \text{0} & \text{if m = 0} \\ \frac{1}{3} (\frac{m}{|s_1|}+\frac{m}{|s_2|}+\frac{m-t}{m}) & \text{if m} \neq 0 \end{cases}
    where:
  • mm is the number of matching characters
  • tt is half the number of transpositions
  • where **|s1|** and **|s2|** are the lengths of strings s1 and s2 respectively.

Time Complexity: O(NM)O(N*M) Space: O(N+M)O(N+M)

Jaro-Winkler Similarity

Defined as following: Sw=Sj+PL(1Sj)S_w = S_j + P * L (1 - S_j) Where:

  • SjS_j is the jaro similarity
  • SwS_w is the jaro-winkler similarity
  • PP is the scaling factor (0.1 by default)
  • LL is the length of hte matching prefix up to a max of 4 characters