[][src]Function str_distance::str_distance_normalized

pub fn str_distance_normalized<S, T, D>(a: S, b: T, dist: D) -> f64 where
    S: AsRef<str>,
    T: AsRef<str>,
    D: DistanceMetric

Evaluates the normalized distance between two strings based on the provided crate::DistanceMetric, so that it returns always a f64 between 0 and 1. A value of '0.0' corresponds to the "zero distance", both strings are considered equal by means of the metric, whereas a value of '1.0' corresponds to the maximum distance that can exist between the strings.

Remark

The distance between two empty strings (a: "", b: "") is determined as 0.0, (a == b)

Examples

/// ```

use str_distance::{Levenshtein, SorensenDice, TokenSet, RatcliffObershelp,

DistanceValue, str_distance_normalized}; assert_eq!(str_distance_normalized("" , "", Levenshtein::default()), 0.0); assert_eq!(str_distance_normalized("nacht", "nacht", Levenshtein::default()), 0.0); assert_eq!(strdistance_normalized("abc", "def", Levenshtein::default()), 1.0); ```