Is it possible for the translate api to return null or an error if no result was found?

shawn-6424 46 Reputation points
2020-12-31T00:01:49.557+00:00

When using the following api to translate from English to Swedish

https://api.cognitive.microsofttranslator.com/translate/?api-version=3.0&from=en&to=sv

with the body containing a gibberishing, non-existing word:

[

     {
    "Text":"aksjdfl;kasjdf;lkjas;fljsad;kfj"
    }
]

i am given back the same text as the reponse

[
    {
        "translations": [
            {
                "text": "aksjdfl;kasjdf;lkjas;fljsad;kfj",
                "to": "sv"
            }
        ]
    }
]

This, imo, should NOT return anything, since this is not a real word; the same should happen to a real word when there is no translation found.

How, if even possible, can I get a request to return a null or empty response if no valid result was found?

Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
462 questions
0 comments No comments
{count} votes

Accepted answer
  1. YutongTie-MSFT 53,941 Reputation points
    2021-06-08T02:09:27.223+00:00

    I am sorry for the late response again. After several discussion and research, just got the confirmation from product team: "Since there are several scenarios where user provided words aren’t seen by machine translation and make sense to return the words as in source, there is no current plan to change the style. The service can’t determine what’s correct / incorrect word. Hence, filtering at service level will lead to more issues. Such options aren’t provided by other leading players in market as well." For example, a special name.

    I am still tracking this feedback to see anything else we can do to optimize the experience.

    But I do find a solution may help your scenario, you could call spell check API first, fix the source text and make translate request. In this situation, we can avoid the wrong word and make sure there is no error.

    Hope this help.

    Regards,
    Yutong

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,941 Reputation points
    2020-12-31T00:13:24.127+00:00

    Thanks for your product feedback, I will forward this idea to product group to review.

    For now I don't think there is a way for this API to return error message/ nothing. At the meantime, I can understand this is for when you try to translate one sentence / one paragraph/ whole article which contains special word. But it should have a way to return error if you want. Will check with product team and let you know.

    Regards,
    Yutong

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.