53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
namespace ReportGenerator.Models;
|
|
|
|
internal readonly struct ImageStats
|
|
{
|
|
public string ImageName { get; } = string.Empty;
|
|
|
|
public ICollection<string> Reference { get; } = Array.Empty<string>();
|
|
public ICollection<ProcessorStat> Stats { get; } = Array.Empty<ProcessorStat>();
|
|
|
|
public ImageStats(
|
|
string imageName,
|
|
ICollection<string> taggedWords,
|
|
IEnumerable<ScannedResultInfo> scanResult
|
|
)
|
|
{
|
|
Reference = taggedWords;
|
|
ImageName = imageName;
|
|
Stats = scanResult
|
|
.Select(t => new ProcessorStat(t.ProcessorName, taggedWords, t.GetWords()))
|
|
.ToArray();
|
|
}
|
|
|
|
|
|
public IEnumerable<IEnumerable<string>> ToTable()
|
|
{
|
|
// Title
|
|
yield return Stats.Select(s => s.ProcessorName).Prepend("Reference");
|
|
|
|
// Spacer
|
|
yield return Stats.Select(s => "---").Prepend("---");
|
|
|
|
// Content
|
|
foreach (var reference in Reference)
|
|
{
|
|
yield return Stats.SelectMany(s => s.ToRow(reference)).Prepend(reference);
|
|
}
|
|
|
|
// Spacer
|
|
yield return Stats.Select(s => "---").Prepend("---");
|
|
|
|
// Summaries
|
|
yield return Stats
|
|
.Select(s => s.CharacterStats.Average(s => s.CharacterError).ToString("F2"))
|
|
.Prepend("CER (avg)");
|
|
yield return Stats
|
|
.Select(s => s.CharacterStats.Sum(s => s.CharacterError).ToString("F2"))
|
|
.Prepend("CER (sum)");
|
|
yield return Stats
|
|
.Select(s => s.WordError.ToString("F2"))
|
|
.Prepend("WER");
|
|
}
|
|
}
|