DEV Community

Cover image for Train OCR on Pre-Revolution Russian Texts? I’ve Got a Dataset for You! 🧐📜
Boris Orekhov
Boris Orekhov

Posted on

Train OCR on Pre-Revolution Russian Texts? I’ve Got a Dataset for You! 🧐📜

The problem: Old Russian orthography is a different beast

If you’ve ever tried to OCR a book published in Russia before 1917, you quickly run into a wall. The alphabet had four extra letters (ѣ, і, ѳ, ѵ), plus spelling rules that disappeared after the orthographic reform. Modern OCR engines trained on contemporary Russian will choke on words like «съ», «онѣ», or «всѣхъ».

But digitizing historical texts is crucial for linguists, historians, and even NLP researchers who want to train models on original sources. So what do we do?

The solution: A clean, paired dataset

I published russian-old-orthography-ocr on Hugging Face. It contains source images and human‑extracted ground‑truth texts from 19th‑century Russian publications – all in original pre‑reform spelling.

  • Long texts (novels, stories) → PDF + TXT in books-pdf-plaintext/
  • Single‑page samples → PNG + TXT in pages-img-plaintext/

File pairs share the same base name, e.g.

afanasjev-chuzhbinskij_a_s.peterburgskie_igroki.pdf and .txt, or

300_page_image_009.png and 300_page_text_009.txt.

Why this dataset rocks for developers

Ready to train – images + ground truth, no scraping or alignment headaches

Covers real 19th‑century typography – including tricky pre‑reform letters

Perfect for fine‑tuning Tesseract, TrOCR, or any CRNN model

Also useful for NLP – language modelling, old‑to‑modern conversion, historical text analysis

Old orthography, demystified

Those four extinct letters have their own Unicode code points, but you also have to handle the old rules (e.g., hard sign at the end of words, и vs і). I wrote a Python package to convert between old and modern orthography: prereform2modern.

Here’s a taste:

from prereform2modern import convert

old_text = "Онъ былъ въ Петербургѣ и видѣлъ тамъ всѣхъ."
modern_text = convert(old_text)
print(modern_text)  # Он был в Петербурге и видел там всех.
Enter fullscreen mode Exit fullscreen mode

You can use it to augment your OCR training pipeline, evaluate model output, or build a transliteration API.

A real example

Old Russian orthography

(imagine an old Russian page here – typefaces, ѣ, і, the whole vibe)

Corresponding ground truth:

7

вамъ это происшествіе со всѣми должными приправами: съ непритворнымъ ужасомъ на лицѣ, въ глазахъ; съ содроганіемъ; съ восклицаніями и, наконецъ, съ поднятіемъ рукъ къ Небу!… Вы увидите какъ это послѣднее тѣлодвиженіе картинно въ немъ.»
Enter fullscreen mode Exit fullscreen mode

Notice the ъ at the end of words, the ѣ in «небе», the `і» in «происшествіе». This is what your OCR model needs to learn.

What can you build?

  • Specialised OCR for historical Russian documents (archives, old newspapers, diaries)
  • Old‑to‑modern transliteration service (like prereform2modern on steroids)
  • Evaluation benchmark for any OCR engine claiming to support pre‑reform Russian
  • Synthetic data generator – convert the ground truth back to old orthography and render different fonts

Get started in 30 seconds

bash
git clone https://huggingface.co/datasets/nevmenandr/russian-old-orthography-ocr
cd russian-old-orthography-ocr
ls books-pdf-plaintext/pdf # pick a PDF
ls pages-img-plaintext # or a PNG+txt pair

Then pair each image with its text, train your model, and watch it learn to read like a 19th‑century typesetter.

Let’s talk

Have you worked with historical languages in OCR? Ever fought with pre‑reform Russian? Drop a comment below – I’d love to hear your stories, ideas, or questions. And if you find the dataset useful, share this post so others can discover it too.

👉 Dataset on Hugging Face

👉 prereform2modern on PyPI

Happy (old) reading! 📖👓

Top comments (0)