pub struct Levenshtein { /* private fields */ }
Expand description
A struct for calculating Levenshtein distance.
This struct provides methods to set custom costs for insert, delete, and replace operations and a method to calculate the Levenshtein distance between two sequences.
Implementations§
Source§impl Levenshtein
impl Levenshtein
Sourcepub fn new() -> Levenshtein
pub fn new() -> Levenshtein
Constructs a new Levenshtein
.
Initializes with default costs for insertion, deletion, and replacement operations.
§Examples
let levenshtein = Levenshtein::new();
Sourcepub fn set_insert_cost(&mut self, cost: i32)
pub fn set_insert_cost(&mut self, cost: i32)
Sourcepub fn set_replace_cost(&mut self, cost: i32)
pub fn set_replace_cost(&mut self, cost: i32)
Sourcepub fn set_delete_cost(&mut self, cost: i32)
pub fn set_delete_cost(&mut self, cost: i32)
Sourcepub fn calculate(&self, seq1: &str, seq2: &str) -> Results
pub fn calculate(&self, seq1: &str, seq2: &str) -> Results
Calculates the Levenshtein distance between two sequences.
Returns a Results
struct containing the distance and the sequence of operations.
§Arguments
seq1
- The first sequence.seq2
- The second sequence.
§Examples
let levenshtein = Levenshtein::new();
let results = levenshtein.calculate("kitten", "sitting");
Auto Trait Implementations§
impl Freeze for Levenshtein
impl RefUnwindSafe for Levenshtein
impl Send for Levenshtein
impl Sync for Levenshtein
impl Unpin for Levenshtein
impl UnwindSafe for Levenshtein
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more