org.apache.openjpa.lib.util
Class StringDistance

java.lang.Object
  extended by org.apache.openjpa.lib.util.StringDistance

public class StringDistance
extends Object

Utilities for calculating string distance.

Author:
Marc Prud'hommeaux

Constructor Summary
StringDistance()
           
 
Method Summary
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 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, Collection candidates, int threshold)
          Returns the candidate string with the closest Levenshtein distance to the given string.
static 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 int getLevenshteinDistance(String s, String t)
          Returns the Levenshtein distance between the two strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringDistance

public StringDistance()
Method Detail

getClosestLevenshteinDistance

public static String getClosestLevenshteinDistance(String str,
                                                   String[] candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.

See Also:
getClosestLevenshteinDistance(String,Collection,int)

getClosestLevenshteinDistance

public static String getClosestLevenshteinDistance(String str,
                                                   Collection candidates)
Returns the candidate string with the closest Levenshtein distance to the given string.

See Also:
getClosestLevenshteinDistance(String,Collection,int)

getClosestLevenshteinDistance

public static String getClosestLevenshteinDistance(String str,
                                                   String[] candidates,
                                                   int threshold)
Returns the candidate string with the closest Levenshtein distance to the given string.

See Also:
getClosestLevenshteinDistance(String,Collection,int)

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).

See Also:
getClosestLevenshteinDistance(String,Collection,int)

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).

See Also:
getClosestLevenshteinDistance(String,Collection,int)

getClosestLevenshteinDistance

public static String getClosestLevenshteinDistance(String str,
                                                   Collection candidates,
                                                   int threshold)
Returns the candidate string with the closest Levenshtein distance to the given string.

Parameters:
str - the string to check
candidates - the list of strings to test against
threshold - the threshold distance a candidate must meet
See Also:
getLevenshteinDistance(java.lang.String, java.lang.String)

getLevenshteinDistance

public static int getLevenshteinDistance(String s,
                                         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.



Copyright © 2006 Apache Software Foundation. All Rights Reserved.