An OCR for Classical Indic Documents Containing Arbitrarily Long Words

Agam Dwivedi, Rohit Saluja, Ravi Kiran SarvadevabhatlaWorkshops @ CVPR 2020

Abstract

Digitizing classical Sanskrit documents presents unique challenges due to complex character conjuncts and the linguistic phenomenon of sandhi, which results in arbitrarily long conjoined words. Standard OCR engines, optimized for space-separated Western languages, often fail in this domain. This paper introduces a specialized line-level OCR system utilizing a CNN-BLSTM architecture with a soft-attention mechanism. By training on a combination of real annotated data and a massive synthetic dataset, the proposed model achieves a Character Error Rate (CER) of 3.71%, significantly outperforming both open-source and commercial baselines.

Introduction: The "Boss Level" of OCR

Classical Indic scripts, particularly Sanskrit in Devanagari, are notoriously difficult to digitize. Two primary factors contribute to this difficulty:

  1. Sandhi and Conjoined Words: Sanskrit words often merge into extremely long strings. A single "word" can span an entire line, making traditional word-level segmentation impossible.
  2. Complex Conjuncts: Devanagari features conjunct glyphs where multiple consonants merge. These vary significantly across historical fonts and manuscripts, complicating character-level recognition.

Existing tools like Tesseract are designed for languages with clear word boundaries and struggle with the visual and structural complexity of Sanskrit.

Methods: A Line-Level Attention Framework

To address these challenges, the researchers developed a line-level OCR framework that bypasses word segmentation entirely. The architecture consists of three integrated stages:

  1. Feature Extraction: A 7-layer CNN processes line images (normalized to 32x512 pixels) to extract high-level visual features.
  2. Encoder: A Bi-directional LSTM (BLSTM) reads these features, capturing context from both directions to better understand complex character sequences.
  3. Decoder with Attention: A two-layer LSTM decodes the sequence into text. Crucially, it employs a single-headed soft-attention mechanism. This allows the model to dynamically "focus" on relevant parts of the image features while generating each character, ensuring alignment even over very long sequences.
The proposed CNN-BLSTM-Attention-LSTM architecture for line-level OCR.

Datasets: Bridging Real and Synthetic Data

The study introduces a substantial new dataset for Sanskrit OCR:

  • Real Data: 24,000 lines from classical texts like Nirnaya Sindhu and Kavyaprakasha.
  • Synthetic Data: 335,000 line images generated using 67 different fonts. This synthetic data includes glyph substitution rules to mimic the variety of complex conjuncts found in real documents.

The researchers found that while synthetic data provides a broad "vocabulary" of shapes, mixing it with real data is essential for the model to handle the noise and textures of historical manuscripts.

Key Results and Performance

The attention-based model demonstrated superior accuracy and robustness compared to existing solutions. It achieved a Character Error Rate (CER) of 3.71% and a Word Error Rate (WER) of 15.97%.

In comparison:

  • Tesseract: Recorded a high WER of 69.89%.
  • Ind.Senz (Commercial): Recorded a 40.81% WER.
  • CNN-RNN Baseline: Lacked the attention mechanism and lagged behind by approximately 7% in word accuracy.
Comparison of error rates across varying word lengths.

As shown in the results, the attention mechanism is particularly effective at maintaining low error rates as word length increases, a scenario where baseline models typically degrade.

Conclusion

By moving to a line-level recognition model and incorporating an attention mechanism, this research provides a robust solution for digitizing classical Sanskrit. The combination of a large-scale synthetic dataset and targeted real-world annotations allows the model to generalize across diverse historical fonts and handle the linguistic complexities of conjoined words. Future work will focus on refining the attention mechanism for extreme word lengths and integrating linguistic post-processing to further reduce error rates.

Summary updated

BibTeX
@inproceedings{dwivedi2020ocr,
  author = {Agam Dwivedi and Rohit Saluja and Ravi Kiran Sarvadevabhatla},
  title = {{An OCR for Classical Indic Documents Containing Arbitrarily Long Words}},
  booktitle = {Workshops @ CVPR},
  year = {2020},
  doi = {10.1109/cvprw50498.2020.00288},
}
Figure