-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: FuzzyMatch should only search trough commands related to the incoming update #18
Comments
Another possible solution would be to return all commands that are pass the selected similarity threshold, with their respective language scope. But it could still happen that the best result is not the one for the end-user lang, but at least the dev-user could chose to return the whole list with their scopes, or depending on the user scope return the matching command |
Maybe we should return the |
I don't think that's the way, since that would require for them to resolve all the logic for knowing which is the localized/default version of the command that is needed to be shown to the end-user, specially if the return of I think in this case it's good to abstract. I'll write the tests for illustrating the problem. Since as of right now, collisions (in the sense that the shown command it's not from the user lang) could happen not only between localized names that are part from the same command class, but also from ones from different command classes. I think there are multiple approaches to solve the problem:
Since this is functionality it's, mostly, a sprinkle to the plugin, a very sweet one tho, I think it's not a bad idea to go with the 3rd option, it's simple and should be okay most of the time. 2nd option it's the most "accurate" for the user experience, but the edge case scenario might be not worth the hassle |
Test's that illustrate the in-class collision problem @roziscoding commands/test/jaroWrinkler.test.ts Lines 82 to 127 in ed90dd4
Test's that illustrate the between-class collision problem commands/test/jaroWrinkler.test.ts Lines 128 to 157 in ed90dd4
|
What about going with the third option, but also allowing the dev to decide if they want to consider all commands or only ones from the current scope? By default, it'd match against localized commands only, or default if the user's locale is not found within a command. Then something like |
I merged the test's into the PoC branch. They are passing.
That's how I initially impemented it :P
I'm on it. Surprisingly, doing the opt-out it's gonna take me some time to do in a more cute fashion, because rn it's a bit too (badly) coupled, but I'll do it right one of this days. Edit: a working version is at improveFuzzyMatch, it's super ugly code, but I added multiple test's that ensure the desired functionality, please check out those when you have time. I'll like to add the feat to compare between commands classes via an overload, should I add it to the same branch? |
Signed-off-by: Hero Protagonist <heroprotagonist32@gmail.com>
Signed-off-by: Hero Protagonist <heroprotagonist32@gmail.com>
Signed-off-by: Hero Protagonist <heroprotagonist32@gmail.com>
Signed-off-by: Hero Protagonist <heroprotagonist32@gmail.com>
Right now fuzzyMatch is searching trough all localized and non-localized versions of the commands.
Example mimicking the inner workings of the fuzzyMatch:
returns:
This is important since
fuzzyMatch
could have matched against a localized/default command version that it's not relevant to the user lang, in other words, returned another foreign local of the command, in any case, one that the end-user is not seeing from the commands menu.It's basically a collision problem.
A more appropriate search would be to filter only trough the respective
ctx.from?.language.scope
and opt-out for search-in-all instead.Must work when no localization exist for a command.
Same thing could be said for the
botCommandScope
, but that might be irrelevant.Edit: I have a PoC branch at improveFuzzySearch f782af6 but it's a little bit of a mess. I think I coupled it too much with the changes exposing the prefix (that's needed for correctly recommend the command + it's respective prefix).
Do:
from.language.scope
it's in IETF language tag, should add a function to assert when it's ISO-639, or convert when possible to ISO-639, if not, fallback to "default". Depends on add languageCode type types#45 approvalThe text was updated successfully, but these errors were encountered: