🚧 dinglehopper: Sahre json_float code
continuous-integration/drone/push Build encountered an error Details

pull/66/head
Gerber, Mike 3 years ago
parent 5b394649a7
commit f77ce857b2

@ -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"): def process(gt, ocr, report_prefix, *, metrics=True, textequiv_level="region"):
"""Check OCR result against GT. """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="" 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( env = Environment(
loader=FileSystemLoader( loader=FileSystemLoader(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates") os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")

@ -14,7 +14,7 @@ from .align import seq_align
from .extracted_text import ExtractedText from .extracted_text import ExtractedText
from .ocr_files import plain_extract from .ocr_files import plain_extract
from .config import Config from .config import Config
from .cli import gen_diff_report from .cli import gen_diff_report, json_float
def all_equal(iterable): 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="" 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( env = Environment(
loader=FileSystemLoader( loader=FileSystemLoader(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates") os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")

Loading…
Cancel
Save