Detecting language please wait for.......
I'm using the Trados Studio SDK to automate the creation of projects, and part of this involves running the analysis.
What's confusing me is when the AnalysisTaskSettings class can be used, and how it gets its values.
The When question:
While creating the project I specify a list of tasks, one of which is Sdl.ProjectApi.AutomaticTasks.Analysis. But I can't see how this would accept an argument of type AnalysisTaskSettings. As far as I can tell it has to be run with the default or template's settings.
Later on, once the project has been created, I can request the analysis results, and at this point I can specify an AnalysisTaskSettings object. Does it matter that the analysis has already been run?
The How question:
Here's how I'm getting the analysis settings...
var analysisSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();
I've found that if I step through the code and check the value of analysisSettings.ReportCrossFileRepetitions then it's set to TRUE. But hang on... I've already that to FALSE in the template...
And here it is in the XML of the template...
And yet when I break in the code I can see...
...not only is it set to TRUE, it also shows me the XML element and it value, contradicting what I see in the XML. The same is true of the fuzzy match leverage...
Trados also has its own copy of these settings (File > Options > Language Pairs) but these are also set to FALSE.
So where is the value of TRUE coming from if not the template or Trados?
To summarise: It looks to me like the cross-file repetitions are always being counted, even if I set Trados, the template and the AnalysisTaskSettings object to not count these - same for the fuzzy match leverage. How can I tell Trados not to count these?
Can you try adding the following line:
after you set the value to "false" and see if that fixes the issue?
Thanks for the suggestion but it doesn't appear to make any difference.
Here is the code I now have:
var analysisSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();analysisSettings.ReportCrossFileRepetitions.Value = false;analysisSettings.ReportInternalFuzzyMatchLeverage.Value = false;analysisSettings.EndEdit();project.UpdateSettings(settings);
analysisSettings.ReportCrossFileRepetitions.Value = false;
analysisSettings.ReportInternalFuzzyMatchLeverage.Value = false;
This looks correct when I inspect it at run-time...
However, inspecting the resultant analysis file suggests that cross-file repetitions were counted...
It could be that I'm only formulating this AnalysisTaskSettings object after the Sdl.ProjectApi.AutomaticTasks.Analysis task has already been executed but like I asked in the original post: how is it possible to pass an AnalysisTaskSettings object to that task?
Besides, my original question was more to do with why Trados appeared to be ignoring the setting in the template, and that question also still stands.
Yes, you are right. EndEdit() doesn't appear to do the trick.
But UpdateSettings(settings) does, but of course it has to be done before the batch task in case is run.
So, first create the project and then retrieve the settings file, change it and run the tasks only after that.
Link to a sample app here.
Thanks Emanuel, it now counts as I'd expect it to.