Skip to content
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

A faster way to look up for a knowledge in a user's input? #16

Open
nuttyartist opened this issue Jan 2, 2020 · 1 comment
Open

A faster way to look up for a knowledge in a user's input? #16

nuttyartist opened this issue Jan 2, 2020 · 1 comment

Comments

@nuttyartist
Copy link
Owner

Rather than compiling for all possible element + key variations and then trying to match it to the user input, doesn't it make more sense to cut the user input and look up at a hash table for the right knowledge data? It should be much faster.

Current way:

Currently, we're going through all possible keys of a knowledge ([websites], for example) and pushing their respective element_plus_key to words_with_knowledge.

command: open [webssites] please
input: open new york times please

[websites]:

reddit: https:://
twitter: https:://
facebook: https:://
new york times: https:://

words_with_knowledge:

open reddit please
open twitter please
open facebook please
open new york times please

This method then compares every item in words_with_knowledge with the current [NAME] element node. This is not efficient.

The suggested and more efficient method is:

  • if we find brackets ([])
  • Get the respective data from the user input based on the current [NAME] element node by:
  • Matching the string before the start bracket '[' and after the end bracket ']' and taking the string the middle of them. In our example, we need to remove from the user input "open " from the start and " please" from the end of the string.
  • Then using a hash table we check if the string in the middle exists as a key in the knowledge file. In our example, we check if "new york times" exist in the knowledge file.
  • If it does, we push it to the bestMatch ElementPlusKnoeledgeData and continue regularly.
@nuttyartist
Copy link
Owner Author

We need to check carefully if it works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant