Penalties in the Translation Provider API

I have a working MT engine plugin developed against the Translation Provider API. It's working in Trados 2017 and Trados 2019. I'm encountering the problem below in Trados 2017 (it may occur in 2019, haven't tried yet).

I would like to apply a penalty to the output of the MT engine. In "Project Settings" -> "Language Pairs" -> "Translation Memory and Automated Translation", I add a penalty setting. However, it's ignored when the engine populates an output segment in the editor view; the score is whatever score is set in the code in the language direction:

            int score = 90;
            tu.Origin = TranslationUnitOrigin.MachineTranslation;


            SearchResult searchResult = new SearchResult(tu);
            searchResult.ScoringResult = new ScoringResult();
            searchResult.ScoringResult.BaseScore = score;

There are two properties in the translation provider that look like they'd be useful:

public bool SupportsPenalties
{
    get { return false; }
}

public bool SupportsScoring

{
    get { return false; }
}

However, changing these values to true makes no difference whatsoever.

What's the proper way to have penalties for MT engines accounted for?

Thanks in advance.

Parents
  • Hi ,

    On our Github SdlCommunity public repository https://github.com/sdl/Sdl-Community, we have 2 providers: ETS and BeGlobal where the base score is setup from the code behind, as in your situation (see below print screen) 

    In this case, even though you change the value from the "Project Settings" -> "Language Pairs" -> "Translation Memory and Automated Translation" grid, the score which was setup in the code will be taken into consideration.

    Example: In the previews code print screen, you can see the score is set to 25, now I am changing the penalty to 10 in "Project Settings" -> "Language Pairs" -> "Translation Memory and Automated Translation" grid, and the search results will still work based on the score 25. (see below)

    After the search results are displayed:

    I suppose in your case, the penalty setup is missing , you can check in this API documentation http://producthelp.sdl.com/SDK/TranslationMemoryApi/4.0/html/9f65aced-c266-485d-bc6a-cb1973f8b0cc.htm. The below code is taken from documentation, and each side of the code is well explained. 

    Please let me know if the above suggestion helped you.

    With kind regards,

    Florentina Caputa

    With kind regards,

    Florentina Caputa

  • I did miss that bit from the API, so thanks for pointing that out. This helps, but not completely. Why is the penalty specified in the UI not applied? In other words, in the example you show, your base score is 25, and the UI penalty is 10; why is the score of the translated element not 15?

  • Did you try to check the settings from the project, if the penalty setup in the UI is identified on one of the setting group, like:

    private void UpdateProjectTMSettings(FileBasedProject project)
    {
          var settings = project.GetSettings();
          var tmSettings = settings.GetSettingsGroup<TranslationMemorySettings>();
          tmSettings.MultipleTranslationsPenalty.Value = 10;
          tmSettings.MissingFormattingPenalty.Value = 0;
          tmSettings.DifferentFormattingPenalty.Value = 0; 
          tmSettings.AutoLocalizationPenalty.Value = 0;
          tmSettings.TextReplacementPenalty.Value = 0;
          tmSettings.TranslationMaximumResults.Value = 99;

    project.UpdateSettings(settings);
    }

    In the above method, the translation memory penalties settings  are setup based on user's situation.

    With kind regards,

    Florentina Caputa

  • Clearly, there's something fundamental I'm missing here.

    First, it seems like you're suggesting that Trados doesn't apply a penalty automatically to the output of the score that comes out of CreateSearchResult or its equivalent. Is this correct? If so, I'm curious about why; it seems to me that if you specify a penalty via the UI, the computation of the final score should be Trados' responsibility, not the responsibility of the plugin. What am I missing here?

    Second, you seem to be suggesting that  if I can get a reference to the project object, I should be able to extract the settings that have been set in the UI. Is this correct?

    Finally, I don't understand how to access the project object. I've traced through the translation provider API, and it doesn't seem to give you access to the project object anywhere: not in the Browse() or Edit() methods, and not in the segment translation methods. So if I need to access the project object to retrieve the settings to compute the score, how do I access the project object?

    Thanks for your attention.

  • OK, I think I've answered part of my own question: the SearchSettings are passed in to the translation function, which I somehow missed. So I don't need to access the project object. So I can definitely apply the penalties by hand. But why do I have to? It seems like the ProviderPenalty ought to be applied automatically by the framework.

    If you have an answer for that, it would be great. Otherwise, thanks for your help.

Reply Children