Package com.sun.xml.bind.v2.util
Class EditDistance
- java.lang.Object
-
- com.sun.xml.bind.v2.util.EditDistance
-
public class EditDistance extends java.lang.Object
Computes the string edit distance.Refer to a computer science text book for the definition of the "string edit distance".
- Author:
- Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
editDistance(java.lang.String a, java.lang.String b)
Computes the edit distance between two strings.static java.lang.String
findNearest(java.lang.String key, java.lang.String[] group)
Finds the string in thegroup
closest tokey
and returns it.static java.lang.String
findNearest(java.lang.String key, java.util.Collection<java.lang.String> group)
Finds the string in thegroup
closest tokey
and returns it.
-
-
-
Method Detail
-
editDistance
public static int editDistance(java.lang.String a, java.lang.String b)
Computes the edit distance between two strings.The complexity is O(nm) where n=a.length() and m=b.length().
-
findNearest
public static java.lang.String findNearest(java.lang.String key, java.lang.String[] group)
Finds the string in thegroup
closest tokey
and returns it.- Returns:
- null if group.length==0.
-
findNearest
public static java.lang.String findNearest(java.lang.String key, java.util.Collection<java.lang.String> group)
Finds the string in thegroup
closest tokey
and returns it.- Returns:
- null if group.length==0.
-
-