dev@glassfish.java.net

Re: "Did you mean" in asadmin

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 11 Aug 2006 10:45:18 -0700

Cheng Fang wrote:
> We can have some simple pattern match to map wrong subcommands to a list
> of valid commands. Any interest?

A better approach is to compute the string edit distance to the nearest
available command. This works pretty well for simple typos, and I've
been using it successfully in the JAXB RI to diagnose user's typos:

     public static String findNearest( String key, String[] group ) {
       ...
     }

It finds the string in "group" that's closest to the given key.

The code is under CDDL, and if Glassfish developers would like to copy
it, I'd be very happy.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com