docling-project / docling-project/docling

Layout misclassifies dotted poetic line as formula, export leaves text empty

Open
#3,780 7 comments 0 reactions 0 assignees View on GitHub
bug docling-document
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug

A **poetic line with dot leaders** (`................ жизни картиновой ................ понесло Константиново ».`) is **misclassified as `formula`** by the layout model (OCR text with ellipsis, not a math formula).

The block is exported as `FormulaItem` with OCR text in `orig`, but **`text` is empty / missing**. Parse returns **success**, yet `json_content` fails `DoclingDocument.model_validate_json()`. Chunking then fails: `Input document parsed.json is not valid.`

Setting `text` from `orig` fixes validation and chunking.

**Root cause (as seen downstream):** classification error → invalid schema export.

### Steps to reproduce

1. Parse attached **1-page PDF** ([misprocessed.pdf](https://github.com/user-attachments/files/29854351/misprocessed.pdf), poetic excerpt with dot leaders)
2. In `json_content`, find item with `"label": "formula"` and dotted Russian text in `orig`, no `text`.
3. Validate: ```python
from docling_core.types.doc import DoclingDocument
DoclingDocument.model_validate_json(open("parsed.json", "rb").read())
```
→ fails (`text` required on formula item).
4. Chunk same JSON via `/v1/chunk/hybrid/source/async` (`from_formats: ["json_docling"]`) → 0 chunks.
5. Add `"text": ""` → validation and chunking succeed.

Parsing options used:

```
{
"do_ocr": false,
"do_formula_enrichment": false,
"do_code_enrichment": false,
"to_formats": ["json", "text"]
}
```

**Minimal fragment:**
```json
{
"self_ref": "#/texts/5",
"parent": {
"$ref": "#/body"
},
"content_layer": "body",
"label": "formula",
"prov": [omitted],
"orig": "..................... жизни картиновой ..................... понесло Константиново »."
},
{
"self_ref": "#/texts/6",
"parent": {
"$ref": "#/body"
},
"content_layer": "body",
"label": "text",
"prov": [omitted],
"orig": "(Восп., 2, 131)",
"text": "(Восп., 2, 131)"
},
```

**Expected:** classify as text/paragraph; if labeled `formula`, populate `text` (e.g. from `orig`) so export passes schema validation.

### Docling and Python versions

`docling-serve` output:

```
Docling version: 2.107.0
Docling Core version: 2.85.0
Docling IBM Models version: 3.13.3
Docling Parse version: 7.2.0
Python: cpython-312 (3.12.13)
Platform: Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.34
```

**Attachments:** 1-page PDF + JSON fragment above.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the attached 1-page PDF and the listed parsing options, then inspect the formula item in json_content. Start with DoclingDocument.model_validate_json() and the /v1/chunk/hybrid/source/async endpoint to trace why the exported item lacks text. Done means the poetic line is classified as text, or a formula export includes text from orig, so JSON validation and chunking succeed.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.