Eddiebot: Improve command matching with suggestions

Created on 20 Sep 2020  路  9Comments  路  Source: EddieJaoudeCommunity/EddieBot

@BOLT04 that's a brilliant idea! :100:
Maybe we can do something similar for all commands where, when the prefix matches a valid command, the bot displays a list of valid completions?
For example, for this:
bot
I would expect the bot to list out these two:
bot

_Originally posted by @RaisinTen in https://github.com/EddieJaoudeCommunity/EddieBot/issues/237#issuecomment-695206438_

Let's discuss in the comments possible implementations for this 馃槂. Maybe we can use Regex to find what commands on the command list match the given input by the user 馃.

enhancement

Most helpful comment

I dont think anyone else is doing it @RaisinTen 馃憤

All 9 comments

It's great having you contribute to this project

Feel free to raise an Issue! Welcome to the community :nerd_face:

If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 馃 . Any questions let us know.

oh I love this! We could use a soundex library, something like this (I just google for it, so not necessarily this one) https://www.npmjs.com/package/soundex-code

I was actually thinking of these 2 scenarios:

  • If # commands stay small:

    • A simple brute force match could get the job done, where we pick up the commands that achieve the highest scores. The scores are assigned based on the length of the largest matching prefix.

  • Otherwise, we can use a trie of all the commands _(...smells a bit like overkill lol...)_, where we select all the commands diverging from the last matching node.

What do y'all think? :slightly_smiling_face:

I think all those suggestions are pretty good 馃憤. I think the important thing to do is to abstract this command matching into a different software module/function/class (whatever 馃槄), so that on command.ts this implementation detail is not known.

Imo, this makes it easier to start with a simple implementation, and then if we need something more complex (perhaps for performance reasons or scalability), we can change only one module and implement a trie, for example.

@eddiejaoude about soundex-code, I couldn't figure out how we would use that library. Would it be like soundex('sta') which returns "S300", but how do we get the list of suggestions from that string?

I think the important thing to do is to abstract this command matching into a different software module/function/class

yes 馃憤 , we should try to abstract it away

Would it be like soundex('sta') which returns "S300", but how do we get the list of suggestions from that string

The matching is done by soundex the incoming request with the available soundex values. For example, a command available is help which has a soundex of H123 (I just made that value up), when someone writes the command hlp we would check the soundex coming in against the available ones. If hlp had a soundex of H123 too, we would suggest help (there could be multiple soundex matches). I hope that makes sense, if not I can find a better example

| Word | Soundex (made up examples) |
| :--- | :--- |
| help | H123 |
| hlp | H123 |

@eddiejaoude thank you for the explanation 馃憤, yeah I can imagine an implementation using soundex 馃槂

I think I have a better understanding of EddieBot and the command routing now. Is it okay if I try to implement this feature? :slightly_smiling_face:

I dont think anyone else is doing it @RaisinTen 馃憤

yes @RaisinTen, thank you for your initiative 馃槂. I'll assign it to you 馃憤

Was this page helpful?
0 / 5 - 0 ratings