#levenshtein

veloci_levenshtein_automata

Creates Levenshtein Automata in an efficient manner

1 unstable release

0.1.0 Mar 17, 2023

#1278 in Text processing

21 downloads per month

MIT license

50KB
1K SLoC

Levenshtein-automaton

This is likely not the crate you are looking for, use this one: https://crates.io/crates/levenshtein_automata

The main difference is that this crate has an ignore case option.


lib.rs:

This crate makes it fast and simple to build a deterministic finite automaton (DFA) that computes the levenshtein distance from a given string.

Example

use veloci_levenshtein_automata::{LevenshteinAutomatonBuilder, Distance};

// Building this factory is not free.
let lev_automaton_builder = LevenshteinAutomatonBuilder::new(2, true);

// We can now build an entire dfa.
let dfa = lev_automaton_builder.build_dfa("Levenshtein", false);

let mut state = dfa.initial_state();
for &b in "Levenshtain".as_bytes() {
state = dfa.transition(state, b);
}

assert_eq!(dfa.distance(state), Distance::Exact(1));

The implementation is based on the following paper Fast String Correction with Levenshtein-Automata (2002) by by Klaus Schulz and Stoyan Mihov. I also tried to explain it in the following blog post.

!

Dependencies

~0–395KB