dev@glassfish.java.net

Re: "Did you mean" in asadmin

From: Kedar Mhaswade <Kedar.Mhaswade_at_Sun.COM>
Date: Fri, 11 Aug 2006 11:25:02 -0700

Craig L Russell wrote:
> Hi Kohsuke,
>
> This is a great idea, perhaps you could blog about it?
>
> 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.
>
> "Your command "foo" was not recognized. Perhaps you meant 'go-foo',
> 'foo-bar', or 'foo-lish'?"
>
I like this (and previous) idea. Maybe we could also introduce a
"dimension" parameter and rank/curtail the possible choices accordingly?

Also, if someone intended to execute "foolish"
command, I am not sure if s/he would "mistype" it like "foo".
A typo is generally having not more than 2 characters of
"Hamming distance" away from the correctly spelled word. (The
sequence is important too).

This is rather different (although related to) from the
"keyword" search where I am trying to search for a command, which
is also a useful addition.

e.g. asadmin help --keyword database
->
create-jdbc-resource (semantically close)
start-database (lexically close)
stop-database (lexically close)

Would it be better to subsume this under the existing "help"
command or introduce a new command like "find"?

Thanks,
Kedar

> Sweet.
>
> Craig
>
> On Aug 11, 2006, at 10:45 AM, Kohsuke Kawaguchi wrote:
>
>> 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
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell_at_sun.com
> P.S. A good JDO? O, Gasp!
>