fix: rename item_title->collection, add book_title parsed from pdf filename, update schema
Browse files
README.md
CHANGED
|
@@ -25,9 +25,13 @@ dataset_info:
|
|
| 25 |
features:
|
| 26 |
- name: item_id
|
| 27 |
dtype: string
|
| 28 |
-
- name:
|
| 29 |
dtype: string
|
| 30 |
-
- name:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
dtype: string
|
| 32 |
- name: pdf_filename
|
| 33 |
dtype: string
|
|
@@ -39,10 +43,16 @@ dataset_info:
|
|
| 39 |
dtype: string
|
| 40 |
- name: raw_text
|
| 41 |
dtype: string
|
|
|
|
|
|
|
| 42 |
- name: char_count
|
| 43 |
dtype: int64
|
|
|
|
|
|
|
| 44 |
- name: arabic_ratio
|
| 45 |
dtype: float64
|
|
|
|
|
|
|
| 46 |
- name: di_confidence
|
| 47 |
dtype: float64
|
| 48 |
- name: pdf_url
|
|
@@ -51,12 +61,6 @@ dataset_info:
|
|
| 51 |
dtype: string
|
| 52 |
- name: shard
|
| 53 |
dtype: string
|
| 54 |
-
- name: text_norm
|
| 55 |
-
dtype: string
|
| 56 |
-
- name: char_count_norm
|
| 57 |
-
dtype: int64
|
| 58 |
-
- name: arabic_ratio_norm
|
| 59 |
-
dtype: float64
|
| 60 |
splits:
|
| 61 |
- name: train
|
| 62 |
num_examples: 123062
|
|
@@ -65,19 +69,21 @@ dataset_info:
|
|
| 65 |
# Asfar — أسفار
|
| 66 |
|
| 67 |
> *أَسْفَار* · "tomes" — the plural of سِفْر, the classical word for a large book.
|
| 68 |
-
> 123,062 pages from 461 volumes of Arabic literary, grammatical, and lexical heritage, normalized and cleaned for language-model training.
|
| 69 |
|
| 70 |
## At a glance
|
| 71 |
|
| 72 |
| | |
|
| 73 |
|---|---|
|
| 74 |
| Rows (pages) | **123,062** |
|
| 75 |
-
| Unique volumes | **461** |
|
|
|
|
|
|
|
| 76 |
| Language | Arabic (Modern Standard / Classical) |
|
| 77 |
| Median chars / page | 1,245 |
|
| 78 |
| Median Arabic-letter ratio | 0.971 |
|
| 79 |
-
| Source | OCR of PDF scans, cleaned + normalized |
|
| 80 |
-
| License | CC-BY-4.0 (
|
| 81 |
|
| 82 |
## Why this exists
|
| 83 |
|
|
@@ -85,61 +91,85 @@ Classical Arabic corpora suitable for LM pre-training / fine-tuning are scarce a
|
|
| 85 |
|
| 86 |
## Columns
|
| 87 |
|
| 88 |
-
|
| 89 |
-
- **`
|
| 90 |
-
- **`
|
| 91 |
-
- **`
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
- **`
|
| 95 |
-
- **`
|
| 96 |
-
- **`
|
| 97 |
-
- **`
|
| 98 |
-
- **`
|
| 99 |
-
- **`
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
- **`char_count`**, **`char_count_norm`** — pre- and post-normalization character counts.
|
| 103 |
- **`arabic_ratio`**, **`arabic_ratio_norm`** — fraction of non-whitespace chars in the Arabic Unicode block.
|
| 104 |
- **`di_confidence`** — document-intelligence confidence from the OCR pipeline.
|
| 105 |
|
| 106 |
-
## Top
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
| 111 |
-
|
|
| 112 |
-
|
|
| 113 |
-
| 2,
|
| 114 |
-
|
|
| 115 |
-
|
|
| 116 |
-
|
|
| 117 |
-
|
|
| 118 |
-
|
|
| 119 |
-
|
|
| 120 |
-
|
|
| 121 |
-
|
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
## How it was built
|
| 129 |
|
| 130 |
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.
|
| 131 |
-
2. **Merge** into a single table,
|
| 132 |
3. **Normalize** `text` → `text_norm`:
|
| 133 |
- Unicode NFC
|
| 134 |
- remove `ـ` (tatweel, U+0640)
|
| 135 |
- strip diacritics (tashkeel, U+064B–U+065F, U+0670)
|
| 136 |
- expand common lam-alef ligatures (ﻻ → لا, etc.)
|
| 137 |
-
- collapse all whitespace (incl. zero-width joiners, NBSP) to single space
|
| 138 |
4. **Filter** rows where:
|
| 139 |
- `char_count_norm` < 50 (OCR fragments, blank pages)
|
| 140 |
- `arabic_ratio_norm` < 0.5 (foreign-language pages, tables, colophons)
|
| 141 |
- `text_norm` exactly duplicates an earlier row (`book, page` order kept)
|
| 142 |
-
5. **
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
### Drops breakdown
|
| 145 |
|
|
@@ -166,20 +196,24 @@ from datasets import load_dataset
|
|
| 166 |
|
| 167 |
ds = load_dataset("HeshamHaroon/asfar", split="train")
|
| 168 |
ds[0]["text_norm"][:200]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
```
|
| 170 |
|
| 171 |
## Suggested use
|
| 172 |
|
| 173 |
- **Causal LM pre-training / continued pre-training** on classical Arabic — use `text_norm`.
|
| 174 |
-
- **OCR denoising**
|
| 175 |
-
- **Lexical resource mining**
|
| 176 |
- **Domain-adapter fine-tuning** for models handling pre-modern Arabic registers.
|
| 177 |
|
| 178 |
Avoid using `text_norm` verbatim for tasks where diacritics matter (Quranic recitation, classical prosody, tashkeel restoration) — normalization strips them. Reach for `text` or `raw_text` in those cases.
|
| 179 |
|
| 180 |
## Licensing
|
| 181 |
|
| 182 |
-
The underlying PDFs are scanned classical Arabic works, almost all past copyright. The corpus metadata and normalization work here are released under **CC-BY-4.0**. Cite the original book when quoting content.
|
| 183 |
|
| 184 |
## Citation
|
| 185 |
|
|
|
|
| 25 |
features:
|
| 26 |
- name: item_id
|
| 27 |
dtype: string
|
| 28 |
+
- name: collection
|
| 29 |
dtype: string
|
| 30 |
+
- name: book_title
|
| 31 |
+
dtype: string
|
| 32 |
+
- name: book_title_source
|
| 33 |
+
dtype: string
|
| 34 |
+
- name: book_raw
|
| 35 |
dtype: string
|
| 36 |
- name: pdf_filename
|
| 37 |
dtype: string
|
|
|
|
| 43 |
dtype: string
|
| 44 |
- name: raw_text
|
| 45 |
dtype: string
|
| 46 |
+
- name: text_norm
|
| 47 |
+
dtype: string
|
| 48 |
- name: char_count
|
| 49 |
dtype: int64
|
| 50 |
+
- name: char_count_norm
|
| 51 |
+
dtype: int64
|
| 52 |
- name: arabic_ratio
|
| 53 |
dtype: float64
|
| 54 |
+
- name: arabic_ratio_norm
|
| 55 |
+
dtype: float64
|
| 56 |
- name: di_confidence
|
| 57 |
dtype: float64
|
| 58 |
- name: pdf_url
|
|
|
|
| 61 |
dtype: string
|
| 62 |
- name: shard
|
| 63 |
dtype: string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
splits:
|
| 65 |
- name: train
|
| 66 |
num_examples: 123062
|
|
|
|
| 69 |
# Asfar — أسفار
|
| 70 |
|
| 71 |
> *أَسْفَار* · "tomes" — the plural of سِفْر, the classical word for a large book.
|
| 72 |
+
> 123,062 pages from 461 PDF volumes of Arabic literary, grammatical, and lexical heritage, normalized and cleaned for language-model training.
|
| 73 |
|
| 74 |
## At a glance
|
| 75 |
|
| 76 |
| | |
|
| 77 |
|---|---|
|
| 78 |
| Rows (pages) | **123,062** |
|
| 79 |
+
| Unique PDFs (volumes) | **461** |
|
| 80 |
+
| Distinct parsed book titles | **460** (1:1 with PDFs where the filename was descriptive) |
|
| 81 |
+
| Archive.org collections | **6** |
|
| 82 |
| Language | Arabic (Modern Standard / Classical) |
|
| 83 |
| Median chars / page | 1,245 |
|
| 84 |
| Median Arabic-letter ratio | 0.971 |
|
| 85 |
+
| Source | OCR of PDF scans (Archive.org), cleaned + normalized |
|
| 86 |
+
| License | CC-BY-4.0 (the underlying works are almost all past copyright; cite the book) |
|
| 87 |
|
| 88 |
## Why this exists
|
| 89 |
|
|
|
|
| 91 |
|
| 92 |
## Columns
|
| 93 |
|
| 94 |
+
### Text
|
| 95 |
+
- **`text_norm`** — `text` after NFC normalization, tatweel removal, tashkeel stripping, lam-alef ligature expansion, and whitespace collapse. **Use this for LM training by default.**
|
| 96 |
+
- **`text`** — OCR output after an LLM cleaning pass (publisher-supplied cleaned form).
|
| 97 |
+
- **`raw_text`** — pre-cleaning OCR (useful for OCR-error-correction training as noisy/clean pairs with `text`).
|
| 98 |
+
|
| 99 |
+
### Source identity (this is the part you probably care about)
|
| 100 |
+
- **`book_title`** — the book's title, derived from the PDF filename with leading volume/part/issue markers stripped (e.g. `" 0 1 1 خزانة الأدب"` → `"خزانة الأدب ولب لباب لسان العرب"`). For ~39% of rows this is the real book title; for the remaining ~61% the uploader used a numeric code (e.g. `"10668"`) and the real title is not recoverable from the metadata alone. See `book_title_source`.
|
| 101 |
+
- **`book_title_source`** — `parsed_from_pdf_name` when `book_title` is a real title parsed from the PDF filename, `pdf_code` when the PDF was uploaded under a numeric/alphanumeric code and no title was recoverable, `pdf_stem` for a handful of edge cases.
|
| 102 |
+
- **`book_raw`** — the original, unprocessed book string from the upstream dataset (= PDF filename stem, sometimes with junk prefix). Keep this if you want to reproduce or audit the parsing.
|
| 103 |
+
- **`collection`** — the **Archive.org collection** this PDF was harvested from (e.g. `"كتب عربية - طبعات قديمة"`). This is a coarse grouping over many books, not a book title. Renamed from the upstream dataset's misleading `item_title` column.
|
| 104 |
+
- **`item_id`** — Archive.org item ID (links to the collection page via `source_detail_url`).
|
| 105 |
+
- **`pdf_filename`** — the original filename of the scanned PDF.
|
| 106 |
+
- **`pdf_url`**, **`source_detail_url`** — upstream links (download + collection page).
|
| 107 |
+
- **`shard`** — original `az_NNNN` config name from `HeshamHaroon/arabic-turath-ocr`, for provenance.
|
| 108 |
+
|
| 109 |
+
### Page position
|
| 110 |
+
- **`page`**, **`total_pages`** — page index within the PDF.
|
| 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 |
+
## Top parsed book titles (by page count)
|
| 118 |
|
| 119 |
+
Only rows with `book_title_source = "parsed_from_pdf_name"`:
|
| 120 |
+
|
| 121 |
+
| pages | book_title |
|
| 122 |
+
|---:|---|
|
| 123 |
+
| 4,824 | خزانة الأدب ولب لباب لسان العرب |
|
| 124 |
+
| 2,547 | تجريد الأغاني |
|
| 125 |
+
| 2,123 | الكامل في اللغة والأدب |
|
| 126 |
+
| 2,013 | المقتصد في شرح التكملة للجرجاني |
|
| 127 |
+
| 1,676 | توضيح المقاصد والمسالك شرح ألفية ابن مالك للمرادي |
|
| 128 |
+
| 974 | كتاب الأمالي مع كتابي ذيل الأمالي والنوادر |
|
| 129 |
+
| 889 | أدب الكاتب |
|
| 130 |
+
| 792 | التقفية في اللغة |
|
| 131 |
+
| 696 | المنتخب من أدب العرب |
|
| 132 |
+
| 679 | الزاهر في غريب ألفاظ الشافعي |
|
| 133 |
+
|
| 134 |
+
## Archive.org collections
|
| 135 |
+
|
| 136 |
+
All 6 collections:
|
| 137 |
+
|
| 138 |
+
| pages | collection |
|
| 139 |
+
|---:|---|
|
| 140 |
+
| 45,249 | كتب عربية - طبعات قديمة |
|
| 141 |
+
| 29,450 | كتب منوعة - المائة الثانية pdf |
|
| 142 |
+
| 28,202 | كتب متنوعة في اللغة العربية ولسانها |
|
| 143 |
+
| 12,030 | مختارات من كتب الأدب العربي |
|
| 144 |
+
| 4,781 | كتب عن تاريخ بلاد الحرمين و نجد - طبعات نادرة و قديمة و ملونة |
|
| 145 |
+
| ≈3,350 | (remaining) |
|
| 146 |
+
|
| 147 |
+
## book_title_source distribution
|
| 148 |
+
|
| 149 |
+
| source | rows | what it means |
|
| 150 |
+
|---|---:|---|
|
| 151 |
+
| `pdf_code` | 74,699 | PDF was uploaded under a numeric / alphanumeric code (e.g. `"10668"`, `"a025"`). No book title recoverable from metadata. Filter these out if you need known titles. |
|
| 152 |
+
| `parsed_from_pdf_name` | 48,363 | Book title parsed cleanly from the PDF filename. |
|
| 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 |
|
|
|
|
| 196 |
|
| 197 |
ds = load_dataset("HeshamHaroon/asfar", split="train")
|
| 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 — use `text_norm`.
|
| 208 |
+
- **OCR denoising**: pair `raw_text` ↔ `text` as noisy/clean examples.
|
| 209 |
+
- **Lexical resource mining**: top volumes are dictionaries and grammar commentaries.
|
| 210 |
- **Domain-adapter fine-tuning** for models handling pre-modern Arabic registers.
|
| 211 |
|
| 212 |
Avoid using `text_norm` verbatim for tasks where diacritics matter (Quranic recitation, classical prosody, tashkeel restoration) — normalization strips them. Reach for `text` or `raw_text` in those cases.
|
| 213 |
|
| 214 |
## Licensing
|
| 215 |
|
| 216 |
+
The underlying PDFs are scanned classical Arabic works hosted on Archive.org, almost all past copyright. The corpus metadata and normalization work here are released under **CC-BY-4.0**. Cite the original book when quoting content.
|
| 217 |
|
| 218 |
## Citation
|
| 219 |
|