Skip to content

Commit d1b2bed

Browse files
author
Hiromu Hota
committed
Check bbox to demonstrate #443
1 parent 6286537 commit d1b2bed

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/utils/test_visualizer.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def test_visualizer():
1111
"""Unit test of visualizer using the md document."""
12-
from fonduer.utils.visualizer import Visualizer # noqa
12+
from fonduer.utils.visualizer import Visualizer, get_box # noqa
1313

1414
docs_path = "tests/data/html_simple/md.html"
1515
pdf_path = "tests/data/pdf_simple/md.pdf"
@@ -38,12 +38,21 @@ def test_visualizer():
3838

3939
doc = candidate_extractor_udf.apply(doc, split=0)
4040

41-
cands = doc.organizations
41+
# Take one candidate
42+
cand = doc.organizations[0]
4243

43-
# Test visualizer
4444
pdf_path = "tests/data/pdf_simple"
4545
vis = Visualizer(pdf_path)
46-
vis.display_candidates([cands[0]])
46+
47+
# Test bounding boxes
48+
boxes = [get_box(mention.context) for mention in cand.get_mentions()]
49+
for box in boxes:
50+
assert box.top <= box.bottom
51+
assert box.left <= box.right
52+
assert boxes == [mention.context.get_bbox() for mention in cand.get_mentions()]
53+
54+
# Test visualizer
55+
vis.display_candidates([cand])
4756

4857

4958
def test_get_pdf_dim():

0 commit comments

Comments
 (0)