Site icon BotFlo

Automatic spell correction is available in Dialogflow API v2

2020 Update: It has been a while since I wrote this post. I have also confirmed with clients, and I can say that the autocorrect is now quite reliable. So you should use the feature, but remember that you don’t get the original query with the typo in the History and Training.

Recently, Dialogflow made an important improvement to their service. They provide automatic spelling correction if there are typos in the user’s message.

How to enable the feature

First, make sure you are using an agent which is on API v2.

Next, go to Settings > ML Settings and enable the Automatic Spell correction toggle.

How it works

So let us take a look at how well it works.

Regular (non-entity) words

Example 1: I introduce a typo in the Dialogflow simulator for a regular (non-entity) word.

And Dialogflow is able to correct the spelling and produce the expected result.

Entity values

Can Dialogflow help with spell correction of entity values too? Apparently, it can, but I found the behavior a little unpredictable.

Here is the entity element:

Example 2: Here, I introduce a typo in the word Carbon.

Which isn’t identified:

Example 3: Then I introduced another typo:

Which is corrected:

Should you start using the feature?

Personally, I am not sure if it is ready for production use.

Specifically, here are my concerns:

The entity autocorrect is not predictable

As you have seen above, it seems like there are some cases where the entity value is automatically corrected to the right spelling. But it doesn’t happen always, and the rules for when the spell correction gets triggered isn’t apparent.

There is no way to know if spell correction happened

It would be super useful to have a true/false value which specifies if some spell correction did happen.

In the best case, Dialogflow was correct, and you would still want to find out the mis-spelling, say if you want to add it to your own internal knowledge base or internal search engine. In the worst case, Dialogflow made a mistake and you can use it to decide if you want to turn the feature on/keep it turned on.

Even if the autocorrect feature isn’t turned on, Dialogflow can successfully map the intent on certain kinds of typos already (you can go and check this for yourself by omitting a vowel from a long-ish word). So having this data available will allow the developer to distinguish between the following scenarios:

It is possible I don’t have the exhaustive set of scenarios covered here, but hopefully you get the picture. Having knowledge of whether any spell correction was done will allow the developer to get a lot more insight into how Dialogflow works.

So my suggestion is to use it for your test agents at the moment, and then turn on the feature in your production bot once you have a good understanding of the overall effect of the spell correction.

Exit mobile version