Function rust_fuzzy_search::fuzzy_search
source · pub fn fuzzy_search<'a, T: AsRef<str>>(
s: &'a str,
list: &'a [T]
) -> Vec<(&'a str, f32)>
Expand description
Use this function to compare a string (&str
) with all elements of a list.
The result is a list whose elements are tuples of the form (string, score)
, the first element being the word of the list and the second element the score.
Arguments:
s
: the string to compare.list
: the list of strings to compare withs
.
example:
fn test() {
use rust_fuzzy_search::fuzzy_search;
let s = "bulko";
let list : Vec<&str> = vec!["kolbasobulko", "sandviĉo"];
let res : Vec<(&str, f32)> = fuzzy_search(s,&list);
for (_word, score) in res {
println!("{:?}",score)
}
}