bugGNU Octave - Bugs: bug #46881, provide hints for possible...

 
 

bug #46881: provide hints for possible misspelled symbol names

Submitted by:  None
Submitted on:  Tue 12 Jan 2016 05:37:23 PM UTC  
 
Category: Octave FunctionSeverity: 1 - Wish
Priority: 3 - LowItem Group: Feature Request
Status: NoneAssigned to: None
Originator Name: Originator Email: -unavailable-
Open/Closed: OpenRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 03 Mar 2016 03:08:33 PM UTC, comment #8:

Realized I never got a project suggestion posted to the GSOC wiki. Just added one now. Could use some points filled in such as Minimum Requiremets, mentor, etc.

http://wiki.octave.org/Summer_of_Code_Project_Ideas#Command_line_suggestion_feature

Nicholas Jankowski <nrjank>
Thu 18 Feb 2016 03:09:19 AM UTC, comment #7:

Haven't written one up or even seen one before, but I can take a look at it thus weekend. Assuming there are models on the gsoc wiki page. If not point me in the right direction. As far as mentoring if simeone picks it up though, would probably need someone who knows more of the back end of the interpreter/GUI.

Nicholas Jankowski <nrjank>
Thu 18 Feb 2016 02:59:52 AM UTC, comment #6:

Nicholas, you absolutely right that this type of "user experience" issue is where Octave can really be better than Matlab. For those of us who need to write Matlab-compatible code, this is much more important than incompatible language extensions (even though things like += are amazingly useful).

Matlab (R2013b) doesn't use a lookup table for this. It recognizes when I mistype a long variable. It seems to check for matches against variables that are at least four characters, even if I only type three.

Regarding "interp", I get

I like the fact that only ENTER is required to execute the suggested command. In the GUI, it would be possible to have a pop-up with multiple options, so that again only ENTER is required to select the "most likely" one, whatever that means.

GOSC is a good idea. Do you have the time to write a project specification for it?

Lachlan Andrew <lachlan>
Project Member
Wed 17 Feb 2016 03:52:04 PM UTC, comment #5:

i was curious. a few trials did not produce the 'did you mean' response until the command had >=5 characters. Arcsin(1) did suggest asin(1),but arcsec(1) didn't suggest asec(1).

Regarding multiple possibilities, various misspellings of interp, interp1, interp2, interpn, etc., failed to invoke the 'did you mean'.

so I'm guessing there's just a lookup table involved with frequent misspellings. (maybe matlab logs and reports back such things?). But, this is one of those areas where Octave isn't bounded by Matlab behavior, so it could be an interesting area for improvement.

For how to handle things, Matlab immediately places the suggested command on the interpreter line, such that you hit enter and it executes. So that precludes multiple options. I guess you could try presenting the options in a bash tab-completion sort of way (a la the show-all-if-ambiguous option)

This could quickly get quite involved. Maybe it should go on a GSOC project suggestion?

Nicholas Jankowski <nrjank>
Mon 18 Jan 2016 01:20:51 PM UTC, comment #4:

It was asked, what types of "close" should be included.

I think, the Levenstein distance (editdistance as Octave function) is what is needed here. One then could sort all possible suggestions by their Levenstein distance and ommit the suggestions having a to big distance.

Obviously, the 4 points by Lachlan Andrew would be Levenstein with a maximal distance of 1.

Max Görner <maxg>
Thu 14 Jan 2016 04:19:59 AM UTC, comment #3:

Yes, I have been thinking that it would be nice to have something like Matlab's "Did you mean" prompts.

What types of "close" should be included? Possibilities are:
1. one-letter substitution (including digits and underline)
2. one-letter addition
3. one-letter deletion
4. transposition of adjacent letters

We should probably not do this for very short identifiers. Would 4 characters be a suitable minimum?

I assume the reference list would be the list of ~2000 returned by pressing "<TAB>" at the start of a word. Unfortunately, preprocessing couldn't be cached, because that list contains the variables in the current scope, but this is in the slow path anyway.

What should we do if there is more than one replacement? The enthusiastic option would be to prioritise "likely" ones (such as ...our->...or/...ise->...ize, adjacent on the keyboard, vowel-to-vowel replacement). Alternative approaches would be to list all of them, suggest the first one found, or do nothing.

(Although I think this is a great idea, could someone please reduce the severity and priority of this bug?)

Lachlan Andrew <lachlan>
Project Member
Tue 12 Jan 2016 06:54:20 PM UTC, comment #2:

We should not make synonyms, but it is OK to suggest function names that might have been intended.

However, instead of doing this for a specific fixed list of words, it seems to me that it would be better to change the function that handles the undefined symbol error to look for possible existing symbols (variables or functions) that are "close" in spelling.

John W. Eaton <jwe>
Project Administrator
Tue 12 Jan 2016 05:42:45 PM UTC, comment #1:

Example: error: 'rgb2grey' undefined near line 1 column 1. Did you mean 'rgb2gray' (U.S. spelling)?

instead of:

error: 'rgb2grey' undefined near line 1 column 1

R treats the two as synonyms, but obviously that would harm Matlab compatibility. Color/colour might also be useful.

The example is from the "image" package, but applicability is wider.

Anonymous
Tue 12 Jan 2016 05:37:23 PM UTC, original submission:

Could Octave possibly provide a specific error message when the word "grey" is used instead of "gray" in a function name?

Example:

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by nrjank (Posted a comment)
  • -unavailable- added by maxg (Posted a comment)
  • -unavailable- added by lachlan (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 13 Aug 2017 01:52:33 PM UTCjweCategoryOctave Forge Package=>Octave Function
      Summarygrey/gray=>provide hints for possible misspelled symbol names
    Thu 18 Feb 2016 02:59:52 AM UTClachlanSeverity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
      Release4.0.0=>dev

    Back to the top


    Powered by Savane 3.1-cleanup1