parent
766260d5d9
commit
a94c350a7b
|
|
@ -117,14 +117,10 @@ class Lattice:
|
|||
hmask, h_segments = find_lines(threshold, direction='horizontal',
|
||||
scale=self.scale)
|
||||
|
||||
if self.table_area:
|
||||
if self.fill:
|
||||
if self.table_area is not None:
|
||||
if self.fill is not None:
|
||||
if len(self.table_area) != len(self.fill):
|
||||
raise ValueError("message")
|
||||
if len(self.jtol) == 1 and self.jtol[0] == 2:
|
||||
self.jtol = self.jtol * len(self.table_area)
|
||||
if len(self.mtol) == 1 and self.mtol[0] == 2:
|
||||
self.mtol = self.mtol * len(self.table_area)
|
||||
areas = []
|
||||
for area in self.table_area:
|
||||
x1, y1, x2, y2 = area.split(",")
|
||||
|
|
@ -139,6 +135,11 @@ class Lattice:
|
|||
contours = find_table_contours(vmask, hmask)
|
||||
table_bbox = find_table_joints(contours, vmask, hmask)
|
||||
|
||||
if len(self.jtol) == 1 and self.jtol[0] == 2:
|
||||
self.jtol = self.jtol * len(table_bbox)
|
||||
if len(self.mtol) == 1 and self.mtol[0] == 2:
|
||||
self.mtol = self.mtol * len(table_bbox)
|
||||
|
||||
if self.debug:
|
||||
self.debug_images = (img, table_bbox)
|
||||
|
||||
|
|
@ -225,7 +226,7 @@ class Lattice:
|
|||
score = get_score([[50, rerror], [50, cerror]])
|
||||
table_data['score'] = score
|
||||
|
||||
if self.fill:
|
||||
if self.fill is not None:
|
||||
table = fill_spanning(table, fill=self.fill[table_no])
|
||||
ar = table.get_list()
|
||||
if table_rotation == 'left':
|
||||
|
|
|
|||
|
|
@ -231,17 +231,13 @@ class Stream:
|
|||
self.debug_text = [(t.x0, t.y0, t.x1, t.y1) for t in text]
|
||||
return None
|
||||
|
||||
if self.table_area:
|
||||
if self.columns:
|
||||
if self.table_area is not None:
|
||||
if self.columns is not None:
|
||||
if len(self.table_area) != len(self.columns):
|
||||
raise ValueError("message")
|
||||
if self.ncolumns:
|
||||
if self.ncolumns is not None:
|
||||
if len(self.table_area) != len(self.ncolumns):
|
||||
raise ValueError("message")
|
||||
if len(self.ytol) == 1 and self.ytol[0] == 2:
|
||||
self.ytol = self.ytol * len(self.table_area)
|
||||
if len(self.mtol) == 1 and self.mtol[0] == 2:
|
||||
self.mtol = self.mtol * len(self.table_area)
|
||||
table_bbox = {}
|
||||
for area in self.table_area:
|
||||
x1, y1, x2, y2 = area.split(",")
|
||||
|
|
@ -253,6 +249,11 @@ class Stream:
|
|||
else:
|
||||
table_bbox = {(0, 0, width, height): None}
|
||||
|
||||
if len(self.ytol) == 1 and self.ytol[0] == 2:
|
||||
self.ytol = self.ytol * len(table_bbox)
|
||||
if len(self.mtol) == 1 and self.mtol[0] == 2:
|
||||
self.mtol = self.mtol * len(table_bbox)
|
||||
|
||||
page = {}
|
||||
tables = {}
|
||||
table_no = 0
|
||||
|
|
@ -268,7 +269,7 @@ class Stream:
|
|||
elements = [len(r) for r in rows_grouped]
|
||||
|
||||
guess = False
|
||||
if self.columns and self.columns[table_no] != "":
|
||||
if self.columns is not None and self.columns[table_no] != "":
|
||||
# user has to input boundary columns too
|
||||
# take (0, width) by default
|
||||
# similar to else condition
|
||||
|
|
@ -277,7 +278,7 @@ class Stream:
|
|||
cols = [(float(cols[i]), float(cols[i + 1]))
|
||||
for i in range(0, len(cols) - 1)]
|
||||
else:
|
||||
if self.ncolumns and self.ncolumns[table_no] != -1:
|
||||
if self.ncolumns is not None and self.ncolumns[table_no] != -1:
|
||||
ncols = self.ncolumns[table_no]
|
||||
cols = [(t.x0, t.x1)
|
||||
for r in rows_grouped if len(r) == ncols for t in r]
|
||||
|
|
|
|||
Loading…
Reference in New Issue