Add atol and fix variable declaration

pull/2/head
Vinayak Mehta 2018-11-23 02:44:55 +05:30
parent 9b5782f9ba
commit 9b67b271e4
1 changed files with 7 additions and 7 deletions

View File

@ -55,7 +55,7 @@ class TextEdges(object):
def find(self, x_coord, align): def find(self, x_coord, align):
for i, te in enumerate(self._textedges[align]): for i, te in enumerate(self._textedges[align]):
if np.isclose(te.x, x_coord): if np.isclose(te.x, x_coord, atol=0.5):
return i return i
return None return None
@ -134,17 +134,17 @@ class TextEdges(object):
# drawback: table areas that have paragraphs to their sides # drawback: table areas that have paragraphs to their sides
# will include the paragraphs too. # will include the paragraphs too.
for tl in textlines: for tl in textlines:
found = None
for area in table_areas: for area in table_areas:
found = None
# check for overlap # check for overlap
if tl.y0 >= area[1] and tl.y1 <= area[3]: if tl.y0 >= area[1] and tl.y1 <= area[3]:
found = area found = area
break break
if found is not None: if found is not None:
table_areas.pop(found) table_areas.pop(found)
updated_area = ( updated_area = (
min(tl.x0, found[0]), min(tl.y0, found[1]), max(found[2], tl.x1), max(found[3], tl.y1)) min(tl.x0, found[0]), min(tl.y0, found[1]), max(found[2], tl.x1), max(found[3], tl.y1))
table_areas[updated_area] = None table_areas[updated_area] = None
# add some padding to table areas # add some padding to table areas
table_areas_padded = {} table_areas_padded = {}