com.sun.xml.bind.v2.util

Class EditDistance

public class EditDistance extends Object

Computes the string edit distance.

Refer to a computer science text book for the definition of the "string edit distance".

Method Summary
static inteditDistance(String a, String b)
Computes the edit distance between two strings.
static StringfindNearest(String key, String[] group)
Finds the string in the group closest to key and returns it.
static StringfindNearest(String key, Collection<String> group)
Finds the string in the group closest to key and returns it.

Method Detail

editDistance

public static int editDistance(String a, 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 String findNearest(String key, String[] group)
Finds the string in the group closest to key and returns it.

Returns: null if group.length==0.

findNearest

public static String findNearest(String key, Collection<String> group)
Finds the string in the group closest to key and returns it.

Returns: null if group.length==0.