Some months ago, I did release a command name rep_sug_arg, and the cli documentation is as followed:
rep_sug_args:
inp,_sep,_return_all_arg={ 0=false | 1=true},0.5>=_int_score_threshold<=3,
arg0,arg1,...
Suggest arguments given input using Damerau-Levenshtein Distance algorithm.
Returns '01e0' on exact match.
Returns '00e0' if no close match is found.
Note: For '00e0' and '01e0'. They're intended to be that way to avoid
conflict with 0 or 1. So, keep in mind these are meant to be treated as
vector to be validated.
Returns suggestion when close matches are found.
Errors when no valid input for argN is found.
Default values: 'sep=','_return_all_arg=1','_int_score_threshold=2'
Why did I implement this? I realized that some commands rely on exact text inputs instead of numbers, and typos are possible. So, making would allow me to implement a feature on commands to allow users to see possible arguments that matches their intended argument. And it feels the commands are more usable when I am seeing suggestions.
However, it turns out, it’s a tricky problem. As you can see, fuzzy matching on +pal shows this?
C:\Windows\System32>gmic +pal aap_radiant
[gmic]./ Start G'MIC interpreter (v.3.7.3).
ERROR: Invalid value 'app_radiant'. No close match found!
pal:
0<="palette_id"<=384 |
*,_name_pals_as_id={ 0=use_full_name | 1=use_id_name }
But, there is a perceptually close match, from the human perspective:
+pal 228 = +pal aap_radiant_xv -- AAP-RadiantXV by Adigun A. Polack
Maybe, the distance of <3 cause this error to show up. But, also, there’s the possibility that my fuzzy matching algorithm needs more refinement.
Also, in this case:
C:\Windows\System32>gmic +pal cga0
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic] *** Error in ./ *** Invalid value 'cga0'. Did you mean one of (case-insensitive): cga,cga10,cga20,cga00,cga01,vga?
You can see that my algorithm works.