docling-project / docling-project/docling

[Bee] Words in a line break into multiple lines

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

Description

### Bug

We have a few sample documents that docling breaks words in a line into multiple lines. Below is an example (handcrafted test document with no sensitive data):

[TestOCR_chars_large3_noisy.pdf](https://github.com/user-attachments/files/20656339/TestOCR_chars_large3_noisy.pdf)

Command:

```
docling --artifacts-path=/root/.cache/docling/models ./TestOCR_chars_large3_noisy.pdf
```

The output markdown:

```md
5S5 717-868 12345678900987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHI JKL MNO PQR 123-45-6778

555 1234567890 0987654321 Abcdef ghijk lmnopqst wxyz ABC DEF GHI JKL MNO PQR 123-45-6778

555 717 -868 1234567890 0987654321 Abcde f ghi jk lmnopqst a##$ ABC DEF GHI JKL PQR XYZ

555 717-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHIJKL MNO PQR 555 717-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHI JKL MNO PQR STUV XYZ 3/24/2002 06/08/1986

5S5 717-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHI JKL MNO PQR

555 717-8 68 1234567890 0 987654321 Abcae f ghijk lmnopast wxyz ABC DEF GHI JKL MNO POR STUV XYZ

555 717-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHI JKL MNO PQR STUV XYZ 3/14/2002 06/08/1986

## 555 717-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz ! ? @##$ ABC DEF GHI JKL MNO PQR

555

717-868

1 2 34567890

0987654321

Abcde f ghijk

lmnopast

@ # # $

ABC DEF GHI JKL MNO PQR

5S5 7T7-868 1234567890 0987654321 Abcdef ghijk Imnopqst wxyz @##S ABC DEF GHI JKL MNO PQR STUV XYZ I1LL 11Il! 3/24/2002 06/08/1986
```

There are two similar lines, one is fine and the other is broken in to multiple lines:

Good line:

Image

```md
555 717-8 68 1234567890 0 987654321 Abcae f ghijk lmnopast wxyz ABC DEF GHI JKL MNO POR STUV XYZ
```

Bad line:

Image

```md
555

717-868

1 2 34567890

0987654321

Abcde f ghijk

lmnopast

@ # # $

ABC DEF GHI JKL MNO PQR
```

Note that this particular document is in low scan quality, but we also see the problem happening on some high quality documents. It seems the layout model sometimes break each word in a line to a "text" cluster. Could you explain the different behaviour, and any parameter available to fine tune for this issue?

### Steps to reproduce

Use the docling CLI to process the document attached.

### Docling version
v2.36.1

### Python version
Python 3.11.7 on Ubuntu 22.04 on x64 CPU

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.