private static List <DocumentResult> WriteXmlFiles(string reportFilePath , Dictionary <Comparison.Comparer.FileUnitProperties, Dictionary <string, Dictionary <string, Comparison.Comparer.ComparisonParagraphUnit> > > fileComparisonFileParagraphUnits) { _idMappings = new List <TERpIdMapping>(); var workingDir = Path.GetDirectoryName(reportFilePath); TerpPath = WriteTerpProcessorFile(workingDir); var results = new List <DocumentResult>(); foreach (var fileComparisonFileParagraphUnit in fileComparisonFileParagraphUnits) { if (fileComparisonFileParagraphUnit.Value == null) { continue; } var fileUnitProperties = fileComparisonFileParagraphUnit.Key; var language = fileUnitProperties.TargetLanguageIdUpdated; var filePath = Path.GetFileName(fileUnitProperties.FilePathUpdated); if (workingDir == null) { continue; } var fileRef = Path.Combine(workingDir, filePath + "." + language + ".terp.ref.xml"); var filehyp = Path.Combine(workingDir, filePath + "." + language + ".terp.hyp.xml"); var filePrefix = Path.Combine(workingDir, filePath + "." + language + ".out"); WriteXmlDocument(fileRef, fileComparisonFileParagraphUnit, true); var segmentDatas = WriteXmlDocument(filehyp, fileComparisonFileParagraphUnit, false); if (segmentDatas.Count > 0) { var info = new ProcessStartInfo("\"" + JavaPath + "\"") { Arguments = " -jar \"" + TerpPath + "\" -r \"" + filehyp + "\" -h \"" + fileRef + "\" -n \"" + filePrefix + "\" -o sum,pra,nist,html,param", WindowStyle = ProcessWindowStyle.Hidden }; var process = System.Diagnostics.Process.Start(info); if (process != null) { process.WaitForExit(); } if (!File.Exists(filePrefix + ".sum")) { continue; } string sumContent; using (var reader = new StreamReader(filePrefix + ".sum")) { sumContent = reader.ReadToEnd(); reader.Close(); } var regexLines = new Regex("^(?<x1>.*|)$", RegexOptions.Multiline); var regexNameAndSegId = new Regex(@"\[(?<x1>.*|)\]\[(?<x2>.*|)\]", RegexOptions.IgnoreCase); var mcLines = regexLines.Matches(sumContent); if (mcLines.Count > 0) { foreach (Match mLine in mcLines) { var strLine = mLine.Value; var columns = strLine.Split('|'); if (columns.Count() != 12) { continue; } var mcNameAndSegId = regexNameAndSegId.Match(columns[0]); if (!mcNameAndSegId.Success) { continue; } var name = mcNameAndSegId.Groups["x1"].Value; var id = mcNameAndSegId.Groups["x2"].Value.TrimStart('0'); if (string.IsNullOrEmpty(id)) { continue; } var segId = _idMappings.FirstOrDefault(s => s.Id.ToString() == id); if (segId == null) { continue; } var segmentData = segmentDatas.SingleOrDefault(a => a.SegmentId == segId.SegmentId && a.FileName == name); if (segmentData == null) { continue; } segmentData.Ins = ReportUtils.GetDecimal(columns[1]); segmentData.Del = ReportUtils.GetDecimal(columns[2]); segmentData.Sub = ReportUtils.GetDecimal(columns[3]); segmentData.Stem = ReportUtils.GetDecimal(columns[4]); segmentData.Syn = ReportUtils.GetDecimal(columns[5]); segmentData.Phrase = ReportUtils.GetDecimal(columns[6]); segmentData.Shft = ReportUtils.GetDecimal(columns[7]); segmentData.Wdsh = ReportUtils.GetDecimal(columns[8]); segmentData.NumEr = ReportUtils.GetDecimal(columns[9]); segmentData.NumWd = ReportUtils.GetDecimal(columns[10]); segmentData.Terp = ReportUtils.GetDecimal(columns[11]); segmentData.NumCap = 0; } } var result = new DocumentResult { OriginalDocumentPath = fileUnitProperties.FilePathOriginal, UpdatedDocumentPath = fileUnitProperties.FilePathUpdated, HtmlPath = filePrefix + ".html", SegmentDatas = segmentDatas }; results.Add(result); File.Delete(filePrefix + ".sum"); } File.Delete(fileRef); File.Delete(filehyp); } if (File.Exists(TerpPath)) { File.Delete(TerpPath); } return(results); }