protected override void OnInitializeTask()
        {
            var fileLanguageDirections = TaskFiles.Select(x => x.GetLanguageDirection().TargetLanguage.IsoAbbreviation).Distinct();

            if (fileLanguageDirections.Count() > 1)
            {
                throw new Exception(
                          $"This batch task can only be applied to one language direction at a time. Select only files with same language direction and try again.");
            }
            else if (fileLanguageDirections.Count() == 0)
            {
                throw new Exception(
                          $"No target files selected.");
            }
            this.collectedSentencePairCount = 0;
            this.settings       = GetSetting <FinetuneBatchTaskSettings>();
            this.opusCatOptions = new OpusCatOptions(new Uri(this.settings.ProviderOptions));

            //Use project guid in case no model tag specified
            if (this.opusCatOptions.modelTag == "")
            {
                this.opusCatOptions.modelTag = this.Project.GetProjectInfo().Id.ToString();
            }

            //Get instances of the translation memories included in the project.
            this.tms = this.InstantiateProjectTms();

            this.ProjectTranslations = new Dictionary <Language, List <Tuple <string, string> > >();
            this.ProjectNewSegments  = new Dictionary <Language, List <string> >();
            this.ProjectFuzzies      = new Dictionary <Language, List <TranslationUnit> >();
            this.sourceVisitor       = new OpusCatProviderElementVisitor();
            this.targetVisitor       = new OpusCatProviderElementVisitor();
            base.OnInitializeTask();
        }
Exemple #2
0
        private void CreateWizardContext()
        {
            var selectedIds = TaskFiles.Select(projectFile => projectFile.Id.ToString()).ToList();

            _project = GetProjectModel(Project as FileBasedProject, selectedIds);
            var settings = GetSettings();

            _wizardContext = new WizardContext(Enumerators.Action.Export, settings)
            {
                Completed          = false,
                Project            = _project,
                Owner              = Enumerators.Controller.Files,    // TODO: check if Files or Projects controller
                DateTimeStamp      = _exportSettings.DateTimeStamp,
                ExportOptions      = _exportSettings.ExportOptions,
                LocalProjectFolder = _exportSettings.LocalProjectFolder,
                TransactionFolder  = _exportSettings.TransactionFolder,
                ProjectFiles       = _project.ProjectFiles,
                AnalysisBands      = GetAnalysisBands(Project as FileBasedProject)
            };
        }