pub struct Levenshtein<T = Symbols> { /* private fields */ }
Expand description
levenshtein distance metric for strings
Implementations§
Source§impl Levenshtein<Symbols>
impl Levenshtein<Symbols>
Sourcepub fn new() -> Self
pub fn new() -> Self
creates a new levenshtein distance metric
Examples found in repository?
examples/string_matching.rs (line 2)
1pub fn main(){
2 let mut tree=BKTreeMap::new(Levenshtein::new());
3 tree.insert("calculate","mathematics");
4 tree.insert("cat","pet");
5 tree.insert("kat","name");
6 tree.insert("hello","greeting");
7 tree.insert("hi","greeting");
8 tree.insert("linear","mathematics");
9
10 println!("{}",tree.get("calculator",2).map(|(s,_d)|*s).unwrap_or("not found"));
11 println!("{}",tree.get("hey",2).map(|(s,_d)|*s).unwrap_or("not found"));
12 println!("{}",tree.get("kate",2).map(|(s,_d)|*s).unwrap_or("not found"));
13 println!("{}",tree.get("line",2).map(|(s,_d)|*s).unwrap_or("not found"));
14 println!("{}",tree.get("serotonin",2).map(|(s,_d)|*s).unwrap_or("not found"));
15}
Source§impl<T> Levenshtein<T>
impl<T> Levenshtein<T>
Trait Implementations§
Source§impl<T> AsMut<Levenshtein<T>> for Levenshtein<T>
impl<T> AsMut<Levenshtein<T>> for Levenshtein<T>
Source§impl<T> AsRef<Levenshtein<T>> for Levenshtein<T>
impl<T> AsRef<Levenshtein<T>> for Levenshtein<T>
Source§impl<T: Clone> Clone for Levenshtein<T>
impl<T: Clone> Clone for Levenshtein<T>
Source§impl<T: Debug> Debug for Levenshtein<T>
impl<T: Debug> Debug for Levenshtein<T>
Source§impl<T: Default> Default for Levenshtein<T>
impl<T: Default> Default for Levenshtein<T>
Source§fn default() -> Levenshtein<T>
fn default() -> Levenshtein<T>
Returns the “default value” for a type. Read more
Source§impl<U: ?Sized + SymbolIter, V: ?Sized + SymbolIter<Item = U::Item>> DiscreteMetric<U, V> for Levenshtein<Symbols>
impl<U: ?Sized + SymbolIter, V: ?Sized + SymbolIter<Item = U::Item>> DiscreteMetric<U, V> for Levenshtein<Symbols>
Auto Trait Implementations§
impl<T = Symbols> !Freeze for Levenshtein<T>
impl<T> RefUnwindSafe for Levenshtein<T>where
T: RefUnwindSafe,
impl<T> Send for Levenshtein<T>where
T: Send,
impl<T> Sync for Levenshtein<T>where
T: Sync,
impl<T> Unpin for Levenshtein<T>where
T: Unpin,
impl<T> UnwindSafe for Levenshtein<T>where
T: UnwindSafe,
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