closestmatch

Crates.ioclosestmatch
lib.rsclosestmatch
version0.1.2
sourcesrc
created_at2017-04-09 19:26:39.170434
updated_at2017-04-11 11:02:37.318129
descriptionThis library fuzzy matches an input string to a list of target strings.
homepagehttps://github.com/Maaarcocr/closestmatch-rs.git
repositoryhttps://github.com/Maaarcocr/closestmatch-rs.git
max_upload_size
id10147
size7,999
Marco Concetto Rudilosso (Maaarcocr)

documentation

https://maaarcocr.github.io/closestmatch-rs

README

Build Status

closestmatch-rs

This library fuzzy matches an input string to a list of target strings.

Why this library

Let's say that you have a collections of words, call it a dictionary of known words, such as ["hello","good","rust"]. You also have a word, such as "hllo" and you want to find the closest match from the dictionary. This is the main functionality of this library.

How it works

The library is based on the concept of bags of words and it calculate the similarity splitting strings in substrings. The developer using this library can specify how long the bags of words are.

Documentation

You can find the documentation here

Example

let known_words = ["hello".to_string(), "rust".to_string(), "hello world".to_string()].to_vec();
//The second parameter specify that strings will be splitted in bags of words of length 2 and 3.
let cm = ClosestMatch::new(known_words,[2, 3].to_vec());
let closest = cm.get_closest("hlo".to_string());
println!("{}", closest)

This will print Some("hello").

Commit count: 19

cargo fmt