Skip to content

Commit

Permalink
Fix for table span compute in vlm_pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Maksym Lysak <[email protected]>
  • Loading branch information
Maksym Lysak committed Jan 10, 2025
1 parent 81b1613 commit b376d83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docling/pipeline/vlm_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,23 @@ def parse_texts(texts, tokens):
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):
Expand Down
1 change: 1 addition & 0 deletions docs/examples/minimal_smol_docling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# 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
Expand Down

0 comments on commit b376d83

Please sign in to comment.