pub mod dice;
pub mod hamming;
pub mod jaro_winkler;
pub mod levenshtein;
pub mod units;
pub use dice::dice_coefficient;
#[cfg(feature = "parallel")]
pub use dice::par_dice_coefficient_batch;
#[cfg(feature = "parallel")]
pub use hamming::par_hamming_batch;
pub use hamming::{INCOMPARABLE, hamming, hamming_checked};
#[cfg(feature = "parallel")]
pub use jaro_winkler::par_jaro_winkler_batch;
pub use jaro_winkler::{jaro, jaro_winkler};
pub use levenshtein::{
SearchResult, damerau_levenshtein, damerau_levenshtein_search, levenshtein, levenshtein_search,
};
#[cfg(feature = "parallel")]
pub use levenshtein::{par_damerau_levenshtein_batch, par_levenshtein_batch};
use verbora_core::StringMetric;
#[derive(Debug, Clone, Copy, Default)]
pub struct Levenshtein(pub levenshtein::Options);
impl StringMetric for Levenshtein {
const IS_SIMILARITY: bool = false;
fn measure(&self, a: &str, b: &str) -> f64 {
levenshtein(a, b, &self.0)
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct DamerauLevenshtein(pub levenshtein::Options);
impl StringMetric for DamerauLevenshtein {
const IS_SIMILARITY: bool = false;
fn measure(&self, a: &str, b: &str) -> f64 {
damerau_levenshtein(a, b, &self.0)
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct JaroWinkler(pub jaro_winkler::Options);
impl StringMetric for JaroWinkler {
const IS_SIMILARITY: bool = true;
fn measure(&self, a: &str, b: &str) -> f64 {
jaro_winkler(a, b, &self.0)
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Dice;
impl StringMetric for Dice {
const IS_SIMILARITY: bool = true;
fn measure(&self, a: &str, b: &str) -> f64 {
dice_coefficient(a, b)
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Hamming {
pub ignore_case: bool,
}
impl StringMetric for Hamming {
const IS_SIMILARITY: bool = false;
fn measure(&self, a: &str, b: &str) -> f64 {
hamming(a, b, self.ignore_case) as f64
}
}