Package org.apache.openjpa.lib.util
Class StringDistance
- java.lang.Object
-
- org.apache.openjpa.lib.util.StringDistance
-
public class StringDistance extends java.lang.Object
Utilities for calculating string distance.- Author:
- Marc Prud'hommeaux
-
-
Constructor Summary
Constructors Constructor Description StringDistance()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.lang.String[] candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.static java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.lang.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 java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.lang.String[] candidates, int threshold)
Returns the candidate string with the closest Levenshtein distance to the given string.static java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.util.Collection candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.static java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.util.Collection<java.lang.String> candidates, int threshold)
Returns the candidate string with the closest Levenshtein distance to the given string.static java.lang.String
getClosestLevenshteinDistance(java.lang.String str, java.util.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
getLevenshteinDistance(java.lang.String s, java.lang.String t)
Returns the Levenshtein distance between the two strings.
-
-
-
Method Detail
-
getClosestLevenshteinDistance
public static java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.lang.String[] candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.
-
getClosestLevenshteinDistance
public static java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.util.Collection candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.
-
getClosestLevenshteinDistance
public static java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.lang.String[] candidates, int threshold)
Returns the candidate string with the closest Levenshtein distance to the given string.
-
getClosestLevenshteinDistance
public static java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.lang.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 java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.util.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 java.lang.String getClosestLevenshteinDistance(java.lang.String str, java.util.Collection<java.lang.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(java.lang.String, java.lang.String)
-
getLevenshteinDistance
public static int getLevenshteinDistance(java.lang.String s, java.lang.String t)
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.
-
-