pub struct StringDistanceWorkspace { /* private fields */ }Expand description
Reusable buffers for plain Unicode-scalar string distance computations.
The *_str helpers tokenize inputs and allocate temporary DP rows on each
call. Use this workspace with pre-tokenized char slices when scoring many
plain string pairs, such as a candidate matrix.
Implementations§
Source§impl StringDistanceWorkspace
impl StringDistanceWorkspace
Sourcepub fn levenshtein(&mut self, left: &[char], right: &[char]) -> usize
pub fn levenshtein(&mut self, left: &[char], right: &[char]) -> usize
Computes Levenshtein distance over Unicode scalar value slices.
Sourcepub fn levenshtein_with_cutoff(
&mut self,
left: &[char],
right: &[char],
threshold: usize,
) -> Option<usize>
pub fn levenshtein_with_cutoff( &mut self, left: &[char], right: &[char], threshold: usize, ) -> Option<usize>
Computes Levenshtein distance up to threshold.
Returns Some(distance) when the exact distance is at most
threshold, and None when the distance is greater than threshold.
Sourcepub fn damerau_levenshtein(&mut self, left: &[char], right: &[char]) -> usize
pub fn damerau_levenshtein(&mut self, left: &[char], right: &[char]) -> usize
Computes optimal string alignment Damerau-Levenshtein distance over Unicode scalar value slices.
Sourcepub fn damerau_levenshtein_with_cutoff(
&mut self,
left: &[char],
right: &[char],
threshold: usize,
) -> Option<usize>
pub fn damerau_levenshtein_with_cutoff( &mut self, left: &[char], right: &[char], threshold: usize, ) -> Option<usize>
Computes optimal string alignment Damerau-Levenshtein distance up to
threshold.
Returns Some(distance) when the exact distance is at most
threshold, and None when the distance is greater than threshold.