diff --git a/README.md b/README.md index 30fe0693..4a2b66b1 100644 --- a/README.md +++ b/README.md @@ -92,10 +92,7 @@ brew install tesseract-lang You can then pass the `-l LANG` argument to OCRmyPDF to give a hint as to what languages it should search for. Multiple languages can be requested. -OCRmyPDF supports Tesseract 4.0 and the beta versions of Tesseract 5.0. It will -automatically use whichever version it finds first on the `PATH` environment -variable. On Windows, if `PATH` does not provide a Tesseract binary, we use -the highest version number that is installed according to the Windows Registry. +OCRmyPDF supports Tesseract 4.1.1+. It will automatically use whichever version it finds first on the `PATH` environment variable. On Windows, if `PATH` does not provide a Tesseract binary, we use the highest version number that is installed according to the Windows Registry. ## Documentation and support diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 1360d17e..581c6474 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -283,7 +283,7 @@ argument. (Normally, OCRmyPDF will exit with an error if asked to modify a file with OCR.) This may be helpful for users who want to take advantage of accuracy -improvements in Tesseract 4.0 for files they previously OCRed with an +improvements in Tesseract for files they previously OCRed with an earlier version of Tesseract and OCRmyPDF. .. code-block:: bash diff --git a/docs/installation.rst b/docs/installation.rst index cb006566..a352ac6b 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -418,7 +418,7 @@ Native Windows You must install the following for Windows: * Python 3.8 (64-bit) or later -* Tesseract 4.0 or later +* Tesseract 4.1.1 or later * Ghostscript 9.50 or later Using the `Chocolatey `_ package manager, install the @@ -481,7 +481,7 @@ Cygwin64 First install the the following prerequisite Cygwin packages using ``setup-x86_64.exe``:: - python37 (or later) + python38 (or later) python3?-devel python3?-pip python3?-lxml @@ -618,7 +618,7 @@ The following versions are required: - Python 3.8 or newer - Ghostscript 9.50 or newer -- Tesseract 4.0.0 or newer +- Tesseract 4.1.1 or newer - jbig2enc 0.29 or newer - pngquant 2.5 or newer - unpaper 6.1 diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py index 78ec318a..adb1ec17 100644 --- a/src/ocrmypdf/_exec/tesseract.py +++ b/src/ocrmypdf/_exec/tesseract.py @@ -33,7 +33,7 @@ HOCR_TEMPLATE = """ - + @@ -114,15 +114,6 @@ def version() -> str: return get_version('tesseract', regex=r'tesseract\s(.+)') -def has_user_words() -> bool: - """Does Tesseract have --user-words capability? - - Not available in 4.0, but available in 4.1. Also available in 3.x, but - we no longer support 3.x. - """ - return version() >= '4.1' - - def has_thresholding() -> bool: """Does Tesseract have -c thresholding method capability?""" return version() >= '5.0' diff --git a/src/ocrmypdf/builtin_plugins/tesseract_ocr.py b/src/ocrmypdf/builtin_plugins/tesseract_ocr.py index d9e24e4e..8372577c 100644 --- a/src/ocrmypdf/builtin_plugins/tesseract_ocr.py +++ b/src/ocrmypdf/builtin_plugins/tesseract_ocr.py @@ -43,7 +43,7 @@ def add_options(parser): metavar='MODE', choices=range(0, 4), help=( - "Set Tesseract 4.0+ OCR engine mode: " + "Set Tesseract 4+ OCR engine mode: " "0 - original Tesseract only; " "1 - neural nets LSTM only; " "2 - Tesseract + LSTM; " @@ -93,7 +93,7 @@ def check_options(options): program='tesseract', package={'linux': 'tesseract-ocr'}, version_checker=tesseract.version, - need_version='4.0.0-beta.1', # using backport for Travis CI + need_version='4.1.1', # Ubuntu 20.04 version version_parser=tesseract.TesseractVersion, ) @@ -101,11 +101,6 @@ def check_options(options): if options.pdf_renderer == 'auto': options.pdf_renderer = 'sandwich' - if not tesseract.has_user_words() and (options.user_words or options.user_patterns): - log.warning( - "Tesseract 4.0 (which you have installed) ignores --user-words and " - "--user-patterns, so these arguments have no effect." - ) if not tesseract.has_thresholding() and options.tesseract_thresholding != 0: log.warning( "The installed version of Tesseract does not support changes to its " diff --git a/tests/plugins/tesseract_cache.py b/tests/plugins/tesseract_cache.py index b32d2498..bc2750f9 100644 --- a/tests/plugins/tesseract_cache.py +++ b/tests/plugins/tesseract_cache.py @@ -21,7 +21,7 @@ were produced. Certain operations are not cached and routed to Tesseract OCR directly. -Assumes Tesseract 4.0.0-alpha or higher. +Assumes Tesseract 4+. """ diff --git a/tests/plugins/tesseract_debug_rotate.py b/tests/plugins/tesseract_debug_rotate.py index f278cb3f..1e10cfb7 100644 --- a/tests/plugins/tesseract_debug_rotate.py +++ b/tests/plugins/tesseract_debug_rotate.py @@ -27,7 +27,7 @@ HOCR_TEMPLATE = ''' - + @@ -46,7 +46,7 @@ HOCR_TEMPLATE = ''' class FixedRotateNoopOcrEngine(OcrEngine): @staticmethod def version(): - return '4.0.0' + return '4.1.1' @staticmethod def creator_tag(options): diff --git a/tests/plugins/tesseract_noop.py b/tests/plugins/tesseract_noop.py index 4dd18dfd..68a0bfe6 100644 --- a/tests/plugins/tesseract_noop.py +++ b/tests/plugins/tesseract_noop.py @@ -25,7 +25,7 @@ HOCR_TEMPLATE = ''' - + @@ -44,7 +44,7 @@ HOCR_TEMPLATE = ''' class NoopOcrEngine(OcrEngine): @staticmethod def version(): - return '4.0.0' + return '4.1.1' @staticmethod def creator_tag(options): diff --git a/tests/test_main.py b/tests/test_main.py index c975665b..d4e3135e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -539,7 +539,6 @@ def test_tesseract_config_invalid(renderer, resources, invalid_tess_config, outp assert p.returncode == ExitCode.invalid_config -@pytest.mark.skipif(not tesseract.has_user_words(), reason='not functional until 4.1.0') def test_user_words_ocr(resources, outdir): # Does not actually test if --user-words causes output to differ word_list = outdir / 'wordlist.txt' diff --git a/tests/test_validation.py b/tests/test_validation.py index ee29f312..192925f8 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -87,22 +87,6 @@ def test_optimizing(caplog): assert 'will be ignored because' in caplog.text -def test_user_words(caplog): - with patch('ocrmypdf._exec.tesseract.has_user_words', return_value=False): - vd.check_options(*make_opts_pm(user_words='foo')) - assert ( - 'Tesseract 4.0 (which you have installed) ignores --user-words' - in caplog.text - ) - caplog.clear() - with patch('ocrmypdf._exec.tesseract.has_user_words', return_value=True): - vd.check_options(*make_opts_pm(user_patterns='foo')) - assert ( - 'Tesseract 4.0 (which you have installed) ignores --user-words' - not in caplog.text - ) - - def test_pillow_options(): vd.check_options_pillow(make_opts(max_image_mpixels=0)) @@ -213,37 +197,38 @@ def test_version_comparison(): program="tesseract", package="tesseract", version_checker=lambda: '4.0.0-beta.1', - need_version='4.0.0', + need_version='4.1.1', version_parser=TesseractVersion, ) vd.check_external_program( program="tesseract", package="tesseract", version_checker=lambda: 'v5.0.0-alpha.20200201', - need_version='4.0.0', + need_version='4.1.1', version_parser=TesseractVersion, ) vd.check_external_program( program="tesseract", package="tesseract", version_checker=lambda: '5.0.0-rc1.20211030', - need_version='4.0.0', + need_version='4.1.1', version_parser=TesseractVersion, ) vd.check_external_program( program="tesseract", package="tesseract", - version_checker=lambda: 'v4.0.0.20181030', # Some Windows builds use this format - need_version='4.0.0', - version_parser=TesseractVersion, - ) - vd.check_external_program( - program="tesseract", - package="tesseract", - version_checker=lambda: '4.1.1-rc2-25-g9707', - need_version='4.0.0', + version_checker=lambda: 'v4.1.1.20181030', # Some Windows builds use this format + need_version='4.1.1', version_parser=TesseractVersion, ) + with pytest.raises(MissingDependencyError): + vd.check_external_program( + program="tesseract", + package="tesseract", + version_checker=lambda: '4.1.1-rc2-25-g9707', + need_version='4.1.1', + version_parser=TesseractVersion, + ) with pytest.raises(MissingDependencyError): vd.check_external_program( program="dummy_fails",