From f077ce2e1b34c9d7cbf0b5bad6d05d2593d0b577 Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Thu, 25 May 2023 18:36:46 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20dinglehopper-summarize:=20Handle?= =?UTF-8?q?=20reports=20without=20difference=20stats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dinglehopper/cli_summarize.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dinglehopper/cli_summarize.py b/src/dinglehopper/cli_summarize.py index 0422759..651f367 100644 --- a/src/dinglehopper/cli_summarize.py +++ b/src/dinglehopper/cli_summarize.py @@ -34,10 +34,13 @@ def process(reports_folder, occurrences_threshold=1): cer_sum += cer wer_sum += wer - for key, value in report_data["differences"]["character_level"].items(): - diff_c[key] = diff_c.get(key, 0) + value - for key, value in report_data["differences"]["word_level"].items(): - diff_w[key] = diff_w.get(key, 0) + value + try: + for key, value in report_data["differences"]["character_level"].items(): + diff_c[key] = diff_c.get(key, 0) + value + for key, value in report_data["differences"]["word_level"].items(): + diff_w[key] = diff_w.get(key, 0) + value + except KeyError: + pass if len(cer_list) == 0: click.echo(f"No reports found in folder '{os.path.abspath(reports_folder)}'")