Jaro-Winkler distance: Difference between revisions

(Added Swift solution)
Line 404:
wick | 0.11664
</pre>
 
=={{header|Phix}}==
Uses jaro() from [[Jaro_distance#Phix]] and unixdict.txt
<lang Phix>function jaroWinklerDist(string s, t)
integer lm = min({length(s),length(t),4}),
l = sum(sq_eq(s[1..lm],t[1..lm]))
atom js = jaro(s, t),
ws = js + l*0.1*(1-js)
return 1 - ws
end function
constant mispelt = {"accomodate", "definately", "goverment", "occured",
"publically", "recieve", "seperate", "untill", "wich"},
words = get_text(join_path({"demo","unixdict.txt"}),GT_LF_STRIPPED),
nom = length(mispelt),
now = length(words)
sequence jwds = repeat(0,now)
for m=1 to nom do
string ms = mispelt[m]
printf(1,"\nMisspelt word: %s :\n", ms)
for w=1 to now do
jwds[w] = jaroWinklerDist(ms,words[w])
end for
sequence tags = custom_sort(jwds,tagset(now))
for j=1 to 6 do
integer tj = tags[j]
if jwds[tj]>0.15 then exit end if
printf(1,"%0.4f %s\n", {jwds[tj], words[tj]})
end for
end for</lang>
Output identical to Go/Wren
 
=={{header|Python}}==
Line 546 ⟶ 577:
wick | 0.1167
</pre>
 
 
=={{header|Raku}}==
7,806

edits