Elamur OCR0.1 preview

Reading woodblock books from their scans

hanocr reads Chinese books printed from carved wooden blocks, straight from the scans, without neural networks. It finds the columns and cuts out each character, compares the motion of the character's lines with exemplars cut from the same book, and lets a small model of the language choose between close shapes. Its first book is a history printed at the Ming court in 1507; on pages it never learned from, it reads 87.4 % of the characters right.

What hanocr is

Many old Chinese books on Wikisource are scans with a machine collation that nobody has checked yet. hanocr is an attempt to read such books the way a careful person would: by the shapes the carver actually cut in this book, not by a font or by a network trained on modern print.

It needs no neural network and no training data from outside the book. A few dozen pages that people have already proofread on Wikisource are its teacher: the proofread text is laid onto the boxes it cuts, so every box becomes an exemplar of its character in the carver's own hand. Then it reads the pages nobody has proofread, says how sure it is of every character, and learns again from the characters it is sure of.

Every step is plain, measurable code: how the columns are found, how two shapes are compared, how the confidence is calibrated. How hanocr reads a page explains each step in plain words, with drawings.

How hanocr reads a page
  1. find the frame and the columns
  2. cut the characters
  3. compare their lines with the book's exemplars
  4. let the language model choose
  5. calibrate the confidence
  6. learn from what it is sure of

The result now

On the test pages 70–88, which hanocr never learned from, it reads 87.4 % of the characters right. On the 108 pages nobody has proofread yet (89–196) it read 17 015 characters, 84.8 % of them right, measured against the text established from the scan for the English translation. Its confidence marks the doubtful ones, so a reader can trust the sure reads and check the rest: every page of the book, page by page marks them.

What made the difference

Each of these was measured on pages hanocr never learned from, and kept only because it helped.

Characters read right on the test pages, step by step (%)% · higher is better

From a font alone to the book's own exemplars, elastic matching, cleaner boxes, self-training and characters built from parts: 15 % to 87.4 %.

A font alone15
Exemplars from the book58.6
Elastic comparison74.7
Columns and boxes found right80.2
Self-training and built characters81.5
Volume 1 of the edition as exemplars85.0
The book's own read pages as exemplars87.4

The book

hanocr's first book is the Essentials of the Comprehensive Mirror (歷代通鑒纂要), a history of China printed at the Ming palace in 1507: the book, its pages and their English translation.

Open source soon

The code of hanocr will be open source soon; until then this site shows what it does and how it does it. It is written in Rust, from scratch: no machine-learning framework, no network to download. The scans and the texts it learns from stay outside the code, as they belong to their sources.

Credits

This page in Markdown https://md.ocr.elamur.ai/free/en/