Crate noodler

Crate noodler 

Source
Expand description

A port of the python-ngram project that provides fuzzy search using N-gram.

ยงโœ๏ธ Example

use noodler::NGram;

let ngram = NGram::<&str>::builder()
    .arity(2)
    .warp(3.0)
    .threshold(0.75)
    .build()
    // Feed with known words
    .fill(vec!["pie", "animal", "tomato", "seven", "carbon"]);

// Try an unknown/misspelled word, and find a similar match
let word = "tomacco";
let top = ngram.search_sorted(word).next();
if let Some((text, similarity)) = top {
    if similarity > 0.99 {
        println!("โœ” {}", text);
    } else {
        println!(
            "โ“{} (did you mean {}? [{:.0}% match])",
            word,
            text,
            similarity * 100.0
        );
    }
} else {
    println!("๐Ÿ—™ {}", word);
}

ยง๐Ÿ’ญ Inspired by

Please check out these awesome works that helped a lot in the creation of noodler:

  • python-ngram: Set that supports searching by ngram similarity.
  • ngrammatic: A rust crate providing fuzzy search/string matching using N-grams.

ยง๐Ÿšฉ Minimal supported Rust version

All tests passed with rustc v1.41, earlier versions may not compile.

Structsยง

NGram
NGramBuilder
NGramSearcher
SharedNGrams

Traitsยง

Keyed