AnalyzeFiles and PreTranslateFilesTasks inProject Automation API Ignore Server TMs.

Hi,

I have managed to create an application using the the Project Automation API that creates a Project based on the needed info (source and target languages , source files, Server TMs to be used, Project settings etc.).  After much struggle, guesswork and trial and error I have managed to properly generate the Project.  When opened in Studio all is there.  The source files, the target files, the TMs with the correct settings etc.

I also run the relevant Analysis and Pretranslation tasks.  The relevant actions are performed without errors and the relevant reports are generated.  However, the reports do not include or use any of the project TMs and the generated reports only mention repetitions and internal fuzzy matching.

If one opens the Project in Studio (without changing anything) and runs an Analysis the new reports use the TMs and provide correct analysis results.

The relevant Analysis code is :

WriteText("Analysing Target Files...");

#region Get Analyse Settings

ISettingsBundle settings = Proj.GetSettings();

AnalysisTaskSettings analyzeSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();

#endregion

#region Set Internal Fuzzy Matching Value

if (InternalFuzzies.ToLower() == "true") analyzeSettings.ReportInternalFuzzyMatchLeverage.Value = true;
else analyzeSettings.ReportInternalFuzzyMatchLeverage.Value = false;

#endregion

#region Set Cross Files Repetitions Value

analyzeSettings.ReportCrossFileRepetitions.Value = true;

#endregion

#region Update Settings

Proj.UpdateSettings(settings);

#endregion

CSVOpen();

