using Common.Distance; namespace ReportGenerator.Models; public readonly struct ProcessorStat : IDistanceComparer> { /// /// The name of the processor /// public string Name { get; } /// /// The total milliseconds it took the processor to process the data /// public double ProcessingTime { get; } /// public IEnumerable Reference { get; } /// public IEnumerable? Hypothesis { get; } /// public double Distance { get; } /// /// Information about the processed values /// public ICollection> Words { get; } public ProcessorStat( string name, double processingTime, ICollection reference, ICollection hypothesis ) { Name = name; ProcessingTime = processingTime; Reference = reference; Hypothesis = hypothesis; Distance = Calculator.GetDistance( reference.OrderBy(s => s).ToArray(), hypothesis.OrderBy(s => s).ToArray() ) / reference.Count; Words = reference.Select(r => GetDistanceInfo(r, hypothesis)).ToArray(); } private static ICollection> GetDistanceInfos( ICollection reference, ICollection hypothesis ) { // todo avoid matching the same reference with a value multiple times throw new NotImplementedException(); } /// /// Compares the with all given /// and determines the with the lowest error /// private static IDistanceComparer GetDistanceInfo( string reference, IEnumerable values ) { var result = new DistanceComparer(reference); // Determine character stat with lowest error foreach (var value in values) { // todo avoid matching the same reference with a value multiple times var stat = new DistanceComparer(reference, value); if (stat.Distance > result.Distance || (stat.Distance / reference.Length) > 0.6d) { // todo fine-tune threshold continue; } result = stat; if (stat.Distance <= 0) { // We cannot go lower than zero, break return result; } } return result; } }