DeepLcom/deepl-api-issues

Inconsistent translation results ES->EN

Opened this issue · 0 comments

Hi!
I'm using an api to translate from Spanish to English. I came across an issue where consecutive requests produce different results.
Example:
I use a glossary containing the following entries:

"entries": {
    "ART.": "Art.",
    "F/A": "Tariff Item"
  },

This is how I use api client:

var result = await translator.TranslateTextAsync(text, sourceLanguageCode, targetLanguageCode, new TextTranslateOptions
{
	PreserveFormatting = true,
	SentenceSplittingMode = SentenceSplittingMode.NoNewlines,
	GlossaryId = glossaryId,
	ModelType = ModelType.PreferQualityOptimized,
	Formality = Formality.PreferMore
});

The text I'm trying to translate: F/A ART. 4o

I'm getting next results randomly:

  • Tariff Item 4
  • Tariff Item Art. 4

I whould expect to have Tariff Item Art. 4 result

How to reproduce:

[Test]
public async Task Translate_Should_Succeed()
{
 var translator = new Translator(ApiKey, new TranslatorOptions { ServerUrl = "https://api.deepl.com" });
 var glossaryName = $"Glossary_{Guid.NewGuid()}";
 var glossaryInfo = await translator.CreateGlossaryAsync(
  glossaryName,
  "ES",
  "EN-US",
  new GlossaryEntries(new Dictionary<string, string> { { "ART.", "Art." }, { "F/A", "Tariff Item" } }),
  CancellationToken.None);

 await translator.WaitUntilGlossaryReadyAsync(glossaryInfo.GlossaryId, CancellationToken.None);

 for (int i = 0; i < 10; i++)
 {
  var result = await translator.TranslateTextAsync("F/A ART. 4o", "ES", "EN-US", new TextTranslateOptions
  {
   PreserveFormatting = true,
   SentenceSplittingMode = SentenceSplittingMode.NoNewlines,
   GlossaryId = glossaryInfo.GlossaryId,
   ModelType = ModelType.PreferQualityOptimized,
   Formality = Formality.PreferMore
  });

  Console.WriteLine($"{i}:{result.Text}");
 }
}

This code produces:

0:Tariff Item Art. 4
1:Tariff Item 4
2:Tariff Item Art. 4
3:Tariff Item Art. 4
4:Tariff Item Art. 4
5:Tariff Item 4
6:Tariff Item 4
7:Tariff Item Art. 4
8:Tariff Item Art. 4
9:Tariff Item Art. 4