From ad4ffec6299ffcfcd3796701f0f2b65124d50331 Mon Sep 17 00:00:00 2001 From: Duc Tuyen Ta Date: Wed, 23 Feb 2022 11:20:17 +0100 Subject: [PATCH 1/2] fix float division by zero --- camelot/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camelot/utils.py b/camelot/utils.py index 404c00b..d04578d 100644 --- a/camelot/utils.py +++ b/camelot/utils.py @@ -373,7 +373,7 @@ def text_in_bbox(bbox, text): continue if bbox_intersect(ba, bb): # if the intersection is larger than 80% of ba's size, we keep the longest - if (bbox_intersection_area(ba, bb) / bbox_area(ba)) > 0.8: + if (bbox_area(ba)>0) and ((bbox_intersection_area(ba, bb) / bbox_area(ba)) > 0.8): if bbox_longer(bb, ba): rest.discard(ba) unique_boxes = list(rest) From bbff5d8130fb83baaeabfd8756c0a88f634d1ec4 Mon Sep 17 00:00:00 2001 From: Duc Tuyen Ta Date: Wed, 23 Feb 2022 13:52:33 +0100 Subject: [PATCH 2/2] change logic and to or to discard area --- camelot/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camelot/utils.py b/camelot/utils.py index d04578d..a7d6d16 100644 --- a/camelot/utils.py +++ b/camelot/utils.py @@ -373,7 +373,7 @@ def text_in_bbox(bbox, text): continue if bbox_intersect(ba, bb): # if the intersection is larger than 80% of ba's size, we keep the longest - if (bbox_area(ba)>0) and ((bbox_intersection_area(ba, bb) / bbox_area(ba)) > 0.8): + if (bbox_area(ba)==0) or ((bbox_intersection_area(ba, bb) / bbox_area(ba)) > 0.8): if bbox_longer(bb, ba): rest.discard(ba) unique_boxes = list(rest)