Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/SentenceSetStatistics.cs @ 11730

Last change on this file since 11730 was 11730, checked in by gkronber, 8 years ago

#2283: several major extensions for grammatical optimization

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Common;
7
8namespace HeuristicLab.Problems.GrammaticalOptimization {
9  public class SentenceSetStatistics {
10    public int NumberOfSentences { get; private set; }
11    public string BestSentence { get; private set; }
12    public string FirstSentence { get; private set; }
13    public string LastSentence { get; private set; }
14    public double BestSentenceQuality { get; private set; }
15    public double BestSentenceIndex { get; private set; }
16    public double FirstSentenceQuality { get; private set; }
17    public double LastSentenceQuality { get; private set; }
18    public double AverageQuality { get { return sumQualities / NumberOfSentences; } }
19    // public double MedianQuality { get; private set; }
20    private double sumQualities;
21
22    public void AddSentence(string sentence, double quality) {
23      sumQualities += quality;
24      NumberOfSentences++;
25
26      if (NumberOfSentences == 1) {
27        FirstSentence = sentence;
28        FirstSentenceQuality = quality;
29      }
30
31      if (quality > BestSentenceQuality) {
32        BestSentence = sentence;
33        BestSentenceQuality = quality;
34        BestSentenceIndex = NumberOfSentences;
35      }
36
37      LastSentence = sentence;
38      LastSentenceQuality = quality;
39    }
40
41    public override string ToString() {
42      return
43        string.Format("Sentences: {0,10} avg.-quality {1,7:F5} best {2,7:F5} {3,2} {4,10} {5} first {6,7:F5} {7} last {8,7:F5} {9}",
44      NumberOfSentences, AverageQuality,
45      BestSentenceQuality, BestSentenceQuality.IsAlmost(1.0)?1.0:0.0,
46      BestSentenceIndex, BestSentence,
47      FirstSentenceQuality, FirstSentence,
48      LastSentenceQuality, LastSentence
49     );
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.