'Azure cognitive service language detection reports Spanish for input "no"

Submitting a request to the language detection API with input text no

curl --location --request POST 'https://api.cognitive.microsofttranslator.com/detect?api-version=3.0
' \
--header 'Ocp-Apim-Subscription-Key: XXXXXXXXXXXXXXXXXXXX' \
--header 'Content-Type: application/json' \
--data-raw '[
    { "Text": "no" }
]'

Returns the following response:

[
    {
        "language": "es",
        "score": 1.0,
        "isTranslationSupported": true,
        "isTransliterationSupported": false
    }
]

Other services detect that there is some nuance here:

{
  "data": {
    "detections": [
      {
        "language": "en",
        "isReliable": true,
        "confidence": 1.6
      },
      {
        "language": "es",
        "isReliable": false,
        "confidence": 1.6
      },
      {
        "language": "pt",
        "isReliable": false,
        "confidence": 1.6
      }
    ]
  }
}

Is there any way to modify the request, or to create a custom translator resource which can return multiple detected languages and allow the client to choose?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source