[11727] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Threading.Tasks;
|
---|
| 6 |
|
---|
| 7 | namespace HeuristicLab.Problems.GrammaticalOptimization {
|
---|
| 8 | public class SentenceSetStatistics {
|
---|
| 9 | public int NumberOfSentences { get; private set; }
|
---|
| 10 | public string BestSentence { get; private set; }
|
---|
| 11 | public string FirstSentence { get; private set; }
|
---|
| 12 | public string LastSentence { get; private set; }
|
---|
| 13 | public double BestSentenceQuality { get; private set; }
|
---|
| 14 | public double FirstSentenceQuality { get; private set; }
|
---|
| 15 | public double LastSentenceQuality { get; private set; }
|
---|
| 16 | public double AverageQuality { get { return sumQualities / NumberOfSentences; } }
|
---|
| 17 | // public double MedianQuality { get; private set; }
|
---|
| 18 | private double sumQualities;
|
---|
| 19 |
|
---|
| 20 | public void AddSentence(string sentence, double quality) {
|
---|
| 21 | if (NumberOfSentences == 0) {
|
---|
| 22 | FirstSentence = sentence;
|
---|
| 23 | FirstSentenceQuality = quality;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | if (quality > BestSentenceQuality) {
|
---|
| 27 | BestSentence = sentence;
|
---|
| 28 | BestSentenceQuality = quality;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | sumQualities += quality;
|
---|
| 32 | NumberOfSentences++;
|
---|
| 33 |
|
---|
| 34 | LastSentence = sentence;
|
---|
| 35 | LastSentenceQuality = quality;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | public override string ToString() {
|
---|
| 39 | return
|
---|
| 40 | string.Format("Sentences: {0,10} avg.-quality {1,7:F5} best {2,7:F5} {3} first {4,7:F5} {5} last {6,7:F5} {7}",
|
---|
| 41 | NumberOfSentences, AverageQuality,
|
---|
| 42 | BestSentenceQuality, BestSentence,
|
---|
| 43 | FirstSentenceQuality, FirstSentence,
|
---|
| 44 | LastSentenceQuality, LastSentence
|
---|
| 45 | );
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | }
|
---|