0
votes

I'm trying to setup a Custom Translator with a Phrase Dictionary for my company. I followed the official documentation and this tutorial: https://soltisweb.com/blog/detail/2019-08-13-using-a-custom-translator-with-azure-co.

When I translate it seems that it's not using my custom model, here is my setup:

1 Azure Translator:

  • Location: Global
  • Pricing Tier: S1

1 Worspace in Custom Translator, connected to the Azure Translator above:

  • Subscription name: ****
  • Subscription type: TextTranslation
  • Pricing tier: S1
  • Subscription region: Global

I've created one project:

  • Category: Global
  • Language Pair: English - Spanish

I uploaded the same Phrase Dictionary as in the tutorial (Phrase Dictionary):

EN ES
one uno
two dos
three tres
four cuatro
five cinco
six seis
seven siete
eight ocho
nine nueve
ten diez
hi hola
hello buenos dias

I've generated a model and deployed it everywhere (America, Europe, Asia) without any error.

I've tried to translate "hello" with the following C# code:

                // Input and output languages are defined as parameters.
            string route = "/translate?api-version=3.0&category=*MyWorkspaceId*-GENERAL&from=en&to=es&allowFallback=true";
            string textToTranslate = "hello";
            object[] body = new object[] { new { Text = textToTranslate } };
            var requestBody = JsonConvert.SerializeObject(body);

            using (var client = new HttpClient())
            using (var request = new HttpRequestMessage())
            {
                // Build the request.
                request.Method = HttpMethod.Post;
                request.RequestUri = new Uri("https://api.cognitive.microsofttranslator.com/" + route);
                request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
                request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
                request.Headers.Add("Ocp-Apim-Subscription-Region", "global");

                // Send the request and get response.
                HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);
                // Read response as a string.
                string result = await response.Content.ReadAsStringAsync();
                Console.WriteLine(result);
            }

The result is:

[{"translations":[{"text":"Hola","to":"es"}]}]

The result should be "buenos dias".

I might be missing something really basic... I already tried to re-create everything from scratch with no success.

Update 1

Switched allowFallback=true to allowFallback=false.

{Method: POST, RequestUri: 'https://api.cognitive.microsofttranslator.com//translate?api-version=3.0&category=***-GENERAL&from=en&to=es&allowFallback=false',
 Version: 1.1,
 Content: System.Net.Http.StringContent,
 Headers:
{
  Ocp-Apim-Subscription-Key: ***
  Ocp-Apim-Subscription-Region: global
  Content-Type: application/json; charset=utf-8
}}

Input:

"one, two, three, four, five, six, seven, eight, nine, ten, hi, hello, My name is Doe."

Ouput:

[{"translations":[{"text":"uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve, diez, hola, hola, Mi nombre es Doe.","to":"es"}]}]

Thanks for your support, Cyril

2
Hi, have you tried other words, are you only getting incorrect results for the word "hello", can you share results for other words as well?GiftA-MSFT
Yes, in "one, two, three, four, five, six, seven, eight, nine, ten, hi, hello, My name is Doe." out "uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve, diez, hola, hola, Mi nombre es Doe." but my goal is to be able to apply custom translation.Cyril Lacroix
We're reviewing your feedback and will get back to you soon. Thanks.GiftA-MSFT

2 Answers

1
votes

We rolled out a hot fix. Issue should be resolved now. Sorry for the inconvenience.

0
votes

There is a possibility you are not hitting your custom model. So, let's first make small change to your API call.

&allowFallback=false to ensure if you don't hit your custom model, the call would fail instead of getting served from our standard model.

Best, Mohamed