How to call bing spell check API from qnA knowledge base to correct the user typos

Lucia Casucci 36 Reputation points Microsoft Employee
2021-08-27T19:55:59.367+00:00

Hello!

I am trying to build a bot from a qNa service in Azure.
I would like to implement some type of spell check of the user to make sure a wrong typed word will still lead the user to what they are trying to find.
From my research I saw that bing spell check could be a possible solution.
However, while it seems pretty straighforward to implement into a LUIS , I do not see an easy way to implement it in the qnA knowledgebase.

What is the best practice to achieve this? I am not an expert coder and the only documentation to send a post request to the bing API that I was able to find was just few lines out code that were not helpful, especially since the bot source code has a ton of sub files.

Any help is appreciated, and if the bing spell check is too advanced, I would also appreciate some work around alternatives.

Bing Spell Check
Bing Spell Check
A Bing service that detects and corrects spelling mistakes in your app.
30 questions
Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
752 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,413 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. YutongTie-MSFT 46,991 Reputation points
    2021-08-29T09:19:58.763+00:00

    Hello,

    Hope you have seen this document for how to integrate it will QnA maker. https://learn.microsoft.com/en-us/azure/cognitive-services/luis/luis-tutorial-bing-spellcheck

    Then You can do this with Dispatch Bot. When you get the results back from the recognizer, there will be an alteredText value if spell check made a correction. What you're wanting to do is replace the original text with this new value.

    const recognizerResult = await this.dispatchRecognizer.recognize(context);
    if (recognizerResult.alteredText) {
    context.activity.text = recognizerResult.alteredText;
    }

    <code to select intent>

    var processResult = await this.qnaDialog.processAsync(userDialog.qnaState, context.activity)

    QnA Maker should now receive the query with the altered text. Try to modify context.activity.text and removed or @ mentions from Teams, which were affecting intent identification and QnA answers.

    Regards,
    Yutong

    0 comments No comments

  2. Lucia Casucci 36 Reputation points Microsoft Employee
    2021-08-31T19:47:43.417+00:00

    @YutongTie-MSFT - Thank you in advance!

    I did not configure LUIS from scratch since I had a lot of documents to extract questions from and it would have been too long to type every entry in the intent and utterances. That file link seems to be more effective in the case i started right from LUIS, not the QnA.

    What I am not sure, do I need to add that code snippet in the QnA.cs bot file?
    Also, how do I connect the bing service to it, do I need to embed the API key and endpoint somewhere in the QnA service?

    0 comments No comments