Class StringUtils
java.lang.Object
com.graphhopper.apache.commons.lang3.StringUtils
This class is a partial Copy of the org.apache.commons.lang3.StringUtils
that can be found here: https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/StringUtils.java
The library can be found here: https://commons.apache.org/proper/commons-lang/
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Find the Levenshtein distance between two Strings.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
getLevenshteinDistance
Find the Levenshtein distance between two Strings.
This is the number of changes needed to change one String into another, where each change is a single character modification (deletion, insertion or substitution).
The implementation uses a single-dimensional array of length s.length() + 1. See http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-c.html for details.
StringUtils.getLevenshteinDistance(null, *) = IllegalArgumentException StringUtils.getLevenshteinDistance(*, null) = IllegalArgumentException StringUtils.getLevenshteinDistance("","") = 0 StringUtils.getLevenshteinDistance("","a") = 1 StringUtils.getLevenshteinDistance("aaapppp", "") = 7 StringUtils.getLevenshteinDistance("frog", "fog") = 1 StringUtils.getLevenshteinDistance("fly", "ant") = 3 StringUtils.getLevenshteinDistance("elephant", "hippo") = 7 StringUtils.getLevenshteinDistance("hippo", "elephant") = 7 StringUtils.getLevenshteinDistance("hippo", "zzzzzzzz") = 8 StringUtils.getLevenshteinDistance("hello", "hallo") = 1
- Parameters:
s
- the first String, must not be nullt
- the second String, must not be null- Returns:
- result distance
- Throws:
IllegalArgumentException
- if either String inputnull
- Since:
- 3.0 Changed signature from getLevenshteinDistance(String, String) to getLevenshteinDistance(CharSequence, CharSequence)
-