F
F
frzq2020-08-27 10:35:24
Algorithms
frzq, 2020-08-27 10:35:24

Algorithm for searching for matches of phrases in dictionaries. How to efficiently find what the user meant?

Inputs:
Vocabulary A - agreement phrases (yes / sure / please, etc.)
Vocabulary B - disagreement phrases (no / don't need it, etc.)
Vocabulary C - busy phrases (no time, I'm busy, please later and etc.)
Vocabulary D - repeat phrases (repeat, misheard, etc.)

The dictionary is stored in XML in the appropriate tags. Now the algorithm loads the XML and when the input is a phrase such as "Please later" it will return a match from dictionary A, because there is a phrase "please" there, but it should have been from dictionary C. In other words, it returns the first match of a word from a phrase. I see a way out of the situation by counting the number of characters in the phrase that came to the input and in the detected matches and return the one that has more characters, but then the dictionaries have to grow indefinitely. They literally should have a maximum of phrases.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2020-08-27
@frzq

Look for all suitable options, assign them a weight depending on how complete the match with the phrase is. Then choose one by weight. Ideally, previous messages can also influence the weight.

R
Ruslan., 2020-08-27
@LaRN

There is no simple solution.
Here is a good article, perhaps it will show you the way to solve the problem.
https://m.habr.com/ru/post/341148/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question