Tools,

Fraktur OCR: which Tesseract model reads old German type

94%

words right with frak2021 or german_print

For modern print scans: $0.006 a page

The German model reads ſ as f

One line from a 1920 novel. Bold letters are wrong:

Model Printed
Proofread Diesen sah ich ebenso selten wie früher
eng Diefen jah ich ebenfo felten wie friiher
deu Diefen fah ich ebenso felten wie früher
frak2021, ſ made s Diesen sah ich ebenso selten wie früher

The deu model has no long s (ſ) in its letter set. Fraktur models print it, and one line of Python turns it into a plain s.

Six free models, the same 46 pages

Proofread scans from 10 books, 1761 to 1935. Words right, of 12,269:

Model Size Words right
eng 4.1 MB 38.9%
deu 1.5 MB 56.1%
script/Fraktur 10.9 MB 78.8%
deu_latf (was frk) 6.4 MB 80.2%
frak2021 5.1 MB 93.8%
german_print 0.5 MB 94.2%

The last two come from the Mannheim University Library, and they tied: german_print won 20 pages, frak2021 won 17. frak2021 beat deu_latf on every page.

How I tested it
  • Books: de.wikisource index pages that mention Fraktur, one book per author, picked by a seeded shuffle, not by me. Pages: proofread and then checked by a second person.
  • One plain tesseract run per page and model, default settings, on 1920 px wide scans.
  • A word counts when it is found in order, exact case and punctuation. First, both texts follow the Wikisource rules: ſ as s, I and J as one letter, the Fraktur hyphen as -, Ä as Ae, and split words joined.
  • The training lists of both Mannheim models name none of these books. I searched them by title and author.
Speed, and the hardest book
  • frak2021 took 0.94 s a page (median). deu_latf took 1.55 s.
  • A 1916 booklet with heavy, smeared ink: frak2021 got 68.1% and deu_latf 34.5%. On the other 9 books, frak2021 got 92.3% or more.

Install frak2021 and run it

One 5.1 MB file, in a folder of your own:

mkdir -p ~/tessdata
curl -L -o ~/tessdata/frak2021.traineddata \
  https://ub-backup.bib.uni-mannheim.de/~stweil/tesstrain/frak2021/tessdata_fast/frak2021_0.905.traineddata
tesseract page.jpg page --tessdata-dir ~/tessdata -l frak2021

In Python, with pytesseract:

import os

import pytesseract

TESSDATA = os.path.expanduser("~/tessdata")
text = pytesseract.image_to_string(
    "page.jpg", lang="frak2021", config=f"--tessdata-dir {TESSDATA}"
)
text = text.replace("ſ", "s")  # long s to a plain s

OCRmyPDF needs the configs folder too

With only the model in the folder, OCRmyPDF stopped with TesseractConfigError, exit code 9. Copy Tesseract's own configs folder next to it. The first line shows where yours is:

tesseract --list-langs | head -1
cp -R /opt/homebrew/share/tessdata/configs ~/tessdata/
TESSDATA_PREFIX=~/tessdata ocrmypdf -l frak2021 in.pdf out.pdf

92.9% words right with frak2021

56.4% with -l deu

One PDF of all 46 scans. Each run took about 16 s.

The frk trap: a 20-byte file

tessdata renamed frk to deu_latf: the same file, byte for byte. On the main branch, frk.traineddata is now a 20-byte stub that names the new file. Tesseract still lists it:

With the stub What happened
-l frk Failed loading language 'frk', exit 1
-l deu+frk The same warning, then deu alone, exit 0
pytesseract get_languages() lists frk. deu+frk raises no error
ocrmypdf -l frk Exit 7

Download deu_latf.traineddata instead, or frak2021. A real model is megabytes, not bytes.

What I did not test
  • Windows and Linux. One Mac, Tesseract 5.5.4.
  • The larger tessdata_best files of these models.
  • Cleaning the image before OCR.
  • Antiqua (roman type) pages. See the German test.
  • Handwriting such as Kurrent or Sütterlin.
Sources

Our Actor has no Fraktur model

Our Apify Actor reads German with deu. On these pages it got 56.3% of the words right, about what deu got alone. For Fraktur, run frak2021 as above.

Two ways to skip the work

Run it yourself. Our Apify Actor turns scanned PDFs into Markdown, tables included.

Try the Actor

Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.

Get one page free

Questions people ask

Which Tesseract language code reads Fraktur?

deu_latf, the new name for frk. On my 46 pages it got 80.2% of the words right. frak2021, from the Mannheim University Library, got 93.8%.

Why does Tesseract read the long s as f?

The deu model has no long s in its letter set, so it picks a letter it knows, often f. A Fraktur model prints the long s, and text.replace("ſ", "s") makes it a plain s.

Can OCRmyPDF read Fraktur?

Yes. Put frak2021 and Tesseract's configs folder in one folder, point TESSDATA_PREFIX at it, and use -l frak2021. It got 92.9% of the words right on my 46 pages.