octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: option for enabling/disabling auto-suggest feature


From: Sudeepam Pandey
Subject: Re: option for enabling/disabling auto-suggest feature
Date: Tue, 1 May 2018 01:27:30 +0530



On Fri, Apr 27, 2018 at 3:13 AM, Nicholas Jankowski <address@hidden> wrote:
On Thu, Apr 26, 2018 at 4:46 PM, Sudeepam Pandey <address@hidden> wrote:




Yes, I'll make sure that the auto-suggest feature has an easy enable/disable option. Maybe something like a command/ shortcut key to disable/enable the feature.

How may depend on how you implement it. if you made it strictly a GUI popup, then a GUI switch could make sense. if it will be inline with the interpreter, then it needs to be functional for --no-gui users. a shortcut key may be too dependent on your terminal of choice. So a command similar to 'more on' 'more off' may be the simplest and most portable. As per my message in the other thread, you should review how others have done it before.

Okay, so I was looking at some implementations of suggestion feature. I examined the suggestion feature of git, mercurial, and gcc. Most thoroughly, the one of git. I have also seen how MATLAB displays suggestions (the result that is, not the code). My research is ongoing but here are some initial observations.

- The most common algorithm for finding which words to suggest seems to be edit distance.
- I haven't figured out how gcc and hg turn on/ turn off this feature yet, but here is how git does it...

...when git realizes that the user has entered a command which it does not recognize, it pops up a 'did you mean' suggestion which has been calculated based on the edit distance algorithm. By default, it simply pops out a did you mean suggestion and does nothing more...git can however be customized to execute the suggested command directly after some time delay which can be defined using the help.autocorrect <time> command. Here is an example...

>address@hidden ~/Desktop/test $ git status                            # Output with correct spelling.
On branch master
nothing to commit, working directory clean

>address@hidden ~/Desktop/test $ git statsus                          # Default output when incorrect spelling of the command is entered.
git: 'statsus' is not a git command. See 'git --help'.
Did you mean this?
    status

>address@hidden ~/Desktop/test $ git config --global help.autocorrect 20      # Changing the default setting

>address@hidden ~/Desktop/test $ git statsus                          # Time after which execution of the suggested command occurs = 2 sec
WARNING: You called a Git command named 'statsus', which does not exist.
Continuing under the assumption that you meant 'status'
in 2.0 seconds automatically...
On branch master
nothing to commit, working directory clean

>address@hidden ~/Desktop/test $ git config --global help.autocorrect 30      # Changing the default setting

>address@hidden ~/Desktop/test $ git statsus                         # Time after which execution of the suggested command occurs = 3 sec
WARNING: You called a Git command named 'statsus', which does not exist.
Continuing under the assumption that you meant 'status'
in 3.0 seconds automatically...
On branch master
nothing to commit, working directory clean

>address@hidden ~/Desktop/test $

I strongly suggest that we implement some command to enable/disable the feature but do not add auto-execute like git...

Although I am still doing my research, here are my initial suggestions (based on some research and the discussions so far) about what the command line suggestion feature should be like....

1) The command line suggestion feature is triggered, whenever the interpreter realizes that it has to throw a...
   - "error: '<typo>' undefined near..." error
   - "error: set: unknown <axes/line etc..> property <property name>" error
   - others? (suggestions welcome)

I don't think that looking at other softwares to see when their suggestion features are triggered would be very useful because the errors and structures of all softwares are different after-all. The essence however, for every software, probably is that the compiler/interpreter of the software doesn't understand the meaning of a particular identifier that it has encountered. Therefore, I believe, that the errors we are looking for are the kind of errors where octave interpreter realizes that it doesn't understand what a particular word that the user has written means (and hence, is most probably a typo). The two errors mentioned above probably cover most of the cases. If anyone thinks that they do not, please suggest.

2) Immediately after the aforementioned errors are thrown, a script (say didYouMean) is called with the misspelled function/property name/ keyword... etc...

Note 1: This would require adding a small piece of code to the main file that generates these error messages on the command window. Can anyone help me figure out what files these are?

Note 2: To add a on/off feature. This script should be callable from the command window, with a simple flag value (0/1) to (turn off/turn on) this feature. I am not very sure about this but I suppose that if the on/off feature is implemented in this way, then it would not require separate implementations for GUI and CLI. The flag value will be permanent and can only be changed by calling the script with the appropriate argument from the command window.

3) If the flag value is 0 then further execution of the script does not take place and nothing is printed on the octave command window. User can continue with whatever they were doing.

4) If the flag value was 1, a separate script is called, which calculates what functions/keywords to suggest based on the edit distance (to begin with), or Neural Networks (at a later stage maybe) or some other better algorithm (if we happen to find one). This algorithm should have minimum speed-accuracy trade-off. Since the algorithm will be written down in a separate script, it should be easier to modify later on as technology evolves.

4) The suggestion(s) are returned to the previous script (didYouMean) in the form of a list (in an array that is). Let the array that stores the suggestions be named 'suggestions' The script then generates something like this on the command window...

ex: say the particular misspelled word was 'akuse'

>> akuse
>> error: 'akuse' undefined near line 1 column 1
Did you mean any of the following...
1) amuse
2) abuse
3) amused
Enter the corresponding number to execute the command...
>>1 #say user enters 1

5) The user types 1 and presses enter...didYouMean execute the command corresponding to suggestions(1).

Note: Since all the aspects of the suggestion feature will be governed by this separate script (didYouMean), it can also be modified later, very easily if required.

Please add in your suggestions, if the idea seems fine, then I can start looking at the code...

P Sudeepam.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]