Function triple_accel::levenshtein::levenshtein_naive_with_opts[][src]

pub fn levenshtein_naive_with_opts<T>(
    a: &[T],
    b: &[T],
    trace_on: bool,
    costs: EditCosts
) -> (u32, Option<Vec<Edit>>) where
    T: PartialEq
Expand description

Returns the Levenshtein distance between two strings and optionally, the edit traceback, using the naive scalar algorithm, with extra options.

Arguments

  • a - first string (slice)
  • b - second string (slice)
  • trace_on - whether to return the traceback, the sequence of edits between a and b
  • costs - EditCosts struct for the cost of each edit operation

Example

let dist = levenshtein_naive_with_opts(b"abc", b"ab", true, LEVENSHTEIN_COSTS);

assert!(dist == (1, Some(vec![Edit{edit: EditType::Match, count: 2},
                              Edit{edit: EditType::BGap, count: 1}])));