New Tool Radar

AI PDF

How to Run Tesseract With the Right Language Code and Check the Output Reads Correctly

Run Tesseract with the language code for your document, then check the output against the page.

Schematic with three steps: List the installed languages; Run OCR with the language code; Check the output against the page.

Tesseract assumes English unless you tell it otherwise, and it uses three-character ISO 639-2 language codes with the -l option. Running a French or German document with the default English setting produces recognisable-looking text full of wrong words, so set the language first and check the result.

What you need

  • Tesseract installed with the language data for your document
  • A scanned page image
  • The correct three-character language code, such as fra for French or deu for German

Step 1: List the installed languages

Run tesseract –list-langs to confirm the language data you need is installed. Install the missing language pack before you run OCR.

Step 2: Run OCR with the language code

Run Tesseract on the image with -l and the language code, for example tesseract page.png output -l fra, and open the output text file.

Step 3: Check the output against the page

Read the first ten lines of the output against the page image. Check accented characters, proper names and common words; if they are wrong, the wrong language was used.

Worked example: synthetic OCR run on a French letter

The table below is a synthetic example. It shows the expected result of checking OCR output; no OCR was run.

Check With -l eng With -l fra
Accented words correct 3 of 10 10 of 10
Proper names correct 6 of 8 8 of 8
Lines readable 4 of 10 10 of 10
Verdict Wrong language Correct language

Expected result (UNTESTED). with the default English setting only 3 of 10 accented words are right, while with -l fra all 10 are right and all 8 proper names match. Use the document language code for every run. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • If no language is specified, English is assumed.
  • Multiple languages can be combined with a plus sign, such as eng+deu, but the order affects the result.
  • A language pack that is not installed cannot be used; check the list first.

Sources

See all