File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 9
9
10
10
def test_visualizer ():
11
11
"""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
13
13
14
14
docs_path = "tests/data/html_simple/md.html"
15
15
pdf_path = "tests/data/pdf_simple/md.pdf"
@@ -38,12 +38,21 @@ def test_visualizer():
38
38
39
39
doc = candidate_extractor_udf .apply (doc , split = 0 )
40
40
41
- cands = doc .organizations
41
+ # Take one candidate
42
+ cand = doc .organizations [0 ]
42
43
43
- # Test visualizer
44
44
pdf_path = "tests/data/pdf_simple"
45
45
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 ])
47
56
48
57
49
58
def test_get_pdf_dim ():
You can’t perform that action at this time.
0 commit comments