docling-project / docling-project/docling
Incorrect Accentuation of Portuguese Text After OCR with EasyOCR
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 95
Description
### Bug
I am encountering an issue with incorrect accentuation of Portuguese text when using Docling with EasyOCR to extract content from PDF files. While EasyOCR itself accurately recognizes accented characters, the output generated by Docling's export_to_markdown() (and other export methods) displays these characters incorrectly.
### Steps to reproduce
PDF page:

#### Evidence of Correct EasyOCR Recognition:
To isolate the issue, I tested EasyOCR directly on a screenshot of the same PDF. The accentuations were perfectly identified.
```python
import easyocr
reader = easyocr.Reader(['pt'])
results = reader.readtext('image.png')
for bbox, text, confidence in results:
print(text)
```
Output:
```
Sislemas
Operacionais
Sumário
Organização da disciplina
2. Introdução aos sistemas operacionais
3
Evolução dos sistemas operacionais
Revisão sobre hardware
5. Considerações finais
```
#### Docling's Incorrect Output:
However, when using Docling, words like "Introdução" and "Organização" are output as "Introdu¸˜o" and "Organiza¸ c˜o", respectively.
Here is the code I am using (based on the docs example):
```python
import json
import logging
import time
from pathlib import Path
from docling.backend.pypdfium2_backend import PyPdfiumDocumentBackend
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import (
PdfPipelineOptions,
)
from docling.document_converter import DocumentConverter, PdfFormatOption
_log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
input_doc_path = Path("./input.pdf")
pipeline_options = PdfPipelineOptions()
pipeline_options.ocr_options.lang = ["pt"]
doc_converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=pipeline_options, backend=PyPdfiumDocumentBackend
)
}
)
start_time = time.time()
conv_result = doc_converter.convert(input_doc_path)
end_time = time.time() - start_time
_log.info(f"Document converted in {end_time:.2f} seconds.")
## Export results
output_dir = Path("scratch")
output_dir.mkdir(parents=True, exist_ok=True)
doc_filename = conv_result.input.file.stem
# Export Markdown format:
with (output_dir / f"{doc_filename}.md").open("w", encoding="utf-8") as fp:
fp.write(conv_result.document.export_to_markdown())
```
Output:
```
## Sum´ario
- 1. Organiza¸c˜ao da disciplina
- 2. Introdu¸c˜ao aos sistemas operacionais
- 3. Evolu¸c˜ao dos sistemas operacionais
- 4. Revis˜ao sobre hardware
- 5. Considera¸c˜oes finais
2/69
```
### Docling version
Docling version: 2.28.4
Docling Core version: 2.25.0
Docling IBM Models version: 3.4.1
Docling Parse version: 4.0.0
Python: cpython-312 (3.12.2)
Platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
### Python version
Python 3.12.2
Contributor guide
Research direction
Reproduce the issue with the provided EasyOCR language setting, PdfPipelineOptions, DocumentConverter, PyPdfiumDocumentBackend, and export_to_markdown() entry points. Trace where correctly recognized Portuguese characters change during conversion or export; done means accented text remains correct in the generated Markdown and other export formats.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100