How to I account for wrong spellings in chat bot

Hi, How can I account for user typos, mis-spelt words while taking in the user input. For example I want my bot to know that achievemnt , achievemnet, achievement, acheivement etc all mean the same? Is giving all these possible values in nlu.md the only solution?

Thank you, Shruti

It depends on two levels

First - are the mistakes to your spelling related to entities, in that case you will need entity synonyms of most likely mistakes Second- if the mistakes are likely to determine the intent, you can simply add such examples to the NLU

There is another way is to add a spell checker in the pre-processing step of rasa core

you can pass a preprocessor that takes the incoming sentence from the user and corrects any possible mistakes in the sentence.

You can also add a browser level spelling correction by adding suggestions when the user is typing a message.

2 Likes

Hi Souvik,

Thank you for the detailed response. You mentioned-

"There is another way is to add a spell checker in the pre-processing step of rasa core

you can pass a preprocessor that takes the incoming sentence from the user and corrects any possible mistakes in the sentence."

I think my use-case requires the above kind of solution. Could you please elaborate a bit? As in where and what kind of changes do I need to make to the code? If you code point me to any code snippet, that would be great!

Thank you once again, Shruti

1 Like

did you find any solution for this

1 Like

A bit late (actually quite a lot) but I think you can run a custom action after every user message(this would be covered by the stories you write) where you can implement that preprocessing step and pass the user uttered message.

Here, you can correct that message using your preprocessing logic and continue.

@nikhilcss97 I think this is the wrong approach, because that custom action would be run after the nlu and would also clutter your stories alot.

I actually build a spell-checking component for a chatbot (not using rasa) once, using language tool which grabbed the user message directly from the front-end and forwarded the corrected message to the back-end.
I ended up with a lot of false-positives, where correct words got changed to rubbish. Apart from that spell-checking is a fairly costly operation and will slow down response times quite a bit.

So my recommendation is to not invest much time into spell-checking and rather implement robust fallbacks for your dialogue in case things were spelled wrong.

The only thing I would take into correction are spelling suggestions in your front-end as @souvikg10 recommended.

1 Like

I would agree that this is a wrong approach. This thread has more appropriate strategy. Currently as it seems you would plug in a Custom NLU Pipeline component.

The real question is: has ANYONE successfully plugged in/registered a custom pipeline component into Rasa?

The answer to my own question above is: yes :crazy_face: