fuzzy_match_flex

Crates.iofuzzy_match_flex
lib.rsfuzzy_match_flex
version0.1.2
sourcesrc
created_at2023-05-31 18:46:23.755806
updated_at2023-05-31 20:29:14.424181
descriptionFuzzy matching library based on the popular `FuzzyWuzzy` library for python.
homepage
repositoryhttps://github.com/Abbion/FuzzyMatchFlex
max_upload_size
id879046
size17,814
(Abbion)

documentation

README

fuzzy_match_flex Crates.io GitHub

Fuzzy Match is a fuzzy matching library based on the popular FuzzyWuzzy library for python. It contains 4 basic fuzzy matching function. There are also four macros that take responsibility for cleaning strings.

Match Examples

The substitution constant is set to $2$.

Method String_1 String_2 Result
ratio This is a string That is a string $0.875$
partial_ratio Robert builds robots roboty $0.833$

Usage

Usage examples:

let str1 = "Hello";
let str2 = "Hallo";
let similiarity = fuzzy_match_flex::ratio(str1, str2, None);

assert_eq!(similiarity, 0.8);

fuzzy_match_flex::ratio uses the levenshtein distance to calculate the similarity of two strings. The third parameter tells the function if the strings were cleaned. Set to Some(false) if they ware and to Some(true) or None if they need to be cleaned.

let str1 = "Do we buy the airplane?";
let str2 = "Airplane";
let similiarity = fuzzy_match_flex::partial_ratio(str1, str2, None);

assert_eq!(similiarity, 1.0);

fuzzy_match_flex::partial_ratio splits the longest string into tokens and uses the levenshtein distance to calculate the similarity of tokens and shorter string.

let str1 = "My mom bought me ice cream";
let str2 = "The ice cream was bought by my mom";
let similiarity = fuzzy_match_flex::token_sort_ratio(str1, str2, None);

assert_eq!(similiarity, 0.8666667);

fuzzy_match_flex::token_sort_ratio splits both strings into tokens, sorts them and calculates the similarity between sorted words.

let str1 = "There are a lot of differences between Rust and C++";
let str2 = "differences in Rust C++";

let similiarity = fuzzy_match_flex::token_set_ratio(str1, str2, None);
assert_eq!(similiarity, 0.9230769);

fuzzy_match_flex::token_set_ratio finds the intersection of both strings and calculates the similarity of strings.

Documentation

Documentation avaliable with command cargo doc --open

Commit count: 17

cargo fmt