dev@glassfish.java.net

Re: "Did you mean" in asadmin

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 11 Aug 2006 11:36:03 -0700

Craig L Russell wrote:
> Hi Kohsuke,
>
> This is a great idea, perhaps you could blog about it?

Sure.

> I think it applies to lots of different cases and needs wider
> awareness. You didn't mention what package it was in. Could it return
> a String[ ] of possible candidates ranked by nearness to the subject
> String? Then you could offer the user a choice, e.g.

The basic algorithm of the string edit distance is, given two strings,
compute the number of insert/remove/replace chars it takes to get from
one to the other.

So sure, you can sort them in order, or cut by certain threshold, etc.

The code I wrote isn't going to scale for a large dataset, but if since
we are talking about 100 max, it's not a problem.

http://fisheye5.cenqua.com/browse/jaxb2-sources/jaxb-ri/runtime/src/com/sun/xml/bind/v2/util/EditDistance.java?r=1.1


> "Your command "foo" was not recognized. Perhaps you meant 'go-foo',
> 'foo-bar', or 'foo-lish'?"

Edit distance computation won't find this kind of match, for the reasons
Kedar mentioned. "foo" is closer to "bar" (3 steps) than "foolish" (4
steps), according to the definition of the edit distance.

But it does find "list-components" from "list-comopnent" or
"start-domain" from "startDomain", things like that.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com