[FREE] Dictionary for Voice assistant

At the request of one of the forum participants, I made a dictionary for dialogue with a voice assistant or chatbot.
The dictionary is loaded from a text file with the following contents:
Question1 # Answer1.1 | Answer1.2 … | Answer 1.N ;
Question2 # Answer2.1 | Answer2.2 … | Answer 2.N ;
………………………………………………………………………………………
QuestionN # AnswerN.1 | AnswerN.2 … | Answer N.N
‘#’,’|’,’;’ separators are required.
If the phrase from the question is contained in the dictionary, a random answer will be returned. Responses will not be repeated until all possible answers are returned.
If the dictionary has only one answer to a question, then this will function too.
Line feeds are ignored. The user can split the lines as he sees fit.
Of course, the same results can be achieved by standard means. My extension just makes it more convenient.

The method:
LoadFromFile
allows you to load a dictionary from a text file. The rules for the file path are the same as for the standard File module
New method in V2:
Load from string
Allows you to load the dictionary as a text string obtained by any means. This also raises the LoadingComplete event.
The event:
LoadingComplete
occurs after the word is fully loaded. If the dictionary did not contain errors, then the result = true .
The method:
GetRandomAnswer
returns one of the answers if the question is in the dictionary.
If the dictionary says “what is your first name what is your name # ……”, that method will give answers to the both question “what is your first name” and “what is your name". However, if the dictionary says only “what is your first name # ……”, and you ask “what is your name”, the method will answer with an empty string. Be careful when compiling a dictionary.
The question character ‘?’ can be used at your discretion. It is understood that a speech recognition system does not add a ‘?’ character at the end of a question sentence, unless you ask for it.

Text example:

hellow # Hi! | good afternoon | Do we know each other? | Hi, my name is Eva;
how are you # thanks, I’m fine | perfectly! | I was fine until you asked me about it;
do you love me # I love you | I would go to the cinema with you | Do not tell me about love!

Version 1: ScDictionaryV1.aix (17.6 KB)
Current Version 2:ScDictionaryV2.aix (17.9 KB)

23 Likes

Very cool extension. That will help us to create chat bot easily. We have to load always from file manazer.we have no others option to load dictionary

3 Likes

Maybe I need to add a manual dictionary edit.

1 Like

This post was flagged by the community and is temporarily hidden.

Google Translate:

Good day Contact off topic, do not scold :slight_smile: ScorpioNormal, you get the extensions you need. Maybe you can make a convenient extension for transforming a number from HEX to DEC indicating the digit capacity of the number to be translated? Using standard mathematical tools, this procedure takes too many blocks. It would be great if you just set the value and bit width and get a number … Once again litter for being out of topic.

1 Like

Please post in English from next time. Other languages are not allowed.

Пожалуйста, пишите на английском в следующий раз. Другие языки не допускаются.

1 Like

Is the Basic Number Block unsuitable?

1 Like

Hello, could you help me understand how to link the text file

To read from a specific file on the SD card (for example, /myFile.txt will read the file /sdcard/myFile.txt ). To read assets packaged with an application (also works for the Companion) start the fileName with // (two slashes). If a fileName does not start with a slash, it will be read from the application’s private storage (for packaged apps) and from /sdcard/AppInventor/data for the Companion.

2 Likes

is it possible to get that file from the server? (means can we use server file path instead of the local file path. )So we don’t need to update our app. We can directly update our questions and answers in the text file.
Thank You

2 Likes

yeah it would be really helpful

Hi ! I’m trying to test your extension as simply as possible, but it doesn’t work. Can you tell me what mistake I’m making?

Button 1 allows me to retrieve the assistant.txt file, and it works because I have “true” in return.

Here are the captures:



Hey! Try writing key phrases in a text file in lower case (no capital letters at the beginning).
Last | at the end of the text is not necessary

Just remove comma from your lines see if it works

The comma is not important. I don’t remember if I did an automatic lowercase translation of key phrases. This should be checked.

Okay, that’s good because of the capital letters. Too bad, there is no possibility of having capital letters at the beginning of the sentence, or for proper nouns?

I’ll fix it.
But, this only applies to key phrases in a text file. During dialogue, you can use upper case.

how are you ?# thanks, I’m fine…

later:

how are you ? = How are you ? = How are you = how are You

1 Like

Made in version 2.

Also added a method to load a dictionary from a string variable.
Thus, you can update from dictionary located in the cloud storage using Kodular methods or third-party extensions.

2 Likes

thanks buddy for the update