diff --git a/qurator/dinglehopper/cli.py b/qurator/dinglehopper/cli.py index 32e159f..72d428d 100644 --- a/qurator/dinglehopper/cli.py +++ b/qurator/dinglehopper/cli.py @@ -84,6 +84,19 @@ def gen_diff_report(gt_in, ocr_in, css_prefix, joiner, none): ) +def json_float(value): + """Convert a float value to an JSON float. + + This is here so that float('inf') yields "Infinity", not "inf". + """ + if value == float("inf"): + return "Infinity" + elif value == float("-inf"): + return "-Infinity" + else: + return str(value) + + def process(gt, ocr, report_prefix, *, metrics=True, textequiv_level="region"): """Check OCR result against GT. @@ -107,18 +120,6 @@ def process(gt, ocr, report_prefix, *, metrics=True, textequiv_level="region"): gt_words, ocr_words, css_prefix="w", joiner=" ", none="⋯" ) - def json_float(value): - """Convert a float value to an JSON float. - - This is here so that float('inf') yields "Infinity", not "inf". - """ - if value == float("inf"): - return "Infinity" - elif value == float("-inf"): - return "-Infinity" - else: - return str(value) - env = Environment( loader=FileSystemLoader( os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates") diff --git a/qurator/dinglehopper/cli_line_dirs.py b/qurator/dinglehopper/cli_line_dirs.py index 48b86d2..4c07ce5 100644 --- a/qurator/dinglehopper/cli_line_dirs.py +++ b/qurator/dinglehopper/cli_line_dirs.py @@ -14,7 +14,7 @@ from .align import seq_align from .extracted_text import ExtractedText from .ocr_files import plain_extract from .config import Config -from .cli import gen_diff_report +from .cli import gen_diff_report, json_float def all_equal(iterable): @@ -82,20 +82,6 @@ def process(gt_dir, ocr_dir, report_prefix, *, metrics=True): gt_words, ocr_words, css_prefix="l{0}-w".format(k), joiner=" ", none="⋯" ) - - # XXX this is a copy from cli.py - def json_float(value): - """Convert a float value to an JSON float. - - This is here so that float('inf') yields "Infinity", not "inf". - """ - if value == float("inf"): - return "Infinity" - elif value == float("-inf"): - return "-Infinity" - else: - return str(value) - env = Environment( loader=FileSystemLoader( os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")