docs: README.md — full volume inventory & corrected schema
Browse files
README.md
CHANGED
|
@@ -66,110 +66,155 @@ dataset_info:
|
|
| 66 |
num_examples: 123062
|
| 67 |
---
|
| 68 |
|
| 69 |
-
# Asfar — أسفار
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
| | |
|
| 77 |
|---|---|
|
| 78 |
| Rows (pages) | **123,062** |
|
| 79 |
-
| Unique
|
| 80 |
-
|
|
| 81 |
| Archive.org collections | **6** |
|
| 82 |
-
| Language | Arabic (Modern Standard
|
| 83 |
-
| Median chars
|
| 84 |
| Median Arabic-letter ratio | 0.971 |
|
| 85 |
-
|
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
## Columns
|
| 93 |
|
| 94 |
### Text
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
### Quality signals
|
| 113 |
-
- **`char_count`**, **`char_count_norm`** — pre- and post-normalization character counts.
|
| 114 |
-
- **`arabic_ratio`**, **`arabic_ratio_norm`** — fraction of non-whitespace chars in the Arabic Unicode block.
|
| 115 |
-
- **`di_confidence`** — document-intelligence confidence from the OCR pipeline.
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
-
| pages |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|---:|---|
|
| 123 |
| 4,824 | خزانة الأدب ولب لباب لسان العرب |
|
| 124 |
| 2,547 | تجريد الأغاني |
|
| 125 |
| 2,123 | الكامل في اللغة والأدب |
|
| 126 |
| 2,013 | المقتصد في شرح التكملة للجرجاني |
|
| 127 |
| 1,676 | توضيح المقاصد والمسالك شرح ألفية ابن مالك للمرادي |
|
| 128 |
-
|
|
| 129 |
-
|
|
| 130 |
-
|
|
| 131 |
-
|
|
| 132 |
-
|
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
## How it was built
|
| 155 |
-
|
| 156 |
-
1. **Source**: 257 configs (`az_0000`–`az_0256`) of `HeshamHaroon/arabic-turath-ocr`, each holding 500 OCR'd pages from a batch of PDF scans.
|
| 157 |
-
2. **Merge** into a single table, dropping pipeline bookkeeping (`clean_model`, `cleaned`, `error`).
|
| 158 |
-
3. **Normalize** `text` → `text_norm`:
|
| 159 |
-
- Unicode NFC
|
| 160 |
-
- remove `ـ` (tatweel, U+0640)
|
| 161 |
-
- strip diacritics (tashkeel, U+064B–U+065F, U+0670)
|
| 162 |
-
- expand common lam-alef ligatures (ﻻ → لا, etc.)
|
| 163 |
-
- collapse all whitespace (incl. zero-width joiners, NBSP) to a single space
|
| 164 |
-
4. **Filter** rows where:
|
| 165 |
-
- `char_count_norm` < 50 (OCR fragments, blank pages)
|
| 166 |
-
- `arabic_ratio_norm` < 0.5 (foreign-language pages, tables, colophons)
|
| 167 |
-
- `text_norm` exactly duplicates an earlier row (`book, page` order kept)
|
| 168 |
-
5. **Fix book/title semantics**:
|
| 169 |
-
- Renamed upstream `item_title` → `collection` (it was actually the Archive.org collection name).
|
| 170 |
-
- Renamed upstream `book` → `book_raw`, and derived `book_title` by stripping leading volume/part/issue numeric markers from the PDF filename.
|
| 171 |
-
- Flagged provenance in `book_title_source` so unrecoverable-title rows are filterable.
|
| 172 |
-
6. **Result**: 123,062 / 128,105 input rows kept (**96.1%**).
|
| 173 |
|
| 174 |
### Drops breakdown
|
| 175 |
|
|
@@ -177,7 +222,7 @@ All 6 collections:
|
|
| 177 |
|---|---:|
|
| 178 |
| empty / < 50 chars after normalization | 3,730 |
|
| 179 |
| Arabic-letter ratio < 0.5 | 1,128 |
|
| 180 |
-
| exact-duplicate
|
| 181 |
|
| 182 |
### Arabic-letter ratio distribution (of merged input)
|
| 183 |
|
|
@@ -189,39 +234,39 @@ All 6 collections:
|
|
| 189 |
| 70–90% | 7,933 |
|
| 190 |
| ≥ 90% Arabic | 115,464 |
|
| 191 |
|
| 192 |
-
##
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
-
ds[0]["text_norm"][:200]
|
| 199 |
-
|
| 200 |
-
# Keep only rows with a recoverable book title
|
| 201 |
-
named = ds.filter(lambda r: r["book_title_source"] == "parsed_from_pdf_name")
|
| 202 |
-
print(named.num_rows, "rows across", len(set(named["book_title"])), "titled books")
|
| 203 |
-
```
|
| 204 |
|
| 205 |
## Suggested use
|
| 206 |
|
| 207 |
-
- **Causal LM pre-training / continued pre-training** on classical Arabic —
|
| 208 |
-
- **OCR denoising**:
|
| 209 |
-
- **Lexical
|
| 210 |
-
- **Domain
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
|
| 214 |
-
## Licensing
|
| 215 |
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
|
| 218 |
## Citation
|
| 219 |
|
| 220 |
```bibtex
|
| 221 |
@dataset{haroon_asfar_2026,
|
| 222 |
-
author
|
| 223 |
-
title
|
| 224 |
-
year
|
| 225 |
-
url
|
| 226 |
}
|
| 227 |
```
|
|
|
|
| 66 |
num_examples: 123062
|
| 67 |
---
|
| 68 |
|
| 69 |
+
# Asfar — أَسْفَار
|
| 70 |
|
| 71 |
+
**A page-level corpus of classical Arabic heritage.**
|
| 72 |
+
123,062 pages · 461 PDF volumes · 6 Archive.org collections · Modern & Classical Arabic.
|
| 73 |
|
| 74 |
+
*`Asfar` (أَسْفَار, plural of سِفْر — "tome, large book") is a cleaned, page-indexed corpus of Arabic heritage literature — grammar, lexicography, adab, history, and poetry commentary — drawn from public-domain scans on Archive.org and normalized for language-model training.*
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## Summary
|
| 79 |
|
| 80 |
| | |
|
| 81 |
|---|---|
|
| 82 |
| Rows (pages) | **123,062** |
|
| 83 |
+
| Unique PDF volumes | **461** |
|
| 84 |
+
| Unique parsed book titles | **132** (the other 329 PDFs carry no extractable title — see below) |
|
| 85 |
| Archive.org collections | **6** |
|
| 86 |
+
| Language | Arabic (Modern Standard and Classical) |
|
| 87 |
+
| Median chars per page | 1,245 |
|
| 88 |
| Median Arabic-letter ratio | 0.971 |
|
| 89 |
+
| Split | single `train` split |
|
| 90 |
+
| Format | Parquet, 5 shards, zstd-compressed |
|
| 91 |
+
| License | CC-BY-4.0 (metadata & normalization work); underlying books are public-domain — cite the book |
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## Quickstart
|
| 96 |
|
| 97 |
+
```python
|
| 98 |
+
from datasets import load_dataset
|
| 99 |
+
|
| 100 |
+
ds = load_dataset("HeshamHaroon/asfar", split="train")
|
| 101 |
+
print(ds)
|
| 102 |
+
print(ds[0]["text_norm"][:200])
|
| 103 |
+
```
|
| 104 |
|
| 105 |
+
To use only rows with a recovered book title:
|
| 106 |
+
|
| 107 |
+
```python
|
| 108 |
+
titled = ds.filter(lambda r: r["book_title_source"] == "parsed_from_pdf_name")
|
| 109 |
+
# ≈ 48,363 pages across 132 named books
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
|
| 114 |
## Columns
|
| 115 |
|
| 116 |
### Text
|
| 117 |
+
|
| 118 |
+
| Column | Dtype | Purpose |
|
| 119 |
+
|---|---|---|
|
| 120 |
+
| **`text_norm`** | `string` | Primary training column. NFC-normalized, tatweel removed, tashkeel stripped, lam-alef ligatures expanded, whitespace collapsed. |
|
| 121 |
+
| `text` | `string` | OCR output after an LLM cleaning pass (publisher-supplied). Keep diacritics if present. |
|
| 122 |
+
| `raw_text` | `string` | Pre-cleaning OCR. Useful as the noisy side of a `raw_text` → `text` OCR-denoising pair. |
|
| 123 |
+
|
| 124 |
+
### Source identity
|
| 125 |
+
|
| 126 |
+
| Column | Dtype | Purpose |
|
| 127 |
+
|---|---|---|
|
| 128 |
+
| **`book_title`** | `string` | Cleaned book title. For PDFs whose filename encoded the title (e.g. `" 0 1 1 خزانة الأدب.pdf"`), leading volume/part/issue numeric markers are stripped to yield `"خزانة الأدب ولب لباب لسان العرب"`. For PDFs whose filename is a bare code (e.g. `"10668.pdf"`, `"a025.pdf"`), `book_title` equals the code — the actual title is not present in upstream metadata. Inspect `book_title_source` to tell the two cases apart. |
|
| 129 |
+
| **`book_title_source`** | `string` | One of: `parsed_from_pdf_name` (48,363 rows / 132 books), `pdf_code` (74,699 rows / 329 books), `pdf_stem` (edge cases where the PDF stem was all-numeric markers). |
|
| 130 |
+
| `book_raw` | `string` | The original, unprocessed `book` string from the upstream dataset (= PDF filename stem). Kept for auditing the parsing. |
|
| 131 |
+
| `collection` | `string` | The **Archive.org collection** (6 distinct) this PDF was harvested from — a coarse grouping over many books, not a book title. Renamed from the upstream dataset's `item_title` column, which had collection strings under a misleading name. |
|
| 132 |
+
| `item_id` | `string` | Archive.org item identifier (links to `source_detail_url`). |
|
| 133 |
+
| `pdf_filename` | `string` | Original PDF filename as uploaded to Archive.org. |
|
| 134 |
+
| `pdf_url` | `string` | Direct download URL for the source PDF on Archive.org. |
|
| 135 |
+
| `source_detail_url` | `string` | Archive.org item/collection detail page. |
|
| 136 |
+
| `shard` | `string` | Original `az_NNNN` config name from the upstream `HeshamHaroon/arabic-turath-ocr` dataset. Provenance only. |
|
| 137 |
+
|
| 138 |
+
### Position
|
| 139 |
+
|
| 140 |
+
| Column | Dtype | Purpose |
|
| 141 |
+
|---|---|---|
|
| 142 |
+
| `page` | `int64` | Page index within the PDF. |
|
| 143 |
+
| `total_pages` | `int64` | Total pages in the PDF. |
|
| 144 |
|
| 145 |
### Quality signals
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
| Column | Dtype | Purpose |
|
| 148 |
+
|---|---|---|
|
| 149 |
+
| `char_count`, `char_count_norm` | `int64` | Character count of `text` and `text_norm`. |
|
| 150 |
+
| `arabic_ratio`, `arabic_ratio_norm` | `float64` | Fraction of non-whitespace characters in the Arabic Unicode block. |
|
| 151 |
+
| `di_confidence` | `float64` | Document-intelligence confidence reported by the upstream OCR pipeline. |
|
| 152 |
+
|
| 153 |
+
---
|
| 154 |
+
|
| 155 |
+
## Archive.org collections
|
| 156 |
|
| 157 |
+
Six collections account for all 461 volumes. Their make-up explains the `pdf_code` vs. `parsed_from_pdf_name` split cleanly — two of the six collections use numeric / `a###` codes as filenames, the others use readable Arabic titles.
|
| 158 |
|
| 159 |
+
| pages | PDFs | collection | filename convention |
|
| 160 |
+
|---:|---:|---|---|
|
| 161 |
+
| 45,249 | 229 | كتب عربية - طبعات قديمة | all numeric codes (e.g. `10668.pdf`, `30283.pdf`) |
|
| 162 |
+
| 29,450 | 100 | كتب منوعة - المائة الثانية pdf | all `a###` codes (e.g. `a025.pdf`, `a077.pdf`) |
|
| 163 |
+
| 28,202 | 99 | كتب متنوعة في اللغة العربية ولسانها | Arabic titles |
|
| 164 |
+
| 12,030 | 7 | مختارات من كتب الأدب العربي | Arabic titles (multi-volume sets) |
|
| 165 |
+
| 4,781 | 16 | كتب عن تاريخ بلاد الحرمين و نجد - طبعات نادرة و قديمة و ملونة | Arabic titles |
|
| 166 |
+
| 3,350 | 10 | تاريخ التراث العربي - فؤاد سزكين | Arabic titles |
|
| 167 |
+
|
| 168 |
+
A per-volume inventory (all 461 PDFs with their page counts and URLs) is published alongside this README as [`VOLUMES.md`](VOLUMES.md) and [`volumes.json`](volumes.json).
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
## Top 20 titled volumes
|
| 173 |
+
|
| 174 |
+
Rows where `book_title_source == "parsed_from_pdf_name"`:
|
| 175 |
+
|
| 176 |
+
| pages | title |
|
| 177 |
|---:|---|
|
| 178 |
| 4,824 | خزانة الأدب ولب لباب لسان العرب |
|
| 179 |
| 2,547 | تجريد الأغاني |
|
| 180 |
| 2,123 | الكامل في اللغة والأدب |
|
| 181 |
| 2,013 | المقتصد في شرح التكملة للجرجاني |
|
| 182 |
| 1,676 | توضيح المقاصد والمسالك شرح ألفية ابن مالك للمرادي |
|
| 183 |
+
| 974 | كتاب الأمالي مع كتابي ذيل الأمالي والنوادر |
|
| 184 |
+
| 792 | التقفية في اللغة |
|
| 185 |
+
| 696 | المنتخب من أدب العرب |
|
| 186 |
+
| 679 | الزاهر في غريب ألفاظ الشافعي |
|
| 187 |
+
| 669 | المعرب من كلام الأعجم على حروف المعجم |
|
| 188 |
+
| 654 | المدخل إلى تقويم اللسان |
|
| 189 |
+
| 596 | تصحيح الفصيح وشرحه |
|
| 190 |
+
| 583 | الفروق في اللغة |
|
| 191 |
+
| 582 | المقتضب |
|
| 192 |
+
| 557 | الدراسات اللغوية والنحوية في مؤلفات ابن تيمية |
|
| 193 |
+
| 552 | تاريخ أحمد باشا الجزار — حيدر أحمد الشهابي — مكتبة انطوان 1955 |
|
| 194 |
+
| 534 | الغريب المصنف |
|
| 195 |
+
| 510 | كتاب الاضداد |
|
| 196 |
+
| 503 | تاريخ نجد الحديث وملحقاته — دار ريحاني — بيروت 1954 |
|
| 197 |
+
| 498 | أبنية الأسماء والأفعال والمصادر، لابن القطاع الصقلي |
|
| 198 |
+
|
| 199 |
+
Full list: see `VOLUMES.md`.
|
| 200 |
|
| 201 |
+
---
|
| 202 |
|
| 203 |
+
## Construction
|
| 204 |
+
|
| 205 |
+
1. **Merge.** 257 configs (`az_0000` through `az_0256`) of `HeshamHaroon/arabic-turath-ocr` — 500 rows each — concatenated into a single table. Pipeline bookkeeping columns (`clean_model`, `cleaned`, `error`) dropped.
|
| 206 |
+
2. **Normalize text.** `text_norm` derived from `text` via:
|
| 207 |
+
- Unicode NFC normalization
|
| 208 |
+
- removal of U+0640 (ـ, tatweel)
|
| 209 |
+
- removal of U+064B–U+065F and U+0670 (tashkeel / harakat)
|
| 210 |
+
- expansion of lam-alef ligatures (ﻻ → لا, ﻷ → لأ, ﻹ → لإ, ﻵ → لآ)
|
| 211 |
+
- collapse of all whitespace — including zero-width joiner, zero-width non-joiner, and NBSP — to a single space
|
| 212 |
+
3. **Filter.** Rows were dropped where:
|
| 213 |
+
- `char_count_norm < 50` (OCR fragments, blank pages)
|
| 214 |
+
- `arabic_ratio_norm < 0.5` (foreign-language pages, tables, colophons)
|
| 215 |
+
- `text_norm` exactly duplicates an earlier row (ordered by `book, page`)
|
| 216 |
+
4. **Fix column semantics.** In the upstream dataset, `item_title` actually held the Archive.org collection name and `book` held the PDF filename stem (sometimes prefixed with volume/part/issue markers). Those columns were renamed to `collection` and `book_raw`, and a derived `book_title` (+ `book_title_source` provenance flag) was added.
|
| 217 |
+
5. **Yield.** 123,062 of 128,105 input rows kept — 96.1%.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
### Drops breakdown
|
| 220 |
|
|
|
|
| 222 |
|---|---:|
|
| 223 |
| empty / < 50 chars after normalization | 3,730 |
|
| 224 |
| Arabic-letter ratio < 0.5 | 1,128 |
|
| 225 |
+
| exact-duplicate normalized text | 185 |
|
| 226 |
|
| 227 |
### Arabic-letter ratio distribution (of merged input)
|
| 228 |
|
|
|
|
| 234 |
| 70–90% | 7,933 |
|
| 235 |
| ≥ 90% Arabic | 115,464 |
|
| 236 |
|
| 237 |
+
### book_title_source breakdown
|
| 238 |
|
| 239 |
+
| source | rows | volumes |
|
| 240 |
+
|---|---:|---:|
|
| 241 |
+
| `parsed_from_pdf_name` | 48,363 | 132 |
|
| 242 |
+
| `pdf_code` | 74,699 | 329 |
|
| 243 |
|
| 244 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
## Suggested use
|
| 247 |
|
| 248 |
+
- **Causal LM pre-training / continued pre-training** on classical Arabic — `text_norm`.
|
| 249 |
+
- **OCR denoising**: `raw_text` ↔ `text` as noisy-clean training pairs.
|
| 250 |
+
- **Lexical and grammatical resources**: the top ten volumes are dictionaries, fiqh al-lugha works, and commentaries.
|
| 251 |
+
- **Domain adapters** for models that need to handle pre-modern Arabic registers.
|
| 252 |
+
|
| 253 |
+
For tasks where diacritics or glyph form matter — Quranic recitation alignment, classical prosody, tashkeel restoration — use `text` or `raw_text` rather than `text_norm`.
|
| 254 |
|
| 255 |
+
---
|
| 256 |
|
| 257 |
+
## Licensing & provenance
|
| 258 |
|
| 259 |
+
All underlying PDFs are public-domain scans of classical Arabic works, hosted on the Internet Archive. The aggregation, cleaning, and metadata work in this repository are released under **CC-BY-4.0**. When quoting or reproducing content, cite the original book (see `book_title`) and, where helpful, the Archive.org item via `source_detail_url`.
|
| 260 |
+
|
| 261 |
+
---
|
| 262 |
|
| 263 |
## Citation
|
| 264 |
|
| 265 |
```bibtex
|
| 266 |
@dataset{haroon_asfar_2026,
|
| 267 |
+
author = {Haroon, Hesham},
|
| 268 |
+
title = {Asfar: An Arabic Heritage Text Corpus},
|
| 269 |
+
year = {2026},
|
| 270 |
+
url = {https://huggingface.co/datasets/HeshamHaroon/asfar},
|
| 271 |
}
|
| 272 |
```
|