docling-project / docling-project/docling

PDF paragraph split into two texts items mid-sentence (leftover last line)

Open
#4,132 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
3d 4h
Merged PRs (30d)
95

Description

### Bug
A single PDF paragraph is exported as two texts items, cut mid-sentence. The last line of the paragraph becomes its own label: "text" item.

This is a layout grouping bug, not a request for sentence splitting. I know texts is layout boxes. Here Docling draws two boxes for one paragraph: a large block plus a leftover last line. Downstream tools then see a broken sentence.

Example 1 (page 1)

texts[5] ends with no period:
… Ein bedeutender Meilenstein war die Mondlandung im Jahr 1969. Die Apollo Mission brachte

texts[6] is only the leftover line (starts lowercase):
erstmals Menschen auf die Oberfläche des Mondes.

Same page. Boxes sit one under the other (BOTTOMLEFT):
texts[5] bbox t≈441.43, b≈296.20 (tall)
texts[6] bbox t≈293.63, b≈280.35 (thin strip).
orig equals text on both (born-digital PDF, not OCR).

Example 2 (same document, page 1)

texts[8] ends: … ausgestoßen wird entsteht eine Kraft die die
texts[9]: Rakete nach vorne beschleunigt.

Expected: one texts item for the whole paragraph, ending at Mondes. / beschleunigt.

Actual: two items; the second is a last-line fragment that continues the first.

Document JSON: schema_name: DoclingDocument, version: 1.10.0. Conversion via docling-serve (POST /v1/convert/file/async, from_formats=pdf, to_formats=json only; no custom pdf_backend). Image: quay.io/docling-project/docling-serve-cpu:latest.
...

### Steps to reproduce
1. Convert the PDF with default PDF backend (json output), e.g. docling-serve:

curl -X POST "http://127.0.0.1:5001/v1/convert/file" \
-F "files=@pleasewritesomelineslikeabove.pdf;type=application/pdf" \
-F "from_formats=pdf" \
-F "to_formats=json"

(Async is the same: /v1/convert/file/async, then poll /v1/status/poll/{task_id}, then GET /v1/result/{task_id}.)

2. Open document.json_content.texts.

3. Compare item 5 and 6 (and 8 / 9). First item does not end with .!?; next item starts with a lowercase letter and is the last line of the same paragraph.

### Docling version

Docling version: 2.115.0
Docling Core version: 2.87.1
Docling IBM Models version: 3.13.3
Docling Parse version: 7.8.1
Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.34

### Python version
Python: cpython-312 (3.12.13)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the report with the supplied PDF and default PDF conversion, then inspect document.json_content.texts around items 5/6 and 8/9. Trace the layout grouping path that produces these text boxes; done means each leftover lowercase final line is grouped with its preceding paragraph without breaking unrelated text items.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.