Package com.helger.commons.string.util
Class LevenshteinDistance
- java.lang.Object
-
- com.helger.commons.string.util.LevenshteinDistance
-
@Immutable public final class LevenshteinDistance extends Object
Utility class for calculating the Levenshtein distance of 2 strings.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 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 char[] aStr1, @Nullable char[] aStr2, @Nonnegative int nCostInsert, @Nonnegative int nCostDelete, @Nonnegative int nCostSubstitution)
-
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.
-
getDistance
public static int getDistance(@Nullable String sStr1, @Nullable String sStr2, @Nonnegative int nCostInsert, @Nonnegative int nCostDelete, @Nonnegative int nCostSubstitution)
-
-