Struct levenshtein_automata::LevenshteinAutomatonBuilder[][src]

pub struct LevenshteinAutomatonBuilder { /* fields omitted */ }
Expand description

Builder for Levenshtein Automata.

It wraps a precomputed datastructure that allows to produce small (but not minimal) DFA.

Implementations

impl LevenshteinAutomatonBuilder[src]

pub fn new(
    max_distance: u8,
    transposition_cost_one: bool
) -> LevenshteinAutomatonBuilder
[src]

Creates a Levenshtein automaton builder. The builder

  • max_distance - maximum distance considered by the automaton.
  • transposition_cost_one - assign a distance of 1 for transposition

Building this automaton builder is computationally intensive. While it takes only a few milliseconds for d=2, it grows exponentially with d. It is only reasonable to d <= 5.

pub fn build_dfa(&self, query: &str) -> DFA[src]

Builds a Finite Determinstic Automaton to compute the levenshtein distance to a fixed given query.

There is no guarantee that the resulting DFA is minimal but its number of states is guaranteed to be smaller than C * (query.len() + 1) in which C is a constant that depends on the distance as well as whether transposition are supported or not.

For instance for d=2 and with transposition, C=68.

pub fn build_prefix_dfa(&self, query: &str) -> DFA[src]

Builds a Finite Determinstic Automaton that computes the prefix levenshtein distance to a given query.

Given a test string, the resulting distance is defined as

    min( levenshtein(&test_string[..i], query } for i in 0..test_string.len() )

Which translates as the minimum distance of the prefixes of test_strings.

See also .build_dfa(…).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.