com.sun.tools.xjc.util
Class EditDistance

java.lang.Object
  extended by com.sun.tools.xjc.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".


Method Summary
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 the group closest to key and returns it.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 the group closest to key and returns it.

Returns:
null if group.length==0.

main

public static void main(java.lang.String[] args)