sinhala-pali-ocr / README.md
pathnirvana's picture
Add README.md
6c4945d verified
|
Raw History Blame Contribute Delete
3.74 kB
---
language:
- si
- pi
license: cc-by-4.0
task_categories:
- image-to-text
tags:
- ocr
- sinhala
- pali
- historical-documents
- buddhism
pretty_name: Sinhala and Pali OCR (old prints)
size_categories:
- 1K<n<10K
---
# Sinhala and Pali OCR: old prints
These are scanned pages of Sinhala and Pali books, mostly Buddhist texts printed between the 1870s and 2000s, each paired with a corrected transcription. They were collected to fine-tune a page-level OCR model (e.g. LightOnOCR-2) for old Sinhala-script print, made by [Path Nirvana](https://pitaka.lk).
## Target format
Each target is the page text as UTF-8 Unicode Sinhala (NFC):
- **Lines:** one printed line becomes one line of text. A word split by the printer across a line end keeps its hyphen (`word-\n`).
- **Paragraphs:** a blank line separates paragraphs, headings, verses and footnotes.
- **Bold:** printed bold is marked `**bold**`.
- **Footnotes:** reference numbers are superscript digits (¹ ² ³).
- **Left out:** running headers, page numbers and printer's footer codes.
The `prompt` column says when a target falls short of this format. The image is then given to the model with that prompt as a text instruction, so that pages with no prompt keep the full format:
| prompt | meaning |
|---|---|
| null | full format |
| `nobold` | the source transcription has no bold markup (the `acts` pages) |
`crop` is `[x0, y0, x1, y1]` to apply to the image before use, or null for the full page. A crop is used where the page holds text that the transcription lacks.
## Files
The data is in Parquet shards, `data/{train,validation,test}-*.parquet`, with one row per page. The columns are `id`, `image` (the original JPEG bytes), `crop`, `text`, `prompt`, `source`, `stratum`, `lang` and `year`.
```python
from datasets import load_dataset
ds = load_dataset("pathnirvana/sinhala-pali-ocr", split="train")
row = ds[0]
img = row["image"].crop(row["crop"]) if row["crop"] else row["image"]
```
## Sources
| source | pages | images | text |
|---|---|---|---|
| `bjt` | 3,301 | Buddha Jayanti Tripitaka (Sri Lanka government edition, 1960s–80s), Pali and facing Sinhala translation | typed text from [tipitaka.lk](https://tipitaka.lk). Printed line breaks were recovered by aligning Tesseract line boxes. 30 pages per volume and language |
| `pitaka-books` | 4,795 | old scanned prints in the [tipitaka.lk library](https://tipitaka.lk/library) | corrected editions from [pitaka.lk/books](https://pitaka.lk/books), cut into pages by alignment. At most 150 pages per print, from 32 books |
| `acts` | 410 | Sri Lankan acts, 1981–1989 | the pre-2000 pages of [avishadilhara/sinhala-ocr-lk-acts-1010](https://huggingface.co/datasets/avishadilhara/sinhala-ocr-lk-acts-1010) (CC BY 4.0), with headers removed |
| `opus-lib` | 92 | single pages of library books printed 1870s–1980s | transcribed by Claude Opus. Not human-checked, so expect a few % character errors and imperfect bold |
The page transcriptions come from corrected editions, which can differ from the printed page in places: spelling, punctuation, small edits. Expect a floor of about 1–2% character differences.
## Splits
- **test:** whole books never trained on. These are BJT volumes 12, 29 and 47, and the pitaka.lk books suvisi-gunaya (1964 print) and chathurarya-sathya (2007).
- **test, other sources:** the acts follow the source dataset's split, and 10% of the `opus-lib` pages are test.
- **validation:** a small set of pages from all sources, used to track loss.
## Credits
The acts pages come from *Sinhala OCR – Sri Lankan Acts Dataset* by avishadilhara (CC BY 4.0). The BJT text is from tipitaka.lk, and the book texts and scans are from pitaka.lk and the tipitaka.lk library.