예제 #1
0
 /// <summary>
 /// Gets the percentage that the text is different from this text
 /// </summary>
 /// <param name="expected">This text</param>
 /// <param name="actual">The text being compared for differences</param>
 /// <param name="algorithm">The edit distance algorithm to use.  Defaults to Levenshtein.</param>
 /// <returns>The percentage difference</returns>
 public static decimal ErrorPercentage(this string expected, string actual, Algorithms algorithm = Algorithms.Levenshtein)
 {
     return(EditDistance.ErrorPercentage(expected, actual, algorithm));
 }
예제 #2
0
 /// <summary>
 /// Gets the Minimum edit distance of comparing the source to another string using the specified algorithm
 /// </summary>
 /// <param name="source">The source text to use in the comparison</param>
 /// <param name="text">The other text to use in the comparison</param>
 /// <param name="algorithm">The edit distance algorithm to use.  Defaults to Levenshtein</param>
 /// <returns>The minimum edit distance using the specified algorithm</returns>
 public static int MinEditDistance(this string source, string text, Algorithms algorithm = Algorithms.Levenshtein)
 {
     return(EditDistance.MinEditDistance(source, text, algorithm));
 }
예제 #3
0
 /// <summary>
 /// Gets the percentage that the text is similar to this text
 /// </summary>
 /// <param name="source">This text</param>
 /// <param name="text">The text to use as a comparison</param>
 /// <param name="algorithm">The edit distance algorithm to use.  Defaults to Levenshtein.</param>
 /// <returns>The percentage of similarity</returns>
 public static decimal SimilarityPercentage(this string source, string text, Algorithms algorithm = Algorithms.Levenshtein)
 {
     return(EditDistance.SimilarityPercentage(source, text, algorithm));
 }
예제 #4
0
 /// <summary>
 /// Gets the minimum edit distance of the text compared to this text.
 /// Tokenizes the strings and compares using word level comparisons
 /// </summary>
 /// <param name="source">This text</param>
 /// <param name="text">The text to compare to</param>
 /// <param name="algorithm">The edit distance algorithm to use.  Defaults to Levenshtein.</param>
 /// <returns>The minimum edit distance between the two phrases</returns>
 public static decimal PhraseMinEditDistance(this string source, string text, Algorithms algorithm = Algorithms.Levenshtein)
 {
     return(EditDistance.PhraseEditDistance(source, text, algorithm));
 }