fuzzy_trie

Crates.iofuzzy_trie
lib.rsfuzzy_trie
version1.2.0
sourcesrc
created_at2020-05-03 09:46:29.675802
updated_at2022-09-06 07:01:21.317877
descriptionKey-value collection to make fuzzy searches
homepage
repositoryhttps://github.com/VictorBulba/fuzzy_trie
max_upload_size
id236995
size17,997
Victor (VictorBulba)

documentation

README

Key-value collection to make fuzzy searches

FuzzyTrie is a trie with a LevensteinAutomata to make fuzzy searches

Example

use fuzzy_trie::FuzzyTrie;

let mut trie = FuzzyTrie::new(2, false);
trie.insert("vanilla").insert("vanilla item");
trie.insert("hello").insert("hello item");
trie.insert("helo").insert("helo item");
trie.insert("vanllo").insert("vanllo item");


let mut hello = Vec::new();
trie.fuzzy_search("hello", &mut hello);
let mut hello_iter = hello.into_iter();

assert_eq!(hello_iter.next(), Some((0, &"hello item")));
assert_eq!(hello_iter.next(), Some((1, &"helo item")));
assert_eq!(hello_iter.next(), None);


let mut vanila = Vec::new();
trie.fuzzy_search("vanilla", &mut vanila);
let mut vanila_iter = vanila.into_iter();

assert_eq!(vanila_iter.next(), Some((0, &"vanilla item")));
assert_eq!(vanila_iter.next(), Some((2, &"vanllo item")));
assert_eq!(vanila_iter.next(), None);

Some more examples are in tests.rs

Commit count: 19

cargo fmt