Fix for table span compute in vlm_pipeline

Signed-off-by: Maksym Lysak <mly@zurich.ibm.com>
This commit is contained in:
Maksym Lysak 2025-01-10 16:30:12 +01:00
parent ef079e4e78
commit 01c46e24b1
2 changed files with 7 additions and 8 deletions

View File

@ -221,25 +221,23 @@ class VlmPipeline(PaginatedPipeline):
c_idx = 0
def count_right(tokens, c_idx, r_idx, which_tokens):
# for t in tokens:
# print(t)
span = 1
span = 0
c_idx_iter = c_idx
while tokens[r_idx][c_idx_iter] in which_tokens:
c_idx_iter += 1
if c_idx_iter >= len(tokens[r_idx]):
break
span += 1
if c_idx_iter >= len(tokens[r_idx]):
return span
return span
def count_down(tokens, c_idx, r_idx, which_tokens):
span = 1
span = 0
r_idx_iter = r_idx
while tokens[r_idx_iter][c_idx] in which_tokens:
r_idx_iter += 1
if r_idx_iter >= len(tokens):
break
span += 1
if r_idx_iter >= len(tokens):
return span
return span
for i, text in enumerate(texts):

View File

@ -9,6 +9,7 @@ from docling.pipeline.vlm_pipeline import VlmPipeline
# source = "https://arxiv.org/pdf/2408.09869" # document per local path or URL
# source = "tests/data/2305.03393v1-pg9-img.png"
source = "tests/data/2305.03393v1-pg9.pdf"
# source = "page.png"
pipeline_options = PdfPipelineOptions()
pipeline_options.generate_page_images = True