ftu-VietFinTab / scripts /test_export_html.py
dinhanhx's picture
Claude Opus 5.5
Add conversion scripts (YOLO, COCO, HTML) and tests
eb58dca
Raw History Blame Contribute Delete
592 Bytes
# /// script
# requires-python = ">=3.10"
# dependencies = []
# ///
from export_html import build_html
rows = [(0, 0, 100, 10), (0, 10, 100, 20)]
cols = [(0, 0, 50, 20), (50, 0, 100, 20)]
ocr = [{"text": "A&B", "bbox": [0, 0, 40, 9]}, {"text": "x", "bbox": [60, 12, 70, 19]},
{"text": "y", "bbox": [5, 12, 15, 19]}]
h = build_html(rows, cols, [(0, 0, 100, 10)], ocr) # first row merged
assert '<tr><td colspan="2">A&amp;B</td></tr>' in h, h
assert "<tr><td>y</td><td>x</td></tr>" in h, h
assert "<td" in build_html(rows, cols, [], []) # no text -> empty cells, no crash
print("ok")