@@ -132,19 +132,23 @@ def compute_usable_proportions(verse_scores: List[VerseScore], output_dir: Path)
132132 chapter_totals = defaultdict (lambda : defaultdict (float ))
133133 chapter_counts = defaultdict (lambda : defaultdict (int ))
134134
135- for verse_score in verse_scores :
136- vref = verse_score .vref
137- if vref .verse_num == 0 :
138- continue
139- if verse_score .projected_chrf3 is None :
140- LOGGER .warning (f"{ vref } does not have a projected chrf3. Skipping." )
141- continue
142-
143- prob = calculate_usable_prob (verse_score .projected_chrf3 , usable_params , unusable_params )
144- book_totals [vref .book ] += prob
145- book_counts [vref .book ] += 1
146- chapter_totals [vref .book ][vref .chapter_num ] += prob
147- chapter_counts [vref .book ][vref .chapter_num ] += 1
135+ with open (output_dir / "usability_verses.tsv" , "w" , encoding = "utf-8" , newline = "\n " ) as verse_file :
136+ verse_file .write ("Book\t Chapter\t Verse\t Usability\n " )
137+ for verse_score in verse_scores :
138+ vref = verse_score .vref
139+ if vref .verse_num == 0 :
140+ continue
141+ if verse_score .projected_chrf3 is None :
142+ LOGGER .warning (f"{ vref } does not have a projected chrf3. Skipping." )
143+ continue
144+
145+ prob = calculate_usable_prob (verse_score .projected_chrf3 , usable_params , unusable_params )
146+ book_totals [vref .book ] += prob
147+ book_counts [vref .book ] += 1
148+ chapter_totals [vref .book ][vref .chapter_num ] += prob
149+ chapter_counts [vref .book ][vref .chapter_num ] += 1
150+
151+ verse_file .write (f"{ vref .book } \t { vref .chapter_num } \t { vref .verse_num } \t { prob :.6f} \n " )
148152
149153 with open (output_dir / "usability_books.tsv" , "w" , encoding = "utf-8" , newline = "\n " ) as book_file :
150154 book_file .write ("Book\t Usability\n " )
@@ -201,6 +205,7 @@ def main() -> None:
201205 parser .add_argument (
202206 "confidence_files" ,
203207 nargs = "*" ,
208+ type = Path ,
204209 help = "Relative paths for the confidence files to process (relative to MT/experiments or --confidence-dir "
205210 + "if specified) e.g. 'project_folder/exp_folder/infer/5000/source/631JN.SFM.confidences.tsv' or "
206211 + "'631JN.SFM.confidences.tsv --confidence-dir project_folder/exp_folder/infer/5000/source'." ,
0 commit comments