I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("JELLYFISH", "SMELLYFISH") I get an error because the code counts the double S of "SMELLYFISH", due to this error I have not been able to finish successfully, here is what I have programmed up to this moment
uno = "DIXON"; dos ="DICKSONX" ;
rep = Characters[uno] \[Intersection] Characters[dos]
scope = Max[StringLength[uno], StringLength[dos]]/2 - 1
inter = Transpose[{Flatten[Position[Characters[uno], #] & /@ rep],
Flatten[Position[Characters[dos], #] & /@ rep]}]
m = Select[inter, Abs[#[[1]] - #[[2]]] < scope &]
prb = Select[m, #[[1]] != #[[2]] &]
trans = Length[DeleteCases[Position[prb, Reverse[#]] & /@ prb, {}]]/2
1/3 (Length[m]/StringLength[uno] + Length[m]/StringLength[dos] + (
Length[m] - trans)/Length[m])
% // N
Someone who can help me solve this problem? Maybe the approach I'm using is wrong, I hope someone is interested in this problem too. Thanks in advance