mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2026-07-30 15:08:10 -04:00
feat: surface raw Tesseract diacritics message at debug level
When Tesseract reports a page with many diacritics, OCRmyPDF rewrites the message to "lots of diacritics - possibly poor OCR", which hid the original wording. Keep the interpreted hint but also emit Tesseract's raw line at debug verbosity (-v 1) so users can see exactly what Tesseract reported. Closes #1566.
This commit is contained in:
@@ -76,6 +76,10 @@
|
||||
OCRmyPDF now also logs which rasterizer rendered each page at debug verbosity
|
||||
(``-v 1``), and the ``--rasterizer`` help text explains the OCR-quality
|
||||
trade-off, to make such reports easier to diagnose. {issue}`1439`
|
||||
- When Tesseract reports a page with many diacritics, OCRmyPDF still logs its
|
||||
interpreted "lots of diacritics - possibly poor OCR" hint, but now also emits
|
||||
Tesseract's raw message at debug verbosity (``-v 1``) so the original wording
|
||||
is available for diagnosis. {issue}`1566`
|
||||
|
||||
## v17.5.0
|
||||
|
||||
|
||||
@@ -297,6 +297,10 @@ def tesseract_log_output(stream: bytes) -> None:
|
||||
continue
|
||||
elif 'diacritics' in line:
|
||||
tlog.warning("lots of diacritics - possibly poor OCR")
|
||||
# Surface the raw Tesseract message at debug level so users can see
|
||||
# exactly what Tesseract reported (e.g. the affected count) without
|
||||
# losing the interpreted hint above (#1566).
|
||||
tlog.debug(line.strip())
|
||||
elif line.startswith('OSD: Weak margin'):
|
||||
tlog.warning("unsure about page orientation")
|
||||
elif 'Error in pixScanForForeground' in line:
|
||||
|
||||
@@ -141,6 +141,14 @@ def test_tesseract_log_output(caplog, in_, logged):
|
||||
assert logged in caplog.text
|
||||
|
||||
|
||||
def test_tesseract_log_output_diacritics_raw(caplog):
|
||||
"""Diacritics branch keeps the interpreted hint and surfaces raw (#1566)."""
|
||||
caplog.set_level(logging.DEBUG)
|
||||
tesseract.tesseract_log_output(b'lots of diacritics blah blah')
|
||||
assert 'possibly poor OCR' in caplog.text # interpreted hint retained
|
||||
assert 'lots of diacritics blah blah' in caplog.text # raw message surfaced
|
||||
|
||||
|
||||
def test_tesseract_log_output_raises(caplog):
|
||||
with pytest.raises(tesseract.TesseractConfigError):
|
||||
tesseract.tesseract_log_output(b'parameter not found: moo')
|
||||
|
||||
Reference in New Issue
Block a user