docling-project / docling-project/docling

issue with pdf_parser.py in 2 column page(which may cause poor reading order output)

Open
#1,868 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Question
Cell detection results:
#### Before

![Image](https://github.com/user-attachments/assets/6b070821-ef8e-4f65-be10-d7bbd11dd42c)

If you check out the bottom of the image, you can see that the cells have been merged even though they are in different columns.
#### After

![Image](https://github.com/user-attachments/assets/74f29b0f-f1eb-4cfc-963d-ec25479fff10)

However, after tuning some parameters in pdf_parser.py, merging has been solved, but it causing other issues(over splitting).

#### to reproduce
I have decreased the amount of `space_width_factor_for_merge` and increased the amount of `space_width_factor_for_merge_with_space`
in `docling_parse/pdf_parser.py`
```
def _create_textline_cells(
self,
segmented_page: SegmentedPdfPage,
*,
space_width_factor_for_merge: float = 1.0,
space_width_factor_for_merge_with_space: float = 0.33,
enforce_same_font: bool = True,
_loglevel: str = "fatal",
):

... (skip) ...
# C++ binding class
data = sanitizer.create_line_cells(
space_width_factor_for_merge=space_width_factor_for_merge,
space_width_factor_for_merge_with_space=space_width_factor_for_merge_with_space,
enforce_same_font=enforce_same_font,
)
```
Over splitting issue is causing a single sentences to be splitted in to separate sentences. But, leaving the parameters as default would cause merging elements between separate columns, which will affect reading order I believe(since it’s going to be detected as one text box element).

What would be best practice that I can try to avoid merging but also over splitting issues?

[BOK이슈노트 제2023-30호_AI와 노동시장 변화.pdf](https://github.com/user-attachments/files/20977172/BOK.2023-30._AI.pdf)

...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.