ProjectAutomation API - TargetLanguageStatistics is null

Hi there,

I am currently writing a Studio plugin that will export an overview of Revisions (for LQA system).

Most things work fine, i.e. revisions and comments are exported and project information such as source and target language as well as word count of the revised document get exported, too. What I cannot get though is the total word count of all files for that target language.

Here is how I try to achieve this:

var stats = project.GetProjectStatistics();
var targetlang = document.ActiveFile.Language;
var tstats = stats.TargetLanguageStatistics.FirstOrDefault(t => t.TargetLanguage == targetlang);

try
{
	((Excel.Range)lqc.Cells[7, 5]).Formula = tstats.ConfirmationStatistics.Total.Words.ToString();
}
catch (Exception ex)
{
	using (var sw = new StreamWriter(errorlog))
	{
		sw.WriteLine(ex.Message);
		if (tstats == null)
		{
			sw.WriteLine("tstats is null");
			sw.WriteLine(targetlang.DisplayName);
		}
	}
}

 Alas, tstats is always null.

This is a simple English => German project, manually created, fully prepared including analysis. I also ran an additional batch task Count words and Analyse to be on the safe side. Still, the error log says:

Object reference not set to an instance of an object.
tstats is null
German (Germany)

So the target language is clearly properly set, yet there do not seem to be any TargetLanguageStatistics for the target language.

Can anyone tell me what I am doing wrong?

Thanks!
Andreas

Parents Reply
  • Thank you, Remy.

    If all else fails, I will probably use this. I have downloaded the source as it will probably come in handy at a later stage.[Y]

    In this special case, however, I find it a little cumbersome having to iterate over all segments of all files and counting the words on a per segment basis, if what I need is already provided by the  ConfirmationStatistics.Total.Words property as well as AnalysisStatistics.Total.Words property.

    By the way, even stats.WordCountStatistics.Total.Words, i.e. the wordcount for the entire project fails, giving me a result of "0". I MUST do some basic thing wrong and would love to know what.

Children
No Data