Trait fuzzy_match::algorithms::SimilarityAlgorithm [−][src]
pub trait SimilarityAlgorithm { fn new() -> Self; fn get_similarity(&mut self, a: &str, b: &str) -> f32; }
Trait defining a single similarity algorithm.
Required Methods
fn new() -> Self
Create a new instance of this algorithm. It's recommended to keep a single instance around as long as possible, as this allows any temporary storage to be recycled without additional allocations.
fn get_similarity(&mut self, a: &str, b: &str) -> f32
Gets the similarity of a given pair of strings using this algorithm. Two identical strings will
always produce 1.0
, and mismatching length 1 strings produce 0.0
. If either string is empty, 0.0
will be
returned. Implementations within the crate round the weight to 5 decimal places, but other implementations don't
need to do the same.
Implementors
impl SimilarityAlgorithm for SorensenDice
impl SimilarityAlgorithm for Levenshtein