HazyResearch / fonduer

A knowledge base construction engine for richly formatted data
https://fonduer.readthedocs.io/
MIT License
409 stars 77 forks source link

Initialize Drawing object every page not to carry over drawings to the following pages #488

Closed HiromuHota closed 4 years ago

HiromuHota commented 4 years ago

Description of the problems or issues

Is your pull request related to a problem? Please describe.

Expected behavior

When displaying candidates like below, the candidates are highlighted by surrounding rectangles.

from hardware_utils import entity_to_candidates
vis = Visualizer(pdf_path)
vis.display_candidates(cands)

Actual behavior

When displaying multiple candidates that span multiple pages, rectangles are drawn not on the right page but also on the following pages.

Does your pull request fix any issue.

N/A.

Description of the proposed changes

Initialize Drawing object every page not to carry over drawings to the following pages

Test plan

Run the hardware tutorial and see the result manually.

Checklist

HiromuHota commented 4 years ago

The hardware tutorial can demonstrates the issue. The blue rectangle for "BC182BG" is drawn both on the first page and on the second page.

image image

HiromuHota commented 4 years ago

This is the result with this patch:

image image

codecov-commenter commented 4 years ago

Codecov Report

Merging #488 into master will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #488   +/-   ##
=======================================
  Coverage   85.82%   85.83%           
=======================================
  Files          88       88           
  Lines        4558     4559    +1     
  Branches      848      848           
=======================================
+ Hits         3912     3913    +1     
  Misses        464      464           
  Partials      182      182           
Flag Coverage Δ
#unittests 85.83% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/fonduer/utils/visualizer.py 80.00% <100.00%> (+0.27%) :arrow_up: