Package org.apache.openjpa.lib.util
Class StringDistance
java.lang.Object
org.apache.openjpa.lib.util.StringDistance
Utilities for calculating string distance.
- Author:
- Marc Prud'hommeaux
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getClosestLevenshteinDistance
(String str, String[] candidates) Returns the candidate string with the closest Levenshtein distance to the given string.static String
getClosestLevenshteinDistance
(String str, String[] candidates, float thresholdPercentage) Returns the candidate string with the closest Levenshtein distance to the given string and using the threshold as the specified percentage of the length of the candidate string(0.0f-1.0f).static String
getClosestLevenshteinDistance
(String str, String[] candidates, int threshold) Returns the candidate string with the closest Levenshtein distance to the given string.static String
getClosestLevenshteinDistance
(String str, Collection candidates) Returns the candidate string with the closest Levenshtein distance to the given string.static String
getClosestLevenshteinDistance
(String str, Collection<String> candidates, int threshold) Returns the candidate string with the closest Levenshtein distance to the given string.static String
getClosestLevenshteinDistance
(String str, Collection candidates, float thresholdPercentage) Returns the candidate string with the closest Levenshtein distance to the given string and using the threshold as the specified percentage of the length of the candidate string(0.0f-1.0f).static int
Returns the Levenshtein distance between the two strings.
-
Constructor Details
-
StringDistance
public StringDistance()
-
-
Method Details
-
getClosestLevenshteinDistance
Returns the candidate string with the closest Levenshtein distance to the given string. -
getClosestLevenshteinDistance
Returns the candidate string with the closest Levenshtein distance to the given string. -
getClosestLevenshteinDistance
Returns the candidate string with the closest Levenshtein distance to the given string. -
getClosestLevenshteinDistance
public static String getClosestLevenshteinDistance(String str, String[] candidates, float thresholdPercentage) Returns the candidate string with the closest Levenshtein distance to the given string and using the threshold as the specified percentage of the length of the candidate string(0.0f-1.0f). -
getClosestLevenshteinDistance
public static String getClosestLevenshteinDistance(String str, Collection candidates, float thresholdPercentage) Returns the candidate string with the closest Levenshtein distance to the given string and using the threshold as the specified percentage of the length of the candidate string(0.0f-1.0f). -
getClosestLevenshteinDistance
public static String getClosestLevenshteinDistance(String str, Collection<String> candidates, int threshold) Returns the candidate string with the closest Levenshtein distance to the given string.- Parameters:
str
- the string to checkcandidates
- the list of strings to test againstthreshold
- the threshold distance a candidate must meet- See Also:
-
getLevenshteinDistance
Returns the Levenshtein distance between the two strings. The distance is the minimum number of changes that need to be applied to the first string in order to get to the second string. For details of the algorithm, see http://en.wikipedia.org/wiki/Levenshtein_distance.
-