Skip to content

[MRG] fix list index out of range and float division by zero bug #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions camelot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

_VALID_URLS = set(uses_relative + uses_netloc + uses_params)
_VALID_URLS.discard("")
SMOOTHING_FACTOR = 0.000001


# https://github.com/pandas-dev/pandas/blob/master/pandas/io/common.py
Expand Down Expand Up @@ -373,7 +374,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_intersection_area(ba, bb) / (bbox_area(ba) + SMOOTHING_FACTOR)) > 0.8:
if bbox_longer(bb, ba):
rest.discard(ba)
unique_boxes = list(rest)
Expand Down Expand Up @@ -622,8 +623,12 @@ def split_textline(table, textline, direction, flag_size=False, strip_text=""):
break
else:
# TODO: add test
if cut == x_cuts[-1]:
cut_text.append((r, cut[0] + 1, obj))
if cut == x_cuts[-1] :
col = cut[0]
#avoid list out of range
if col + 1 < len(table.cols) :
col = cut[0] + 1
cut_text.append((r, col, obj))
elif isinstance(obj, LTAnno):
cut_text.append((r, cut[0], obj))
elif direction == "vertical" and not textline.is_empty():
Expand Down