athena_rs 3.6.1

Hyper performant polyglot Database driver
Documentation
use crate::data::calculate::levenshtein_distance::levenshtein_distance_normalized;

/// Compute the similarity score between two string slices, based on normalized Levenshtein distance.
/// Returns a score between 0.0 (completely different) and 1.0 (identical).
///
/// # Arguments
///
/// * `a` - The first string slice to compare
/// * `b` - The second string slice to compare
///
/// # Returns
///
/// A score between 0.0 (completely different) and 1.0 (identical).
///
/// # Examples
///
/// ```
/// let score = similarity_score("hello", "world");
/// assert_eq!(score, 0.0);
/// ```
///
pub fn similarity_score(a: &str, b: &str) -> f64 {
    1.0 - levenshtein_distance_normalized(a, b)
}