Reputation: 887
I am building my first agent with DialogFlow, and the intent page has the entry for training phrases. I am testing with a simple intent "greeting". With normal, properly spelled words works just fine, e.g.
Now, if I run DetectIntentText with words like "Hellooooooooo" (9 o's) ... the detected intent gives the Default Fallback intent. So if I add "Hellooooooooo" (with exactly 9 o's) to the training phrases, then the intent is "greeting". But then if I test it with Helloooo (4 o's) the intent given is the Default Fallback intent again ...
I can't predict how many o's the user will put, and it will be cumbersome to add in the training phrases all combinations (e.g. Helloooo, Heeellooooo, etc. etc.). With all the slang going around, and people typing pretty fast, what is the recommended approach? spell check / correct it before sending it to the Dialogflow API? Wouldn't the DialogFlow API catch these?
Thanks!
Upvotes: 0
Views: 1359
Reputation: 376
As you've mentioned, you'd need to check spelling before sending the request. Your example can work.
Regarding training phrases, the more phrases you add, the more training the agent has to get the context from certain user inputs.
For example, if you had "hello" or "hi" as some of your training phrases, you could send "hey" (not in your training phrases) as request and the intent will still be matched.
However, this only works with phrase context and doesn't by-pass spelling errors. For example, "helloo" wouldn't match that intent. So it's still necessary to check spelling before sending the request.
Alternatively, you could turn on automatic spell correction on the agent’s ML settings.
Warnings and best practices about automatic spell correction:
Upvotes: 1
Reputation: 887
Found out that DialogFlow does not handle typos, it is recommended to do spelling check before sending it to the API.
So in my specific case, what I can do is:
word = re.sub(r"(\w)\1*", r'\1', 'heelloooo')
import pyspellchecker
from spellchecker import SpellChecker
spell = SpellChecker()
corrected = spell.correction(word)
What do you think?
Upvotes: 0