file-based TM upgrade through API?

Hello,

in our project, we create project specific file-based TMs using the FileBasedTranslationMemory class. This works correctly and we are able to populate some segments in it using a standard TM update batch task. Unfortunately in Studio, this TM is marked with an orange triangle, advising to run an upgrade of the TM for better performance and we have just noticed that tokens in the TM are not indexed correctly: when a segment is searched in this file-based TM, a penalty is set when placeables are found in the segment, even if the segment and the TU are strictly identical.

After an upgrade of the TM, the TM search works correctly; there is no more penalty connected to tokens (when segment and TU are identical).

I've looked into the API documentation if there is any function to run an upgrade but I couldn't find any. Can you tell us, how should we proceed to run an upgrade of the file-based TM?

Kind regards

Sébastien

Parents Reply Children
  • Hello Patrick,

    Maybe, I don't understand the API that deep... but in the meantime, my colleague solved the problem with this snippet, and there are indeed FGA functions used in it.

    if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresUpgrade(tm))
    {
        TranslationMemoryUpgradeUtil.UpgradeTranslationMemory(tm);
    }
    if (tm.GetTranslationUnitCount() >= 1000)
    {
        tm.FGASupport = FGASupport.Automatic;
    }
    else
    {
        tm.FGASupport = FGASupport.Off;
    }
    tm.Save();
    
    
    var token = new System.Threading.CancellationTokenSource().Token;
    var progress = new Progress<int>(i => { });
    
    if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresReindex(tm))
    {
        tm.SelectiveReindexTranslationUnits(token, progress);
    }
    if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresModelRebuild(tm))
    {
        tm.BuildModel();
    }
    if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresAlignment(tm))
    {
        tm.AlignTranslationUnits(true, false, token, progress);
    }
    
    if (tm.ShouldRecomputeFuzzyIndexStatistics())
    {
        tm.ClearFuzzyCache();
        tm.RecomputeFuzzyIndexStatistics();
    }
    tm.Save();

    Kind regards

    emoji