question

AngelChua-5623 avatar image
0 Votes"
AngelChua-5623 asked romungi-MSFT commented

Bing Spell Check API callout is successful but no flaggedtokens returned when there is new line in the text

My input is this text --- The quick brown fox jumped overd the lazy dog.

I am getting 'overd' as a flagged token on this, thus I know that the request works. However when I add a new line to any part of the text, the callout is still successful but no flagged tokens come back. {"_type": "SpellCheck", "flaggedTokens": []}

Here is how the request is setup --- req.open("GET", this.endpoint + "?mode=proof&mkt=en-US&text=" + encodeURIComponent(textToCheck));

If there is anything else needed in the request to fix this, let me know.

Are there other reasons/causes for the API to run without error but fail to detect misspelling?

azure-bing-spellcheck
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

romungi-MSFT avatar image
0 Votes"
romungi-MSFT answered romungi-MSFT commented

@AngelChua-5623 I have tried the same scenario directly by calling the API via postman and it flags the text correctly that is misspelled. I think you are not getting any suggestions because of the formatting of the text parameter that is passed in your request. Could you print your request and check the parameters that are passed in your call?

180957-image.png



image.png (61.5 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@romungi-MSFT Thanks for looking into this. To clarify, it works fine if the input doesn't have a newline. (See screenshot 1) The problem happens when I add a new line to it. I tried it in Postman like you did, and below is what I got.

To mimic user input, I typed the text in Notepad. I added a newline at the end of the sentence and copy pasted it in Postman. Notice the new line character at the end. (See screenshot 2)

In the code I also tried encoding the text using - encodeURIComponent(text). Then pasted the encoded text input into Postman to check, and still didn't return flagged tokens. (See screenshot 3)

Let me know if there's a proper way to handle newlines. Thanks.

Screenshot 1 - Ok

181196-image.png


Screenshot 2 - Not Ok

181175-image.png


Screenshot 3 - Not Ok

181099-image.png


0 Votes 0 ·
image.png (49.6 KiB)
image.png (38.4 KiB)
image.png (41.6 KiB)

@AngelChua-5623 Yes, the text parameter string may include only valid UTF-8 characters. I think pre-processing the input to remove characters will provide accurate result and you may specify this parameter in the body of a POST request if the string is larger because you may hit the query string limitation.

0 Votes 0 ·