Skip to Content

AI-102: How to Use Azure Translator API for Custom Sports News Translation?

Learn how to leverage Azure Translator API to translate sports news into Spanish while preserving key terms like “touchdown” and “slam dunk.” Discover required parameters, optional settings, and best practices for seamless translation.

Table of Contents

Question

Xerigon Corporation is a sports news organization that serves North and Latin America. They are developing a method that uses the Translator API to translate content into Spanish.

The method will receive content from a webpage, and then translate it into Spanish.

Unfortunately, certain English words such as “touchdown” and “slam dunk” do not translate into Spanish, and therefore should not be translated.

You use the following to translate the input:

curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=es&textType=html" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json; charset=UTF-8" -d "[{'Text': <div>The Atlanta Falcons had an improbable last-second win over the Philadelphia Eagles 22-21 on Monday Night Football. Kirk Cousins threw a 13 yard</div>
<div class=\"notranslate”\">touchdown</div><div> to Drake London for the winning score.<div>

In the above code, which parameters are required and which are optional?

Drag the appropriate code to the corresponding category.

Parameters:

  • toScript
  • fromScript
  • textType
  • to
  • from
  • api-version

Answer

Required

  • to
  • api-version

Optional

  • textType
  • from

Explanation

The required parameters are api-version and to. The from and textType parameters are not required.

curl -X POST “https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=es&textType=html” -H “Ocp-Apim-Subscription-Key: <client-secret>” -H “Content-Type: application/json; charset=UTF-8” -d “[{‘Text’: <div>The Atlanta Falcons had an improbable last-second win over the Philadelphia Eagles 22-21 on Monday Night Football. Kirk Cousins threw a 13 yard</div>
<div class=\”notranslate”\”>touchdown</div><div> to Drake London for the winning score.<div>

The api-version parameter specifies the API version requested by the client, which is 3.0 in this scenario, and is required.

The to parameter specifies the language of the output. In this scenario, the text will be converted to Spanish, represented by the Spanish language symbol of es. This is also a required parameter.

The optional parameters listed in the code are from and textType. fromScript and toScript are also optional parameters, but they have not been specified in the code.

curl -X POST “https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=es&textType=html” -H “Ocp-Apim-Subscription-Key: <client-secret>” -H “Content-Type: application/json; charset=UTF-8” -d “[{‘Text’: <div>The Atlanta Falcons had an improbable last-second win over the Philadelphia Eagles 22-21 on Monday Night Football. Kirk Cousins three a 13 yard</div>
<div class=\”notranslate”\”>touchdown</div><div> to Drake London for the winning score.<div>

The from parameter specifies the language of input. In this scenario, the language of the input was English, represented by the symbol for English, en.

The textType parameter uses the value of HTML if the input is from a webpage and plain if it is from a text file.

The fromScript specifies what script will be used for the input.

The toScript specifies what script will be used for the output.

Although neither the fromScript nor the toScript parameters were used in the code, the following example translates the text “Hello, how are you?” from English to Greek (language symbol el), and the text will use the Roman alphabet because of the toScript=Cyrl parameter.

curl -X POST “https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=el&toScript=Cyrl” -H “Ocp-Apim-Subscription-Key: <client-secret>” -H “Content-Type: application/json; charset=UTF-8” -d “[{‘Text’:’Hello, how are you?’}]”

Microsoft Azure AI Engineer Associate AI-102 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Microsoft Azure AI Engineer Associate AI-102 exam and earn Microsoft Azure AI Engineer Associate AI-102 certification.