public static void WriteToFile(List<ComparisonResult> data, PackSummary summary, string filePath, Application oxlApp)
        {
            var writer = new SentencesPackSummaryWriter(filePath, oxlApp);

            writer._write(data, summary);

            writer.Close();
        }
Beispiel #2
0
 public static void WritePackSimpleSentencesSummary(List<ComparisonResult> data, PackSummary summary, string filePath)
 {
     SentencesPackSummaryWriter.WriteSSToFile(data, summary, filePath, OxlApp);
 }
Beispiel #3
0
 private static void _exportPackSimpleSentencesSummary(SentencesPack dataPack, PackSummary summary, string resultsDir, string fileName)
 {
     DataExporter.WritePackSimpleSentencesSummary(dataPack.ComparisonResults, summary, Path.Combine(resultsDir, fileName));
 }
Beispiel #4
0
        private static PackSummary _summaryFor(SentencesPack pack,
            Func<SentencesPack, Func<SimpleSentenceStats, int>,
                Func<SimpleSentenceStats, double>, int, LinguisticObjectType, LoSummaryStats> statsForLObjects)
        {
            var result = new PackSummary
            {
                SentencesCount = pack.Sample.Count,
                Stats = new Dictionary<LinguisticObjectType, LoSummaryStats>()
            };

            var simpleSentences =
                pack.ComparisonResults.SelectMany(comparisonResult => comparisonResult.SimpleSentenceStats).ToList();

            var simpleSentecesCount = simpleSentences.Count();

            result.Stats[LinguisticObjectType.Subject] = statsForLObjects(pack, stats => stats.Subjects.Objects.Count,
                stats => stats.Subjects.AverageDetectionQuality, simpleSentecesCount, LinguisticObjectType.Subject);
            result.Stats[LinguisticObjectType.Predicate] = statsForLObjects(pack, stats => stats.Predicates.Objects.Count,
                stats => stats.Predicates.AverageDetectionQuality, simpleSentecesCount, LinguisticObjectType.Predicate);
            result.Stats[LinguisticObjectType.Uniform] = statsForLObjects(pack, stats => stats.Uniforms.Objects.Count,
                stats => stats.Uniforms.AverageDetectionQuality, simpleSentecesCount, LinguisticObjectType.Uniform);
            result.Stats[LinguisticObjectType.MeaningPart] = statsForLObjects(pack,
                stats => stats.MeaningAuxParts.Objects.Count,
                stats => stats.MeaningAuxParts.AverageDetectionQuality, simpleSentecesCount,
                LinguisticObjectType.MeaningPart);
            result.Stats[LinguisticObjectType.ChainFromSubject] = statsForLObjects(pack,
                stats => stats.ChainsFromSubjects.Values.SelectMany(list => list).Count(),
                stats => stats.ChainsFromSubjects.AverageDetectionQuality, simpleSentecesCount,
                LinguisticObjectType.ChainFromSubject);
            result.Stats[LinguisticObjectType.ChainFromPredicate] = statsForLObjects(pack,
                stats => stats.ChainsFromPredicates.Values.SelectMany(list => list).Count(),
                stats => stats.ChainsFromPredicates.AverageDetectionQuality, simpleSentecesCount,
                LinguisticObjectType.ChainFromPredicate);
            result.Stats[LinguisticObjectType.ChainFromMeaningPart] = statsForLObjects(pack,
                stats => stats.ChainsFromMeaningParts.Values.SelectMany(list => list).Count(),
                stats => stats.ChainsFromMeaningParts.AverageDetectionQuality, simpleSentecesCount,
                LinguisticObjectType.ChainFromMeaningPart);
            result.Stats[LinguisticObjectType.SimpleSentence] = _statsForSimpleSentences(pack, simpleSentecesCount);

            result.AverageLoCount =
                simpleSentences.Aggregate(0d, (sampleObjectsCount, stats) => sampleObjectsCount + stats.AllObjects.Count)/
                simpleSentecesCount;

            //result.AverageSentenceQuality = simpleSentences.Aggregate(0d,
            //    (d, stats) => d + stats.AverageDetectionQuality) / simpleSentecesCount;

            result.AverageSentenceQuality = _calcAverageAverageQuality(result.Stats);

            return result;
        }
