Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/SIL.Machine/QualityEstimation/BookScores.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;

namespace SIL.Machine.QualityEstimation
{
internal class BookScores
{
private readonly Dictionary<string, List<double>> _verseUsabilities = new Dictionary<string, List<double>>();

public readonly Dictionary<string, Score> Scores = new Dictionary<string, Score>();

public void AddScore(string book, Score score) => Scores[book] = score;

public Score GetScore(string book) => Scores.TryGetValue(book, out Score score) ? score : null;

public void AppendVerseUsability(string book, double usability)
{
if (!_verseUsabilities.TryGetValue(book, out List<double> list))
{
list = new List<double>();
_verseUsabilities[book] = list;
}

list.Add(usability);
}

public List<double> GetVerseUsabilities(string book) =>
_verseUsabilities.TryGetValue(book, out List<double> list) ? new List<double>(list) : new List<double>();
}
}
13 changes: 13 additions & 0 deletions src/SIL.Machine/QualityEstimation/BookUsability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SIL.Machine.QualityEstimation
{
public class BookUsability : UsabilityBase
{
public BookUsability(string book, UsabilityLabel label, double projectedChrF3, double usability)
: base(label, projectedChrF3, usability)
{
Book = book;
}

public string Book { get; }
}
}
53 changes: 53 additions & 0 deletions src/SIL.Machine/QualityEstimation/ChapterScores.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections.Generic;

namespace SIL.Machine.QualityEstimation
{
internal class ChapterScores
{
private readonly Dictionary<string, Dictionary<int, List<double>>> _verseUsabilities =
new Dictionary<string, Dictionary<int, List<double>>>();

public readonly Dictionary<string, Dictionary<int, Score>> Scores =
new Dictionary<string, Dictionary<int, Score>>();

public void AddScore(string book, int chapter, Score score)
{
if (!Scores.TryGetValue(book, out Dictionary<int, Score> chapters))
{
chapters = new Dictionary<int, Score>();
Scores[book] = chapters;
}

chapters[chapter] = score;
}

public Score GetScore(string book, int chapter) =>
Scores.TryGetValue(book, out Dictionary<int, Score> chapters)
&& chapters.TryGetValue(chapter, out Score score)
? score
: null;

public void AppendVerseUsability(string book, int chapter, double usability)
{
if (!_verseUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters))
{
chapters = new Dictionary<int, List<double>>();
_verseUsabilities[book] = chapters;
}

if (!chapters.TryGetValue(chapter, out List<double> list))
{
list = new List<double>();
chapters[chapter] = list;
}

list.Add(usability);
}

public List<double> GetVerseUsabilities(string book, int chapter) =>
_verseUsabilities.TryGetValue(book, out Dictionary<int, List<double>> chapters)
&& chapters.TryGetValue(chapter, out List<double> list)
? new List<double>(list)
: new List<double>();
}
}
13 changes: 13 additions & 0 deletions src/SIL.Machine/QualityEstimation/ChapterUsability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SIL.Machine.QualityEstimation
{
public class ChapterUsability : BookUsability
{
public ChapterUsability(string book, int chapter, UsabilityLabel label, double projectedChrF3, double usability)
: base(book, label, projectedChrF3, usability)
{
Chapter = chapter;
}

public int Chapter { get; }
}
}
Loading
Loading