pub fn levenshtein_weight(
    a: &str,
    b: &str,
    limit: u32,
    weights: &LevWeights
) -> u32
Expand description

Levenshtein distance computations with adjustable weights and a limit

Allows setting costs for inserts, deletes and substitutions. See algorithms for details on weight computation.

Behind the scenes, this wraps levenshtein_weight_iter.

Example

In this example, an insertion weight of 4, deletion weight of 3, and substitution weight of 2 are used. A limit of 6 is applied, and we see that we hit that limit.

use stringmetrics::{levenshtein_weight, LevWeights};

let weights = LevWeights::new(4, 3, 2);
assert_eq!(levenshtein_weight("kitten", "sitting", 6, &weights), 6);

With a more reasonable limit, we get a representative result. The 8 comes from one added letter (4) and two substitutions.

use stringmetrics::{levenshtein_weight, LevWeights};

let weights = LevWeights::new(4, 3, 2);
assert_eq!(levenshtein_weight("kitten", "sitting", 100, &weights), 8);