public void ProcessReindex(BackgroundWorker bw, TranslationMemoryInfo tm) { _reindexStatus.AppendLine(string.Format("Start reindex {0} translation memory", tm.Name)); bw.ReportProgress(0, _reindexStatus.ToString()); var fileBasedTm = new FileBasedTranslationMemory(tm.FilePath); if ((fileBasedTm.Recognizers & BuiltinRecognizers.RecognizeAlphaNumeric) == 0) { fileBasedTm.Recognizers |= BuiltinRecognizers.RecognizeAlphaNumeric; } var languageDirection = fileBasedTm.LanguageDirection; var iterator = new RegularIterator(100); while (languageDirection.ReindexTranslationUnits(ref iterator)) { if (!bw.CancellationPending) { bw.ReportProgress(0, _reindexStatus.ToString()); } else { bw.ReportProgress(100, ""); } } fileBasedTm.RecomputeFuzzyIndexStatistics(); fileBasedTm.Save(); _reindexStatus.AppendLine(string.Format("Finish reindex {0} translation memory", tm.Name)); bw.ReportProgress(0, _reindexStatus.ToString()); }
public void Uplift(TranslationMemoryInfo tm, BackgroundWorker bw) { var originalTmFilePath = ProcessorUtil.RenameOriginalTm(tm.Name, tm.FilePath); var upliftTmFilePath = ProcessorUtil.GetOutputTmFullPath(tm.Name, tm.FilePath); _reindexStatus.AppendLine(string.Format("Start uplift {0} translation memory", tm.Name)); bw.ReportProgress(0, _reindexStatus.ToString()); File.Copy(originalTmFilePath, upliftTmFilePath, true); var tmOut = new FileBasedTranslationMemory(upliftTmFilePath); tmOut.FGASupport = FGASupport.Automatic; tmOut.Save(); var tmExporter = new TmExporter(tmOut); var tmIn = new FileBasedTranslationMemory(tm.FilePath); var tmImporter = new TmImporter(tmIn); var modelBuilder = new ModelBuilder(tmOut); var fragmentAligner = new FragmentAligner(tmOut); if (tmIn.FGASupport != FGASupport.NonAutomatic) { Process(modelBuilder, fragmentAligner, bw); } else { Process(tmExporter, tmImporter, modelBuilder, fragmentAligner, bw); } if (!bw.CancellationPending) { ProcessorUtil.UpdateTranslationMemory(tmOut); _reindexStatus.AppendLine(string.Format("Finish uplift {0} translation memory", tm.Name)); bw.ReportProgress(0, _reindexStatus.ToString()); } else { bw.ReportProgress(100, ""); } }