fn similarity2<'a>(&mut self, mut string1: &'a str, mut string2: &'a str, min_similarity: f64) -> Option<f64> {
        assert_eq!((0.0..1.0).contains(&min_similarity), true);

        if string1.is_empty() && string2.is_empty() {
            return null_similarity_results(string1, string2, min_similarity);
        }

        // if strings of different lengths, ensure shorter string is in string1. This can result in a little
        // faster speed by spending more time spinning just the inner loop during the main processing.
        let mut str1_len = GraphemeClusters::new(string1).len();
        let mut str2_len = GraphemeClusters::new(string2).len();
        if str1_len > str2_len {
            let s = string1;
            string1 = string2;
            string2 = s;

            let sl = str1_len;
            str1_len = str2_len;
            str2_len = sl;
        }
        let max_distance = distance(min_similarity, str2_len);
        if str1_len > max_distance {
            return None;
        }

        if max_distance == 0 {
            return if string1 == string2 { Some(1.0) } else { None };
        }

        // identify common suffix and/or prefix that can be ignored
        let (len1, len2, start) = prefix_suffix_prep(string2, string2);
        if len1 == 0 {
            return Some(1.0);
        }

        let distance = if max_distance < len2 {
            Levenshtein::core_levenshtein2(string1, string2, len1, len2, start, max_distance as usize, &mut self.base_char1_costs)
        } else {
            Levenshtein::core_levenshtein(string1, string2, len1, len2, start, &mut self.base_char1_costs)
        };

        if distance.is_some() {
            return similarity(distance.unwrap() as f64, str2_len as f64);
        }
        None
    }
/// <summary>Return Levenshtein similarity between two strings
/// (1 - (levenshtein distance / len of longer string)).</summary>
/// <param name="string1">One of the strings to compare.</param>
/// <param name="string2">The other string to compare.</param>
/// <param name="minSimilarity">The minimum similarity that is of interest.</param>
/// <returns>The degree of similarity 0 to 1.0, where -1 represents a similarity
/// lower than minSimilarity, otherwise, a number between 0 and 1.0 where 0
/// represents a lack of any noteable similarity, and 1 represents equivalent
/// strings.</returns>
Return Levenshtein similarity between two strings
(1 - (levenshtein distance / len of longer string)).
One of the strings to compare.
The other string to compare.
The minimum similarity that is of interest.
The degree of similarity 0 to 1.0, where -1 represents a similarity
lower than minSimilarity, otherwise, a number between 0 and 1.0 where 0
represents a lack of any noteable similarity, and 1 represents equivalent
strings.
Return Levenshtein similarity between two strings ( 1 - ( levenshtein distance / len of longer string )) . One of the strings to compare . The other string to compare . The minimum similarity that is of interest . The degree of similarity 0 to 1 . 0 where - 1 represents a similarity lower than minSimilarity otherwise a number between 0 and 1 . 0 where 0 represents a lack of any noteable similarity and 1 represents equivalent strings .
fn similarity2<'a>(&mut self, mut string1: &'a str, mut string2: &'a str, min_similarity: f64) -> Option<f64> {
        assert_eq!((0.0..1.0).contains(&min_similarity), true);
        if string1.is_empty() && string2.is_empty() {
            return null_similarity_results(string1, string2, min_similarity);
        }
        // if strings of different lengths, ensure shorter string is in string1. This can result in a little
        // faster speed by spending more time spinning just the inner loop during the main processing.
        let mut str1_len = GraphemeClusters::new(string1).len();
        let mut str2_len = GraphemeClusters::new(string2).len();
        if str1_len > str2_len {
            let s = string1;
            string1 = string2;
            string2 = s;
            let sl = str1_len;
            str1_len = str2_len;
            str2_len = sl;
        }
        let max_distance = distance(min_similarity, str2_len);
        if str1_len > max_distance {
            return None;
        }
        if max_distance == 0 {
            return if string1 == string2 { Some(1.0) } else { None };
        }
        // identify common suffix and/or prefix that can be ignored
        let (len1, len2, start) = prefix_suffix_prep(string2, string2);
        if len1 == 0 {
            return Some(1.0);
        }
        let distance = if max_distance < len2 {
            Levenshtein::core_levenshtein2(string1, string2, len1, len2, start, max_distance as usize, &mut self.base_char1_costs)
        } else {
            Levenshtein::core_levenshtein(string1, string2, len1, len2, start, &mut self.base_char1_costs)
        };
        if distance.is_some() {
            return similarity(distance.unwrap() as f64, str2_len as f64);
        }
        None
    }
fn similarity2 < ' a > ( & mut self , mut string1 : & ' a str , mut string2 : & ' a str , min_similarity : f64 ) -> Option < f64 > { assert_eq ! ( ( 0.0 1.0 ) contains ( min_similarity ) true ) ; if string1 . is_empty ( ) && string2 . is_empty ( ) { return null_similarity_results ( string1 , string2 , min_similarity ) ; } // if strings of different lengths, ensure shorter string is in string1. This can result in a little // faster speed by spending more time spinning just the inner loop during the main processing. let mut str1_len = GraphemeClusters :: new ( string1 ) . len ( ) ; let mut str2_len = GraphemeClusters :: new ( string2 ) . len ( ) ; if str1_len > str2_len { let s = string1 ; string1 = string2 ; string2 = s ; let sl = str1_len ; str1_len = str2_len ; str2_len = sl ; } let max_distance = distance ( min_similarity , str2_len ) ; if str1_len > max_distance { return None ; } if max_distance == 0 { return if string1 == string2 { Some ( 1.0 ) } else { None } ; } // identify common suffix and/or prefix that can be ignored let ( len1 , len2 , start ) = prefix_suffix_prep ( string2 , string2 ) ; if len1 == 0 { return Some ( 1.0 ) ; } let distance = if max_distance < len2 { Levenshtein :: core_levenshtein2 ( string1 , string2 , len1 , len2 , start , max_distance as usize , & mut self . base_char1_costs ) } else { Levenshtein :: core_levenshtein ( string1 , string2 , len1 , len2 , start , & mut self . base_char1_costs ) } ; if distance . is_some ( ) { return similarity ( distance . unwrap ( ) as f64 , str2_len as f64 ) ; } None }
<summary>Return Levenshtein similarity between two strings
(1 - (levenshtein distance / len of longer string)).</summary>
<param name="string1">One of the strings to compare.</param>
<param name="string2">The other string to compare.</param>
<param name="minSimilarity">The minimum similarity that is of interest.</param>
<returns>The degree of similarity 0 to 1.0, where -1 represents a similarity
lower than minSimilarity, otherwise, a number between 0 and 1.0 where 0
represents a lack of any noteable similarity, and 1 represents equivalent
strings.</returns>
<summary > Return Levenshtein similarity between two strings ( 1 - ( levenshtein distance / len of longer string )) . < / summary > <param name = " string1 " > One of the strings to compare . < / param > <param name = " string2 " > The other string to compare . < / param > <param name = " minSimilarity " > The minimum similarity that is of interest . < / param > <returns > The degree of similarity 0 to 1 . 0 where - 1 represents a similarity lower than minSimilarity otherwise a number between 0 and 1 . 0 where 0 represents a lack of any noteable similarity and 1 represents equivalent strings . < / returns >
&mut self
string1
&'a str
string2
&'a str
min_similarity
f64