for (int i = 0; i < LangTrgLangs.Length; i++)
{
Language LangTrgLang = LangTrgLangsIdea;

WriteText("Analysing Target Files for " + LangTrgLang.DisplayName);

#region Analyse Language Pair

ProjectFile[] TargetFiles = Proj.GetTargetLanguageFiles(LangTrgLang);

AutomaticTask analyzeTask = Proj.RunAutomaticTask(TargetFiles.GetIds(), AutomaticTaskTemplateIds.AnalyzeFiles);

CheckEvents(taskStatusEventArgsList, messageEventArgsList);
if (!Continue) WriteError("Failed to Analyse files.", "Please check and try to analyse them manually.");

#endregion

#region Save Analysis Report for Language Pair

WriteText("Saving Analysis Html Report File for " + LangTrgLang.DisplayName);

Guid reportId = analyzeTask.Reports[0].Id;
string AnalysisFileName = JobFile.Substring(0, JobFile.Length - 4) + "_" + LangTrgLang.DisplayName + ".html";
Proj.SaveTaskReportAs(reportId, AnalysisFileName, Sdl.ProjectAutomation.Core.ReportFormat.Html);

#endregion

Any help in the matter would be greatly appreciated.  I have spend a couple of days on it and no matter what I have tried I did not manage to make it work properly.

Thank you in advance for any tips or help.

Best regards,

Costas

also uses them in trhe Analysis.

Parents
  • From a Senior SDL Developer...

     

    Concerning the issue (AnalyzeFiles and PreTranslateFilesTasks inProject Automation API Ignore Server TMs), I created a test with the following code:

     

    static void TestProjectAnalysisReportWithServerTm()

    {

        // 1. create project

        var infoProjectToCreate = new ProjectInfo()

                                        {

                                            Name = "Costas Nadalis",

                                            Description = "AnalyzeFiles inProject Automation API Ignore Server TMs",

                                            DueDate = new DateTime(2013, 6, 6),

                                           SourceLanguage = new Language("en-US"),

                                            TargetLanguages = new Language[] {new Language("de-DE")},

                                            LocalProjectFolder = @"D:\tout\1"

                                        };

     

        var templatePath = @"C:\Users\xliu\Documents\Studio 2011--\Project Templates\Default.sdltpl";           

     

        var project = new FileBasedProject(infoProjectToCreate, new ProjectTemplateReference(templatePath));

     

        // 2. configure the TM:

        var tmProviderConfig = project.GetTranslationProviderConfiguration();

        var tmServer = new TranslationProviderServer(new Uri("http://shdevgs2011:80"), false, "sa", "sa");

        var serverTm = tmServer.GetTranslationMemory("/SDL Trados Studio/TestServerTM", TranslationMemoryProperties.All);

        var tmProviderRef = new TranslationProviderReference(serverTm.Uri, serverTm.SerializeState(), true);

        var providerEntry = new TranslationProviderCascadeEntry(tmProviderRef, true, true, true);

               

        tmProviderConfig.Entries.Add(providerEntry);

        project.AddMasterTM(tmProviderConfig, "de-DE");

     

        //3. add files to the project

        var sourceFile = @"C:\Users\xliu\Documents\Studio 2011--\Projects\Samples\SampleProject\en-US\TryPerfectMatch.doc";

        project.AddFiles(new string[] { sourceFile });

     

        project.Save();

     

        //4. run the tasks

        var automaticTask = project.RunAutomaticTasks(project.GetSourceLanguageFiles().GetIds(),

                                                        new string[]

                                                            {

                                                                AutomaticTaskTemplateIds.Scan,

                                                                AutomaticTaskTemplateIds.ConvertToTranslatableFormat,

                                                                AutomaticTaskTemplateIds.CopyToTargetLanguages,

                                                                AutomaticTaskTemplateIds.AnalyzeFiles

                                                            });

               

        //5. check analysis results

        var analysisSettings = project.GetSettings().GetSettingsGroup<AnalysisTaskSettings>();

        // here I might cusomize the settings, but I decide to use the default settings

        var statistics = project.GetProjectStatistics().TargetLanguageStatistics[0].AnalysisStatistics;

        Console.WriteLine("Analysis result for the project:");

        Console.WriteLine("new segments: {0}", statistics.New.Segments);

        Console.WriteLine("context match: {0}", statistics.InContextExact.Segments);

        Console.WriteLine("100%: {0}", statistics.Exact.Segments);

    }

     

    My test file has 20 segments and 19 of them are already in my server TM.  Here is the printed results:

     

    It accounts 18 of them as matched in context, and 1 of them is 100% match.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

Reply
  • From a Senior SDL Developer...

     

    Concerning the issue (AnalyzeFiles and PreTranslateFilesTasks inProject Automation API Ignore Server TMs), I created a test with the following code:

     

    static void TestProjectAnalysisReportWithServerTm()

    {

        // 1. create project

        var infoProjectToCreate = new ProjectInfo()

                                        {

                                            Name = "Costas Nadalis",

                                            Description = "AnalyzeFiles inProject Automation API Ignore Server TMs",

                                            DueDate = new DateTime(2013, 6, 6),

                                           SourceLanguage = new Language("en-US"),

                                            TargetLanguages = new Language[] {new Language("de-DE")},

                                            LocalProjectFolder = @"D:\tout\1"

                                        };

     

        var templatePath = @"C:\Users\xliu\Documents\Studio 2011--\Project Templates\Default.sdltpl";           

     

        var project = new FileBasedProject(infoProjectToCreate, new ProjectTemplateReference(templatePath));

     

        // 2. configure the TM:

        var tmProviderConfig = project.GetTranslationProviderConfiguration();

        var tmServer = new TranslationProviderServer(new Uri("http://shdevgs2011:80"), false, "sa", "sa");

        var serverTm = tmServer.GetTranslationMemory("/SDL Trados Studio/TestServerTM", TranslationMemoryProperties.All);

        var tmProviderRef = new TranslationProviderReference(serverTm.Uri, serverTm.SerializeState(), true);

        var providerEntry = new TranslationProviderCascadeEntry(tmProviderRef, true, true, true);

               

        tmProviderConfig.Entries.Add(providerEntry);

        project.AddMasterTM(tmProviderConfig, "de-DE");

     

        //3. add files to the project

        var sourceFile = @"C:\Users\xliu\Documents\Studio 2011--\Projects\Samples\SampleProject\en-US\TryPerfectMatch.doc";

        project.AddFiles(new string[] { sourceFile });

     

        project.Save();

     

        //4. run the tasks

        var automaticTask = project.RunAutomaticTasks(project.GetSourceLanguageFiles().GetIds(),

                                                        new string[]

                                                            {

                                                                AutomaticTaskTemplateIds.Scan,

                                                                AutomaticTaskTemplateIds.ConvertToTranslatableFormat,

                                                                AutomaticTaskTemplateIds.CopyToTargetLanguages,

                                                                AutomaticTaskTemplateIds.AnalyzeFiles

                                                            });

               

        //5. check analysis results

        var analysisSettings = project.GetSettings().GetSettingsGroup<AnalysisTaskSettings>();

        // here I might cusomize the settings, but I decide to use the default settings

        var statistics = project.GetProjectStatistics().TargetLanguageStatistics[0].AnalysisStatistics;

        Console.WriteLine("Analysis result for the project:");

        Console.WriteLine("new segments: {0}", statistics.New.Segments);

        Console.WriteLine("context match: {0}", statistics.InContextExact.Segments);

        Console.WriteLine("100%: {0}", statistics.Exact.Segments);

    }

     

    My test file has 20 segments and 19 of them are already in my server TM.  Here is the printed results:

     

    It accounts 18 of them as matched in context, and 1 of them is 100% match.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

Children