Skip to content

Commit 78d4df2

Browse files
committed
Refactored quality estimation to match Machine conventions
1 parent d4993ff commit 78d4df2

19 files changed

Lines changed: 360 additions & 332 deletions

src/SIL.Machine/QualityEstimation/BookScores.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/SIL.Machine/QualityEstimation/ChapterUsability.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/SIL.Machine/QualityEstimation/ChrF3QualityEstimation.cs renamed to src/SIL.Machine/QualityEstimation/ChrF3QualityEstimator.cs

Lines changed: 140 additions & 115 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Collections.Generic;
2+
3+
namespace SIL.Machine.QualityEstimation
4+
{
5+
internal class ScriptureBookScores
6+
{
7+
private readonly Dictionary<string, List<double>> _segmentUsabilities = new Dictionary<string, List<double>>();
8+
9+
public readonly Dictionary<string, Score> Scores = new Dictionary<string, Score>();
10+
11+
public void AddScore(string book, Score score) => Scores[book] = score;
12+
13+
public Score GetScore(string book) => Scores.TryGetValue(book, out Score score) ? score : null;
14+
15+
public void AppendSegmentUsability(string book, double usability)
16+
{
17+
if (!_segmentUsabilities.TryGetValue(book, out List<double> list))
18+
{
19+
list = new List<double>();
20+
_segmentUsabilities[book] = list;
21+
}
22+
23+
list.Add(usability);
24+
}
25+
26+
public List<double> GetSegmentUsabilities(string book) =>
27+
_segmentUsabilities.TryGetValue(book, out List<double> list) ? new List<double>(list) : new List<double>();
28+
}
29+
}

src/SIL.Machine/QualityEstimation/BookUsability.cs renamed to src/SIL.Machine/QualityEstimation/ScriptureBookUsability.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace SIL.Machine.QualityEstimation
22
{
3-
public class BookUsability : UsabilityBase
3+
public class ScriptureBookUsability : UsabilityBase
44
{
5-
public BookUsability(string book, UsabilityLabel label, double projectedChrF3, double usability)
5+
public ScriptureBookUsability(string book, UsabilityLabel label, double projectedChrF3, double usability)
66
: base(label, projectedChrF3, usability)
77
{
88
Book = book;

src/SIL.Machine/QualityEstimation/ChapterScores.cs renamed to src/SIL.Machine/QualityEstimation/ScriptureChapterScores.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace SIL.Machine.QualityEstimation
44
{
5-
internal class ChapterScores
5+
internal class ScriptureChapterScores
66
{
7-
private readonly Dictionary<string, Dictionary<int, List<double>>> _verseUsabilities =
7+
private readonly Dictionary<string, Dictionary<int, List<double>>> _segmentUsabilities =
88
new Dictionary<string, Dictionary<int, List<double>>>();
99

1010
public readonly Dictionary<string, Dictionary<int, Score>> Scores =
@@ -27,12 +27,12 @@ public Score GetScore(string book, int chapter) =>
2727
? score
2828
: null;
2929

30-
public void AppendVerseUsability(string book, int chapter, double usability)
30+
public void AppendSegmentUsability(string book, int chapter, double usability)
3131
{
32-
if (!_verseUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters))
32+
if (!_segmentUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters))
3333
{
3434
chapters = new Dictionary<int, List<double>>();
35-
_verseUsabilities[book] = chapters;
35+
_segmentUsabilities[book] = chapters;
3636
}
3737

3838
if (!chapters.TryGetValue(chapter, out List<double> list))
@@ -44,8 +44,8 @@ public void AppendVerseUsability(string book, int chapter, double usability)
4444
list.Add(usability);
4545
}
4646

47-
public List<double> GetVerseUsabilities(string book, int chapter) =>
48-
_verseUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters)
47+
public List<double> GetSegmentUsabilities(string book, int chapter) =>
48+
_segmentUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters)
4949
&& chapters.TryGetValue(chapter, out List<double> list)
5050
? new List<double>(list)
5151
: new List<double>();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace SIL.Machine.QualityEstimation
2+
{
3+
public class ScriptureChapterUsability : ScriptureBookUsability
4+
{
5+
public ScriptureChapterUsability(
6+
string book,
7+
int chapter,
8+
UsabilityLabel label,
9+
double projectedChrF3,
10+
double usability
11+
)
12+
: base(book, label, projectedChrF3, usability)
13+
{
14+
Chapter = chapter;
15+
}
16+
17+
public int Chapter { get; }
18+
}
19+
}

src/SIL.Machine/QualityEstimation/VerseScore.cs renamed to src/SIL.Machine/QualityEstimation/ScriptureSegmentScore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace SIL.Machine.QualityEstimation
44
{
5-
internal class VerseScore : Score
5+
internal class ScriptureSegmentScore : Score
66
{
7-
public VerseScore(double slope, double confidence, double intercept, ScriptureRef scriptureRef)
7+
public ScriptureSegmentScore(double slope, double confidence, double intercept, ScriptureRef scriptureRef)
88
: base(slope, confidence, intercept)
99
{
1010
ScriptureRef = scriptureRef;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using SIL.Machine.Corpora;
2+
3+
namespace SIL.Machine.QualityEstimation
4+
{
5+
public class ScriptureSegmentUsability : ScriptureChapterUsability
6+
{
7+
public ScriptureSegmentUsability(
8+
ScriptureRef scriptureRef,
9+
UsabilityLabel label,
10+
double projectedChrF3,
11+
double usability
12+
)
13+
: base(scriptureRef.Book, scriptureRef.ChapterNum, label, projectedChrF3, usability)
14+
{
15+
ScriptureRef = scriptureRef;
16+
}
17+
18+
public ScriptureRef ScriptureRef { get; }
19+
}
20+
}

src/SIL.Machine/QualityEstimation/SequenceScore.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)