Function strsim::sorensen_dice

source ·
pub fn sorensen_dice(a: &str, b: &str) -> f64
Expand description

Calculates a Sørensen-Dice similarity distance using bigrams. See https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient.

use strsim::sorensen_dice;

assert_eq!(1.0, sorensen_dice("", ""));
assert_eq!(0.0, sorensen_dice("", "a"));
assert_eq!(0.0, sorensen_dice("french", "quebec"));
assert_eq!(1.0, sorensen_dice("ferris", "ferris"));
assert_eq!(0.8888888888888888, sorensen_dice("feris", "ferris"));