@@ -50,49 +50,32 @@ public ChrF3QualityEstimation(double slope, double intercept)
5050 /// </summary>
5151 public UsabilityParameters Unusable { get ; set ; } = UsabilityParameters . Unusable ;
5252
53- /// <summary>
54- /// The usability scores for every book.
55- /// </summary>
56- public List < BookUsability > UsabilityBooks { get ; } = new List < BookUsability > ( ) ;
57-
58- /// <summary>
59- /// The usability scores for every chapter.
60- /// </summary>
61- public List < ChapterUsability > UsabilityChapters { get ; } = new List < ChapterUsability > ( ) ;
62-
63- /// <summary>
64- /// The usability scores for every line in a text file.
65- /// </summary>
66- public List < SequenceUsability > UsabilitySequences { get ; } = new List < SequenceUsability > ( ) ;
67-
68- /// <summary>
69- /// The usability scores for every text file.
70- /// </summary>
71- public List < TxtFileUsability > UsabilityTxtFiles { get ; } = new List < TxtFileUsability > ( ) ;
72-
73- /// <summary>
74- /// The usability scores for every verse.
75- /// </summary>
76- public List < VerseUsability > UsabilityVerses { get ; } = new List < VerseUsability > ( ) ;
77-
7853 /// <summary>
7954 /// Estimate the quality of the pre-translations from text files.
8055 /// </summary>
8156 /// <param name="confidences">The confidence values.</param>
82- public void EstimateQuality ( IEnumerable < ( MultiKeyRef key , double confidence ) > confidences )
57+ /// <returns>The usability scores for every line in the text files, and for the text files.</returns>
58+ public ( List < SequenceUsability > usabilitySequences , List < TxtFileUsability > usabilityTxtFiles ) EstimateQuality (
59+ IEnumerable < ( MultiKeyRef key , double confidence ) > confidences
60+ )
8361 {
8462 ProjectChrF3 ( confidences ) ;
85- ComputeSequenceUsability ( ) ;
63+ return ComputeSequenceUsability ( ) ;
8664 }
8765
8866 /// <summary>
8967 /// Estimate the quality of the pre-translations from USFM files.
9068 /// </summary>
9169 /// <param name="confidences">The confidence values.</param>
92- public void EstimateQuality ( IEnumerable < ( ScriptureRef key , double confidence ) > confidences )
70+ /// <returns>The usability scores for every verse, chapter, and book.</returns>
71+ public (
72+ List < VerseUsability > usabilityVerses ,
73+ List < ChapterUsability > usabilityChapters ,
74+ List < BookUsability > usabilityBooks
75+ ) EstimateQuality ( IEnumerable < ( ScriptureRef key , double confidence ) > confidences )
9376 {
9477 ProjectChrF3 ( confidences ) ;
95- ComputeVerseUsability ( ) ;
78+ return ComputeVerseUsability ( ) ;
9679 }
9780
9881 /// <summary>
@@ -119,8 +102,9 @@ private double CalculateUsableProbability(double chrF3)
119102 return usableWeight / ( usableWeight + unusableWeight ) ;
120103 }
121104
122- private void ComputeBookUsability ( )
105+ private List < BookUsability > ComputeBookUsability ( )
123106 {
107+ var usabilityBooks = new List < BookUsability > ( ) ;
124108 foreach ( string book in _bookScores . Scores . Keys )
125109 {
126110 Score score = _bookScores . GetScore ( book ) ;
@@ -129,7 +113,7 @@ private void ComputeBookUsability()
129113
130114 List < double > bookUsabilities = _bookScores . GetVerseUsabilities ( book ) ;
131115 double averageProbability = bookUsabilities . Average ( ) ;
132- UsabilityBooks . Add (
116+ usabilityBooks . Add (
133117 new BookUsability (
134118 book ,
135119 label : BookThresholds . ReturnLabel ( averageProbability ) ,
@@ -138,10 +122,13 @@ private void ComputeBookUsability()
138122 )
139123 ) ;
140124 }
125+
126+ return usabilityBooks ;
141127 }
142128
143- private void ComputeChapterUsability ( )
129+ private List < ChapterUsability > ComputeChapterUsability ( )
144130 {
131+ var usabilityChapters = new List < ChapterUsability > ( ) ;
145132 foreach ( KeyValuePair < string , Dictionary < int , Score > > chapterScoresByBook in _chapterScores . Scores )
146133 {
147134 string book = chapterScoresByBook . Key ;
@@ -153,7 +140,7 @@ private void ComputeChapterUsability()
153140
154141 List < double > chapterUsabilities = _chapterScores . GetVerseUsabilities ( book , chapter ) ;
155142 double averageProbability = chapterUsabilities . Average ( ) ;
156- UsabilityChapters . Add (
143+ usabilityChapters . Add (
157144 new ChapterUsability (
158145 book ,
159146 chapter ,
@@ -164,10 +151,34 @@ private void ComputeChapterUsability()
164151 ) ;
165152 }
166153 }
154+
155+ return usabilityChapters ;
156+ }
157+
158+ private ( List < SequenceUsability > , List < TxtFileUsability > ) ComputeSequenceUsability ( )
159+ {
160+ var usabilitySequences = new List < SequenceUsability > ( ) ;
161+ foreach ( SequenceScore sequenceScore in _sequenceScores )
162+ {
163+ double probability = CalculateUsableProbability ( sequenceScore . ProjectedChrF3 ) ;
164+ _txtFileScores . AppendSequenceUsability ( sequenceScore . TargetDraftFileStem , probability ) ;
165+ usabilitySequences . Add (
166+ new SequenceUsability (
167+ targetDraftFile : sequenceScore . TargetDraftFileStem ,
168+ sequenceNumber : sequenceScore . SequenceNumber ,
169+ label : VerseThresholds . ReturnLabel ( probability ) ,
170+ usability : probability ,
171+ projectedChrF3 : sequenceScore . ProjectedChrF3
172+ )
173+ ) ;
174+ }
175+
176+ return ( usabilitySequences , ComputeTxtFileUsability ( ) ) ;
167177 }
168178
169- private void ComputeTxtFileUsability ( )
179+ private List < TxtFileUsability > ComputeTxtFileUsability ( )
170180 {
181+ var usabilityTxtFiles = new List < TxtFileUsability > ( ) ;
171182 foreach ( string targetDraftFileStem in _txtFileScores . Scores . Keys )
172183 {
173184 Score score = _txtFileScores . GetScore ( targetDraftFileStem ) ;
@@ -176,7 +187,7 @@ private void ComputeTxtFileUsability()
176187
177188 List < double > txtFileUsabilities = _txtFileScores . GetSequenceUsabilities ( targetDraftFileStem ) ;
178189 double averageProbability = txtFileUsabilities . Average ( ) ;
179- UsabilityTxtFiles . Add (
190+ usabilityTxtFiles . Add (
180191 new TxtFileUsability (
181192 targetDraftFileStem ,
182193 label : BookThresholds . ReturnLabel ( averageProbability ) ,
@@ -185,10 +196,13 @@ private void ComputeTxtFileUsability()
185196 )
186197 ) ;
187198 }
199+
200+ return usabilityTxtFiles ;
188201 }
189202
190- private void ComputeVerseUsability ( )
203+ private ( List < VerseUsability > , List < ChapterUsability > , List < BookUsability > ) ComputeVerseUsability ( )
191204 {
205+ var usabilityVerses = new List < VerseUsability > ( ) ;
192206 foreach ( VerseScore verseScore in _verseScores . Where ( v => v . ScriptureRef . VerseNum > 0 ) )
193207 {
194208 double probability = CalculateUsableProbability ( verseScore . ProjectedChrF3 ) ;
@@ -198,7 +212,7 @@ private void ComputeVerseUsability()
198212 probability
199213 ) ;
200214 _bookScores . AppendVerseUsability ( verseScore . ScriptureRef . Book , probability ) ;
201- UsabilityVerses . Add (
215+ usabilityVerses . Add (
202216 new VerseUsability (
203217 book : verseScore . ScriptureRef . Book ,
204218 chapter : verseScore . ScriptureRef . ChapterNum ,
@@ -210,28 +224,7 @@ private void ComputeVerseUsability()
210224 ) ;
211225 }
212226
213- ComputeChapterUsability ( ) ;
214- ComputeBookUsability ( ) ;
215- }
216-
217- private void ComputeSequenceUsability ( )
218- {
219- foreach ( SequenceScore sequenceScore in _sequenceScores )
220- {
221- double probability = CalculateUsableProbability ( sequenceScore . ProjectedChrF3 ) ;
222- _txtFileScores . AppendSequenceUsability ( sequenceScore . TargetDraftFileStem , probability ) ;
223- UsabilitySequences . Add (
224- new SequenceUsability (
225- targetDraftFile : sequenceScore . TargetDraftFileStem ,
226- sequenceNumber : sequenceScore . SequenceNumber ,
227- label : VerseThresholds . ReturnLabel ( probability ) ,
228- usability : probability ,
229- projectedChrF3 : sequenceScore . ProjectedChrF3
230- )
231- ) ;
232- }
233-
234- ComputeTxtFileUsability ( ) ;
227+ return ( usabilityVerses , ComputeChapterUsability ( ) , ComputeBookUsability ( ) ) ;
235228 }
236229
237230 private void ProjectChrF3 ( IEnumerable < ( MultiKeyRef , double ) > confidences )
0 commit comments