Beispiel #5
0
 private void _writeSSStats(string key, PackSummary summary, int totalSentencesCount)
 {
     XlHelper.WriteRow(() =>
     {
         XlHelper.WriteValue(key);
         XlHelper.WriteValue(((double) summary.SentencesCount)/totalSentencesCount, null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.SimpleSentence].AverageCount, Colors.SummaryRow);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.SimpleSentence].AverageQuality, Colors.SummaryRow,
             XlsxHelper.PercentageFormat);
     });
 }
Beispiel #6
0
 private void _writeCategoryStats(string key, PackSummary summary, int totalSentencesCount)
 {
     XlHelper.WriteRow(() =>
     {
         XlHelper.WriteValue(key);
         XlHelper.WriteValue(((double) summary.SentencesCount)/totalSentencesCount, null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Subject].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Subject].AverageQuality,
             summary.Stats[LinguisticObjectType.Subject].WasEmulated ? Colors.EmulatedQuality : (Color?) null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Predicate].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Predicate].AverageQuality,
             summary.Stats[LinguisticObjectType.Predicate].WasEmulated ? Colors.EmulatedQuality : (Color?) null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Uniform].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.Uniform].AverageQuality,
             summary.Stats[LinguisticObjectType.Uniform].WasEmulated ? Colors.EmulatedQuality : (Color?) null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.MeaningPart].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.MeaningPart].AverageQuality,
             summary.Stats[LinguisticObjectType.MeaningPart].WasEmulated ? Colors.EmulatedQuality : (Color?) null,
             XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromSubject].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromSubject].AverageQuality,
             summary.Stats[LinguisticObjectType.ChainFromSubject].WasEmulated
                 ? Colors.EmulatedQuality
                 : (Color?) null, XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromPredicate].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromPredicate].AverageQuality,
             summary.Stats[LinguisticObjectType.ChainFromPredicate].WasEmulated
                 ? Colors.EmulatedQuality
                 : (Color?) null, XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromMeaningPart].AverageCount);
         XlHelper.WriteValue(summary.Stats[LinguisticObjectType.ChainFromMeaningPart].AverageQuality,
             summary.Stats[LinguisticObjectType.ChainFromMeaningPart].WasEmulated
                 ? Colors.EmulatedQuality
                 : (Color?) null, XlsxHelper.PercentageFormat);
         XlHelper.WriteValue(summary.AverageLoCount, Colors.SummaryRow);
         XlHelper.WriteValue(summary.AverageSentenceQuality,
             summary.Stats.Values.Any(stats => stats.WasEmulated) ? Colors.EmulatedQuality : Colors.SummaryRow,
             XlsxHelper.PercentageFormat);
     });
 }
 private void _write(List<ComparisonResult> data, PackSummary summary)
 {
     _writeHeader();
     _writeData(data);
     _writeSummary(summary);
 }
        private void _writeSummary(PackSummary data)
        {
            XlHelper.WriteRow(() =>
            {
                XlHelper.WriteValue(Labels.Summary.TotalByCategory, Colors.SummaryRow);

                _writeStatsForType(data.Stats, LinguisticObjectType.Subject);
                _writeStatsForType(data.Stats, LinguisticObjectType.Predicate);
                _writeStatsForType(data.Stats, LinguisticObjectType.Uniform);
                _writeStatsForType(data.Stats, LinguisticObjectType.MeaningPart);
                _writeStatsForType(data.Stats, LinguisticObjectType.ChainFromSubject);
                _writeStatsForType(data.Stats, LinguisticObjectType.ChainFromPredicate);
                _writeStatsForType(data.Stats, LinguisticObjectType.ChainFromMeaningPart);

                XlHelper.WriteValue(data.AverageLoCount, Colors.SummaryRow);
                XlHelper.WriteValue(data.AverageSentenceQuality,
                    data.Stats.Values.Any(stats => stats.WasEmulated) ? Colors.EmulatedQuality : Colors.SummaryRow,
                    XlsxHelper.PercentageFormat);
            });
        }
        private void _writeSSSummary(PackSummary data)
        {
            XlHelper.WriteRow(() =>
            {
                XlHelper.WriteValue(Labels.Summary.TotalByCategory, Colors.SummaryRow);

                XlHelper.WriteValue("", Colors.SummaryRow);
                XlHelper.WriteValue("", Colors.SummaryRow);

                XlHelper.WriteValue(data.Stats[LinguisticObjectType.SimpleSentence].AverageQuality, Colors.SummaryRow,
                    XlsxHelper.PercentageFormat);
            });
        }