Jaro-Winkler distance: Difference between revisions

m
Rust code updated to match spec
m (clarify definition)
m (Rust code updated to match spec)
Line 681:
=={{header|Rust}}==
{{trans|Python}}
=={{header|Rust}}==
<lang rust>use std::fs::File;
use std::io::{self, BufRead};
Line 696 ⟶ 697:
let mut st1 = string1;
let mut st2 = string2;
iflet mut len1 = st1.lenchars() < st2.lencount() {;
let mut len2 = st2.lenchars().count();
letif len1 =< st1.len();len2 {
std::mem::swap(&mut st1, &mut st2);
std::mem::swap(&mut len1, &mut len2);
}
let len1 = st1.len();
let len2 = st2.len();
if len2 == 0 {
return if len1 == 0 { 0.0 } else { 1.0 };
}
let delta = std::cmp::max(1, len2len1 / 2) - 1;
let mut flag = vec![false; len2];
let mut ch1_match = vec![];
Line 855 ⟶ 857:
untie | 0.1067
untimely | 0.1083
richtill | 0.11671111
Antilles | 0.1264
untidy | 0.1333
 
Close dictionary words (distance < 0.15 using Jaro-Winkler distance) to 'wich' are:
Line 862 ⟶ 864:
witch | 0.0533
which | 0.0600
untidyswitch | 0.13331111
wicktwitch | 0.11671111
witches | 0.1143
rich | 0.1167
wick | 0.1167
 
</pre>
1,777

edits