Azure AI Translator API - Example Code

Azure AI Translator API

Question

Review the code snippet given below and complete it by choosing the correct base URL for the translator using the global translator resource

curl -X POST "https://………………………………………………………………...?api-version=3.0&to=es" \  -H "Ocp-Apim-Subscription-Key:<your-key>" \  -H "Content-Type: application/json" \  -d "[{'Text':'<sample text>'}]" 

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: A.

Option A is correct.

The objective is to use a translator service using a global endpoint.

Here is the completed code snippet:

&lt;pre&gt;curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&amp;amp;to=es" \

-H "Ocp-Apim-Subscription-Key:&amp;lt;your-key&amp;gt;" \

-H "Content-Type: application/json" \

-d "[{'Text':'Hello, what is your name?'}]"

&lt;/pre&gt;

Option B is incorrect because “api-nam.cognitive.microsofttranslator.com” is the endpoint for the North American region.

Option C is incorrect because the objective is to translate, not just to detect the language in the &amp;lt;sample text&amp;gt;.

Option D is incorrect because “api-nam.cognitive.microsofttranslator.com” is the endpoint for the North American region.

Reference:

To learn more about the translator, use the link given below:

The given code snippet is an example of using the Microsoft Azure Cognitive Services Translator API to translate text from one language to another. The base URL for the translator API is missing in the code, and the task is to choose the correct URL for the global translator resource.

The correct answer is A. api.cognitive.microsofttranslator.com/translate.

Explanation: The Microsoft Azure Cognitive Services Translator API provides machine translation capabilities for text in various languages. The base URL for the global translator resource is api.cognitive.microsofttranslator.com. The endpoint "/translate" should be added to the base URL to access the translation functionality.

Option B (api-nam.cognitive.microsofttranslator.com/detect) is incorrect because the "detect" endpoint is used to identify the language of the input text, not to perform translation.

Option C (api.cognitive.microsofttranslator.com/detect) is also incorrect for the same reason as option B.

Option D (api-nam.cognitive.microsofttranslator.com/translate) is incorrect because "nam" indicates that this is a North America-specific endpoint. However, the question asks for the base URL for the global translator resource, which is not region-specific.

Therefore, the correct answer is A. api.cognitive.microsofttranslator.com/translate.