2022-03-23 13:46:57 +01:00

22 lines
741 B
Python

from os.path import join
import json
from cv_analysis.table_parsing import parse_table
from cv_analysis.locations import TEST_DATA_DIR
from cv_analysis.test.config import TEST_CONFIG
from cv_analysis.utils.test_metrics import compute_document_score
from cv_analysis.utils.preprocessing import open_pdf
def test_table_parsing():
img_path = join(TEST_DATA_DIR, "table.jpg")
json_path = join(TEST_DATA_DIR, "table.json")
pages = open_pdf(img_path)[0]
result = {}
for i, page in enumerate(pages):
result.update({str(i): parse_table(page)})
with open(json_path) as f:
annotation = json.load(f)
score = compute_document_score(result, annotation)
assert score >= TEST_CONFIG.table_score_threshold