Fuzzy matching algorithm(s) in Rust!
In your Cargo.toml add the following:
toml
[dependencies]
fuzzy-matcher = "*"
Here are some code example:
```rust use fuzzymatcher::FuzzyMatcher; use fuzzymatcher::skim::SkimMatcherV2;
let matcher = SkimMatcherV2::default(); asserteq!(None, matcher.fuzzymatch("abc", "abx")); assert!(matcher.fuzzymatch("axbycz", "abc").issome()); assert!(matcher.fuzzymatch("axbycz", "xyz").issome());
let (score, indices) = matcher.fuzzyindices("axbycz", "abc").unwrap(); asserteq!(indices, [0, 2, 4]); ```
fuzzy_match
only return scores while fuzzy_indices
returns the matching
indices as well.echo "axbycz" | cargo run --example fz "abc"
and check what happens.
The skim is currently used by skim, a fuzzy finder.
O(mn)
where m, n
are the length of the pattern
and input line.O(mn)
for fuzzy_indices
and O(2n)
for
fuzzy_match
which will compress the table for dynamic programming.m*n
exceeded the limit, it will fallback to a linear search.O(mn)
where m, n
are the length of the pattern and
input line.O(mn)
for fuzzy_indices
and O(2n)
for
fuzzy_match
which will compress the table for dynamic programming.