Class LevenshteinDistance


  • @Immutable
    public final class LevenshteinDistance
    extends Object
    Utility class for calculating the Levenshtein distance of 2 strings.
    Author:
    Philip Helger
    • Method Detail

      • getDistance

        public static int getDistance​(@Nullable
                                      char[] aStr1,
                                      @Nullable
                                      char[] aStr2)
        Get the distance of the 2 strings, using the costs 1 for insertion, deletion and substitution.
        Parameters:
        aStr1 - First string.
        aStr2 - Second string.
        Returns:
        The Levenshtein distance.
      • getDistance

        public static int getDistance​(@Nullable
                                      String sStr1,
                                      @Nullable
                                      String sStr2)
        Get the distance of the 2 strings, using the costs 1 for insertion, deletion and substitution.
        Parameters:
        sStr1 - First string.
        sStr2 - second string.
        Returns:
        The Levenshtein distance.