pub struct StringSimilarity;Expand description
String similarity utilities
Implementations§
Source§impl StringSimilarity
impl StringSimilarity
Sourcepub fn levenshtein_distance(s1: &str, s2: &str) -> usize
pub fn levenshtein_distance(s1: &str, s2: &str) -> usize
Calculate Levenshtein distance between two strings
Sourcepub fn levenshtein_similarity(s1: &str, s2: &str) -> f64
pub fn levenshtein_similarity(s1: &str, s2: &str) -> f64
Calculate normalized Levenshtein similarity (0.0 to 1.0)
Sourcepub fn jaccard_similarity(s1: &str, s2: &str, n: usize) -> f64
pub fn jaccard_similarity(s1: &str, s2: &str, n: usize) -> f64
Calculate Jaccard similarity between two strings (based on character n-grams)
Sourcepub fn cosine_similarity(s1: &str, s2: &str) -> f64
pub fn cosine_similarity(s1: &str, s2: &str) -> f64
Calculate cosine similarity between two strings (based on word frequencies)
Auto Trait Implementations§
impl Freeze for StringSimilarity
impl RefUnwindSafe for StringSimilarity
impl Send for StringSimilarity
impl Sync for StringSimilarity
impl Unpin for StringSimilarity
impl UnwindSafe for StringSimilarity
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more