22 lines
716 B
Python

from os.path import join
import json
from vidocp.table_parsing import parse_table
from vidocp.locations import TEST_DATA_DIR
from vidocp.test.config import TEST_CONFIG
from vidocp.utils.test_metrics import compute_document_score
from vidocp.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