Merge 1da6be8863 into 644bbe7c6d
commit
7e619e6c81
|
|
@ -186,23 +186,24 @@ class Lattice(BaseParser):
|
||||||
"""
|
"""
|
||||||
indices = []
|
indices = []
|
||||||
for r_idx, c_idx, text in idx:
|
for r_idx, c_idx, text in idx:
|
||||||
for d in shift_text:
|
if r_idx < len(t.cells) and c_idx < len(t.cells[r_idx]):
|
||||||
if d == "l":
|
for d in shift_text:
|
||||||
if t.cells[r_idx][c_idx].hspan:
|
if d == "l":
|
||||||
while not t.cells[r_idx][c_idx].left:
|
if t.cells[r_idx][c_idx].hspan:
|
||||||
c_idx -= 1
|
while not t.cells[r_idx][c_idx].left:
|
||||||
if d == "r":
|
c_idx -= 1
|
||||||
if t.cells[r_idx][c_idx].hspan:
|
if d == "r":
|
||||||
while not t.cells[r_idx][c_idx].right:
|
if t.cells[r_idx][c_idx].hspan:
|
||||||
c_idx += 1
|
while not t.cells[r_idx][c_idx].right:
|
||||||
if d == "t":
|
c_idx += 1
|
||||||
if t.cells[r_idx][c_idx].vspan:
|
if d == "t":
|
||||||
while not t.cells[r_idx][c_idx].top:
|
if t.cells[r_idx][c_idx].vspan:
|
||||||
r_idx -= 1
|
while not t.cells[r_idx][c_idx].top:
|
||||||
if d == "b":
|
r_idx -= 1
|
||||||
if t.cells[r_idx][c_idx].vspan:
|
if d == "b":
|
||||||
while not t.cells[r_idx][c_idx].bottom:
|
if t.cells[r_idx][c_idx].vspan:
|
||||||
r_idx += 1
|
while not t.cells[r_idx][c_idx].bottom:
|
||||||
|
r_idx += 1
|
||||||
indices.append((r_idx, c_idx, text))
|
indices.append((r_idx, c_idx, text))
|
||||||
return indices
|
return indices
|
||||||
|
|
||||||
|
|
@ -373,7 +374,8 @@ class Lattice(BaseParser):
|
||||||
table, indices, shift_text=self.shift_text
|
table, indices, shift_text=self.shift_text
|
||||||
)
|
)
|
||||||
for r_idx, c_idx, text in indices:
|
for r_idx, c_idx, text in indices:
|
||||||
table.cells[r_idx][c_idx].text = text
|
if r_idx < len(table.cells) and c_idx < len(table.cells[r_idx]):
|
||||||
|
table.cells[r_idx][c_idx].text = text
|
||||||
accuracy = compute_accuracy([[100, pos_errors]])
|
accuracy = compute_accuracy([[100, pos_errors]])
|
||||||
|
|
||||||
if self.copy_text is not None:
|
if self.copy_text is not None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue