Fetching Cross-file repetitions through API

Hello!

We cannot seem to find the way to fetch the cross-file repetitions results generated during analysis via API, at least we haven't found that information in the API documentation for Studio 2014.

Does anybody know if this is supported and if it is, how can we do it?

Thanks for your help!

Best Regards

Lara

  • Hi Lara,

    Not sure if you have your problem sorted, but following function does that for summary part and might give you some idea how t sort your problem:

    private static string AddClientQuoteSummary(FileBasedProject project,  TargetLanguageStatistics analysis_stats, DataTable dt_client)

           {

               string result = "";

               string project_file = project.FilePath;

               string ReportsFolder = project_file.Replace(Path.GetFileName(project_file), "Reports");

               if (Directory.Exists(ReportsFolder))

               {

                   string[] files = Directory.GetFiles(ReportsFolder, "Analyze*.xml", SearchOption.TopDirectoryOnly);

                   string xmlfile = files[0];

                   XmlDocument doc = new XmlDocument();

                   doc.XmlResolver = null;

                   doc.Load(xmlfile);

                   doc.Save(xmlfile);

                   doc.Load(xmlfile);

                   XmlNodeList n1 = doc.SelectNodes("/task/batchTotal/analyse/perfect");

                   iTracTools.Log.Info(String.Format("File: {0}, childnode: {1}, count: {2}", xmlfile, doc.ChildNodes[0].Name, n1[0].Name));

                   XmlNode perfect_node = doc.SelectSingleNode("/task/batchTotal/analyse/perfect");

                   XmlNode context_node = doc.SelectSingleNode("/task/batchTotal/analyse/inContextExact");

                   XmlNode exact_node = doc.SelectSingleNode("/task/batchTotal/analyse/exact");

                   XmlNode cross_file_rep_node = doc.SelectSingleNode("/task/batchTotal/analyse/crossFileRepeated");

                   XmlNode rep_node = doc.SelectSingleNode("/task/batchTotal/analyse/repeated");

                   XmlNode new_node = doc.SelectSingleNode("/task/batchTotal/analyse/new");

                   decimal client_perfect_segments = decimal.Parse(perfect_node.Attributes["segments"].Value);

                   decimal client_perfect_words = decimal.Parse(perfect_node.Attributes["words"].Value);

                   decimal client_context_segments = decimal.Parse(context_node.Attributes["segments"].Value);

                   decimal client_context_words = decimal.Parse(context_node.Attributes["words"].Value);

                   decimal client_exact_segments = decimal.Parse(exact_node.Attributes["segments"].Value);

                   decimal client_exact_words = decimal.Parse(exact_node.Attributes["words"].Value);

                   decimal client_cross_file_rep_seg = decimal.Parse(cross_file_rep_node.Attributes["segments"].Value);

                   decimal client_cross_file_rep_words = decimal.Parse(cross_file_rep_node.Attributes["words"].Value);

                   decimal client_rep_segments = decimal.Parse(rep_node.Attributes["segments"].Value);

                   decimal client_rep_words = decimal.Parse(rep_node.Attributes["words"].Value);

                   decimal new_words = decimal.Parse(new_node.Attributes["words"].Value);

                   decimal new_segments = decimal.Parse(new_node.Attributes["segments"].Value);

                   //finalizing context and reps

                   decimal client_final_context_words = client_perfect_words + client_context_words;

                   decimal client_final_context_segments = client_context_segments + client_perfect_segments;

                   decimal client_final_reps_seg = client_cross_file_rep_seg + client_rep_segments;

                   decimal client_final_reps_words = client_cross_file_rep_words + client_rep_words;

                   DataRow client_row = dt_client.NewRow();

                   client_row["Language"] = analysis_stats.TargetLanguage.DisplayName;

                   client_row["ContextMatch"] = client_final_context_words.ToString();

                   client_row["Repetitions"] = client_final_reps_words.ToString();

                   client_row["100% Match"] = client_exact_words.ToString();

                   client_row["New Words"] = new_words;

                   //adding non fuzzies to datatable

                   //fuzzies

                   result += "<table border=\"1\" bordercolor=\"black\">";

                   decimal client_fuzzy_total = 0;

                   result += "<tr><td>Type</td><td>Segments</td><td>Words</td></tr>";

                   result += String.Format("<tr><td>Context</td><td>{0}</td><td>{1}</td></tr>",

                       client_final_context_segments, client_final_context_words);

                   result += String.Format("<tr><td>Repetitions</td><td>{0}</td><td>{1}</td></tr>", client_final_reps_seg, client_final_reps_words);

                   result += String.Format("<tr><td>100% Matches</td><td>{0}</td><td>{1}</td></tr>", client_exact_segments, client_exact_words);

                   XmlNodeList normal_fuzzy_list = doc.SelectNodes("/task/batchTotal/analyse/fuzzy");

                   for (int i = normal_fuzzy_list.Count - 1; i >= 0; i--)

                   {

                       XmlNode node = normal_fuzzy_listIdea;

                       result += String.Format("<tr><td>Normal Fuzzy: {0}-{1}</td><td>{2}</td><td>{3}</td></tr>", node.Attributes["max"].Value, node.Attributes["min"].Value,

                           node.Attributes["segments"].Value, node.Attributes["words"].Value);

                       client_fuzzy_total = client_fuzzy_total + decimal.Parse(node.Attributes["words"].Value);

                   }

                   client_row["Fuzzies"] = client_fuzzy_total;

                   dt_client.Rows.Add(client_row);

                   XmlNodeList internal_fuzzy_nodes = doc.SelectNodes("/task/batchTotal/analyse/internalFuzzy");

                   for (int i = internal_fuzzy_nodes.Count - 1; i >= 0; i--)

                   {

                       XmlNode node = internal_fuzzy_nodesIdea;

                       result += String.Format("<tr><td><font color=\"Red\">Internal Fuzzy: {0}-{1}</font></td><td><font color=\"Red\">{2}</font></td><td><font color=\"Red\">{3}</font></td></tr>", node.Attributes["max"].Value, node.Attributes["min"].Value,

                           node.Attributes["segments"].Value, node.Attributes["words"].Value);

                   }

                   iTracTools.Log.Info(String.Format("Internal fuzyy: {0}, normal fuzzy {1}", internal_fuzzy_nodes.Count, normal_fuzzy_list.Count));

                   result += String.Format("<tr><td>New</td><td>{0}</td><td>{1}</td></tr>", new_segments, new_words);

                   result += "</table>";

               }

               return result;

           }

  • Is there any update on this? I want to see which segments of a merged xliff are repetitions cross-file via the API, not via Trados Studio. Essentially, when you open Trados Studio and perform an Analysis Task with an empty TM hooked on your project, your xliff has something like this:

    <doc-info xmlns="">sdl.com/.../1.0">
    <rep-defs>
    <rep-def id="JzFVytbB/dtRXmLFj8jObLBhpts=">
    <entry tu="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" seg="1"/>
    <entry tu="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" seg="2"/>
    <entry tu="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" seg="3"/>
    <entry tu="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" seg="4"/>
    </rep-def>

    which shows the groups of segment repetitions. How can I populate this information via the API?