Function triple_accel::levenshtein::levenshtein_naive_k_with_opts [−][src]
pub fn levenshtein_naive_k_with_opts<T>(
a: &[T],
b: &[T],
k: u32,
trace_on: bool,
costs: EditCosts
) -> Option<(u32, Option<Vec<Edit>>)> where
T: PartialEq,
Expand description
Returns the Levenshtein distance, bounded by a cost threshold k
, between two strings and optionally,
the edit traceback, using the naive scalar algorithm, with extra options.
This will return None
if the Levenshtein distance between a
and b
is greater than the
threshold k
.
This should be much faster than levenshtein_naive_with_opts
if k
is small compared to the lengths of
a
and b
.
Arguments
a
- first string (slice)b
- second string (slice)k
- maximum number of cost allowed betweena
andb
trace_on
- whether to return the traceback, the sequence of edits betweena
andb
costs
-EditCosts
struct for the cost of each edit operation
Example
let dist = levenshtein_naive_k_with_opts(b"abc", b"ab", 1, true, LEVENSHTEIN_COSTS); assert!(dist.unwrap() == (1, Some(vec![Edit{edit: EditType::Match, count: 2}, Edit{edit: EditType::BGap, count: 1}])));