Package com.helger.commons.string.util
Class LevenshteinDistance
java.lang.Object
com.helger.commons.string.util.LevenshteinDistance
Utility class for calculating the Levenshtein distance of 2 strings.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetDistance(char[] aStr1, char[] aStr2) Get the distance of the 2 strings, using the costs 1 for insertion, deletion and substitution.static intgetDistance(char[] aStr1, char[] aStr2, int nCostInsert, int nCostDelete, int nCostSubstitution) static intgetDistance(String sStr1, String sStr2) Get the distance of the 2 strings, using the costs 1 for insertion, deletion and substitution.static intgetDistance(String sStr1, String sStr2, int nCostInsert, int nCostDelete, int nCostSubstitution)
-
Method Details
-
getDistance
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 char[] aStr1, @Nullable char[] aStr2, @Nonnegative int nCostInsert, @Nonnegative int nCostDelete, @Nonnegative int nCostSubstitution) -
getDistance
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.
-
getDistance
public static int getDistance(@Nullable String sStr1, @Nullable String sStr2, @Nonnegative int nCostInsert, @Nonnegative int nCostDelete, @Nonnegative int nCostSubstitution)
-