| --- |
| language: |
| - ar |
| license: cc-by-4.0 |
| pretty_name: Asfar — Arabic Heritage Text Corpus |
| size_categories: |
| - 100K<n<1M |
| task_categories: |
| - text-generation |
| - fill-mask |
| - feature-extraction |
| tags: |
| - arabic |
| - classical-arabic |
| - heritage |
| - turath |
| - language-modeling |
| - corpus |
| configs: |
| - config_name: default |
| data_files: |
| - split: train |
| path: data/train-*.parquet |
| dataset_info: |
| features: |
| - name: item_id |
| dtype: string |
| - name: collection |
| dtype: string |
| - name: book_title |
| dtype: string |
| - name: book_title_source |
| dtype: string |
| - name: book_raw |
| dtype: string |
| - name: pdf_filename |
| dtype: string |
| - name: page |
| dtype: int64 |
| - name: total_pages |
| dtype: int64 |
| - name: text |
| dtype: string |
| - name: raw_text |
| dtype: string |
| - name: text_norm |
| dtype: string |
| - name: char_count |
| dtype: int64 |
| - name: char_count_norm |
| dtype: int64 |
| - name: arabic_ratio |
| dtype: float64 |
| - name: arabic_ratio_norm |
| dtype: float64 |
| - name: di_confidence |
| dtype: float64 |
| - name: pdf_url |
| dtype: string |
| - name: source_detail_url |
| dtype: string |
| - name: shard |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 123062 |
| --- |
| |
| # Asfar — أَسْفَار |
|
|
| **A page-level corpus of classical Arabic heritage.** |
| 123,062 pages · 461 PDF volumes · 6 Archive.org collections · Modern & Classical Arabic. |
|
|
| *`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.* |
|
|
| --- |
|
|
| ## Summary |
|
|
| | | | |
| |---|---| |
| | Rows (pages) | **123,062** | |
| | Unique PDF volumes | **461** | |
| | Unique parsed book titles | **121** (the other 339 PDFs were uploaded under filename codes — see below) | |
| | Archive.org collections | **6** | |
| | Language | Arabic (Modern Standard and Classical) | |
| | Median chars per page | 1,245 | |
| | Median Arabic-letter ratio | 0.971 | |
| | Split | single `train` split | |
| | Format | Parquet, 5 shards, zstd-compressed | |
| | License | CC-BY-4.0 (metadata & normalization work); underlying books are public-domain — cite the book | |
|
|
| --- |
|
|
| ## Quickstart |
|
|
| ```python |
| from datasets import load_dataset |
| |
| ds = load_dataset("HeshamHaroon/asfar", split="train") |
| print(ds) |
| print(ds[0]["text_norm"][:200]) |
| ``` |
|
|
| To use only rows with a recovered book title: |
|
|
| ```python |
| titled = ds.filter(lambda r: r["book_title_source"] == "parsed_from_pdf_name") |
| # ≈ 45,013 pages across 121 named books |
| ``` |
|
|
| --- |
|
|
| ## Columns |
|
|
| ### Text |
|
|
| | Column | Dtype | Purpose | |
| |---|---|---| |
| | **`text_norm`** | `string` | Primary training column. NFC-normalized, tatweel removed, tashkeel stripped, lam-alef ligatures expanded, whitespace collapsed. | |
| | `text` | `string` | OCR output after an LLM cleaning pass (publisher-supplied). Keep diacritics if present. | |
| | `raw_text` | `string` | Pre-cleaning OCR. Useful as the noisy side of a `raw_text` → `text` OCR-denoising pair. | |
| |
| ### Source identity |
| |
| | Column | Dtype | Purpose | |
| |---|---|---| |
| | **`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"`, `"tta0104.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. | |
| | **`book_title_source`** | `string` | One of: `parsed_from_pdf_name` (45,013 rows / 122 PDFs / 121 distinct titles), `pdf_code` (78,049 rows / 339 PDFs), `pdf_stem` (edge cases). | |
| | `book_raw` | `string` | The original, unprocessed `book` string from the upstream dataset (= PDF filename stem). Kept for auditing the parsing. | |
| | `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. | |
| | `item_id` | `string` | Archive.org item identifier (links to `source_detail_url`). | |
| | `pdf_filename` | `string` | Original PDF filename as uploaded to Archive.org. | |
| | `pdf_url` | `string` | Direct download URL for the source PDF on Archive.org. | |
| | `source_detail_url` | `string` | Archive.org item/collection detail page. | |
| | `shard` | `string` | Original `az_NNNN` config name from the upstream `HeshamHaroon/arabic-turath-ocr` dataset. Provenance only. | |
|
|
| ### Position |
|
|
| | Column | Dtype | Purpose | |
| |---|---|---| |
| | `page` | `int64` | Page index within the PDF. | |
| | `total_pages` | `int64` | Total pages in the PDF. | |
|
|
| ### Quality signals |
|
|
| | Column | Dtype | Purpose | |
| |---|---|---| |
| | `char_count`, `char_count_norm` | `int64` | Character count of `text` and `text_norm`. | |
| | `arabic_ratio`, `arabic_ratio_norm` | `float64` | Fraction of non-whitespace characters in the Arabic Unicode block. | |
| | `di_confidence` | `float64` | Document-intelligence confidence reported by the upstream OCR pipeline. | |
|
|
| --- |
|
|
| ## Archive.org collections |
|
|
| Six collections account for all 461 volumes. Three of them use codes as PDF filenames — the titles aren't recoverable from metadata alone. The other three use readable Arabic titles. |
|
|
| | pages | PDFs | collection | filename convention | |
| |---:|---:|---|---| |
| | 45,249 | 229 | كتب عربية - طبعات قديمة | numeric codes (e.g. `10668.pdf`, `30283.pdf`) | |
| | 29,450 | 100 | كتب منوعة - المائة الثانية pdf | `a###` codes (e.g. `a025.pdf`, `a077.pdf`) | |
| | 28,202 | 99 | كتب متنوعة في اللغة العربية ولسانها | Arabic titles | |
| | 12,030 | 7 | مختارات من كتب الأدب العربي | Arabic titles (multi-volume sets) | |
| | 4,781 | 16 | كتب عن تاريخ بلاد الحرمين و نجد - طبعات نادرة و قديمة و ملونة | Arabic titles | |
| | 3,350 | 10 | تاريخ التراث العربي - فؤاد سزكين | `tta####` codes | |
|
|
| A per-volume inventory of all 461 PDFs is published alongside this README as [`VOLUMES.md`](VOLUMES.md) (human-readable, grouped by collection) and [`volumes.json`](volumes.json) (machine-readable). |
|
|
| --- |
|
|
| ## All titled volumes (121) |
|
|
| Every PDF whose filename encoded a real book title. Pages sum to 45,013. |
|
|
| | pages | title | |
| |---:|---| |
| | 4,824 | خزانة الأدب ولب لباب لسان العرب | |
| | 2,547 | تجريد الأغاني | |
| | 2,123 | الكامل في اللغة والأدب | |
| | 2,013 | المقتصد في شرح التكملة للجرجاني | |
| | 1,676 | توضيح المقاصد والمسالك شرح ألفية ابن مالك للمرادي | |
| | 974 | كتاب الأمالي مع كتابي ذيل الأمالي والنوادر | |
| | 889 | أدب الكاتب | |
| | 792 | التقفية في اللغة | |
| | 696 | المنتخب من أدب العرب | |
| | 679 | الزاهر في غريب ألفاظ الشافعي | |
| | 669 | المعرب من كلام الاعجم على حروف المعجم | |
| | 654 | المدخل إلى تقويم اللسان | |
| | 596 | تصحيح الفصيح وشرحه | |
| | 583 | الفروق في اللغة | |
| | 582 | المقتضب | |
| | 557 | الدراسات اللغوية والنحوية في مؤلفات ابن تيمية | |
| | 552 | تاريخ أحمد باشا الجزار - حيدر أحمد الشهابي - مكتبة انطوان 1955 | |
| | 534 | الغريب المصنف | |
| | 510 | كتاب الاضداد | |
| | 503 | تاريخ نجد الحديث وملحقاته - دار ريحاني - بيروت 1954 | |
| | 498 | أبنية الأسماء والأفعال والمصادر، لابن القطاع الصقلي | |
| | 494 | أسرار العربية | |
| | 473 | اصلاح المنطق لابن السكيت | |
| | 471 | قلب جزيرة العرب - فؤاد حمزة - المطبعة السلفية ومكتبتها - مكة المكرمة - 1933 | |
| | 456 | جزيرة العرب في القرن العشرين ؛ لجنة التأليف والترجمة والنشر ؛ القاهرة 1354-1935 | |
| | 447 | تحفة المستفيد بتاريخ الاحساء في القديم والجديد 1 - آل عبد القادر - مطابع الرياض - الرياض - 1960 | |
| | 436 | شرح الفصيح | |
| | 425 | الموجز في قواعد اللغة | |
| | 420 | مختارات من أدب العرب | |
| | 418 | الدراسات النحوية واللغوية عن الزمخشري | |
|
|
| <details> |
| <summary><b>Show remaining 91 titled volumes</b></summary> |
|
|
| | pages | title | |
| |---:|---| |
| | 411 | لحن العوام | |
| | 398 | الاخطاء في حروف الجر | |
| | 393 | المشترك اللغوي | |
| | 385 | لغة قريش | |
| | 380 | تثقيف اللسان العربي | |
| | 378 | الفرق بين الاحرف الخمسة | |
| | 376 | التهذيب بمحكم الترتيب | |
| | 367 | البحث اللغوي عند العرب | |
| | 363 | ابن جني النحوي | |
| | 353 | النحو العصري | |
| | 342 | علم اللغة | |
| | 339 | صيحة في سبيل العربية | |
| | 339 | القراءة الراشدة | |
| | 338 | العشرات في اللغة | |
| | 324 | أسرار العربية (3) | |
| | 322 | أضواء على المملكة العربية السعودية - المديرية العامة للإذاعة - الرياض - 1958-1377 | |
| | 319 | ما اتفق لفظه واختلف معناه | |
| | 319 | الفروق اللغوية | |
| | 313 | معالم تاريخ الجزيرة العربية - سعيد عوض با وزير - مؤسسة الصبان - عدن 1966 | |
| | 313 | عمر فاروق الطباع - الوسيط في قواعد الإملاء والإنشاء | |
| | 305 | تثقيف اللسان وتلقيح الجنان | |
| | 299 | الجملة العربية | |
| | 280 | عنوان المجد في بيان أحوال بغداد والبصرة ونجد - دار منشورات البصري - بغداد 1962 | |
| | 279 | مناهج البحث في اللغة | |
| | 269 | الصاحبي في فقه اللغة | |
| | 268 | بحوث في اللغة | |
| | 268 | الشعر النبطي | |
| | 267 | التدريبات اللغوية | |
| | 265 | البلاد العربية السعودية - فؤاد حمزة, مطبعة أم القرى 1355-1937 | |
| | 263 | أخطاء اللغة عند المعاصرين | |
| | 262 | المملكة العربية السعودية في عهدها الحاضر - مديرية العامة للإذاعة, جدة 1376-1957 | |
| | 260 | اقتطاف الأزاهر | |
| | 254 | تقويم اللسان | |
| | 253 | تاريخ ملوك آل سعود - مطابع الرياض - 1961 | |
| | 239 | المطالع النصرية | |
| | 239 | تقويم اللسان (2) | |
| | 235 | أسرار العربية (2) | |
| | 227 | الصاحبي في فقه اللغة (2) | |
| | 224 | معجم الدخيل | |
| | 220 | الجملة العربية (2) | |
| | 219 | العربية والحداثة | |
| | 216 | المقتضب في لهجات العرب | |
| | 216 | الرياض المزهرة بين الكويت والمحمرة - عبد المسيح أنطاكي بيك - مطبعة العرب - القاهرة - 1907 | |
| | 213 | اللسان والإنسان | |
| | 208 | الحسن والإحسان | |
| | 199 | الشامل في اللغة لطلبة الجامعات والمعاهد غير المتخصصين | |
| | 197 | اللغة العربية أداءً ونطقاً | |
| | 177 | تعقبات مصابيح الجامع | |
| | 174 | المعرب من كلام الأعجمي على حروف المعجم | |
| | 172 | أسرار العربية (4) | |
| | 168 | أخطاء لغوية شائعة | |
| | 163 | ما تلحن فيه العامة | |
| | 162 | المقتبس من اللهجات | |
| | 153 | نحو تقويم جديد | |
| | 152 | عثرات اللسان | |
| | 146 | علم نفسك الخطوط | |
| | 146 | عنوان المجد في تاريخ نجد 1 ؛ مطبعة الشابندر 1328-1910 | |
| | 140 | الأمالي للزجاج | |
| | 139 | ملك وآمال الشعب - زينب الغزالي - دار الكتاب العربي؛ 1954 | |
| | 137 | الفرق بين الضاد والظاء للداني | |
| | 131 | زينة الفضلاء في الفرق بين الضاد والظاء | |
| | 130 | قواعد الإملاء | |
| | 127 | الكافي في اللغة | |
| | 127 | التشكيل الصوتي في اللغة | |
| | 110 | إتحاف الأماجد بما يصح به الاستشهاد | |
| | 108 | الفرق بين المذكر والمؤنث | |
| | 95 | شرح مثلثات قطرب | |
| | 94 | نقعة الصديان | |
| | 89 | التعريف بما آنست الهجرة من معالم دار الهجرة 1372-1952 | |
| | 77 | قواعد الإملاء (3) | |
| | 75 | كيف تكون فصيحاً | |
| | 67 | في قلب نجد والحجاز - مكتبة المنار - مصر 1927 | |
| | 64 | الإملاء والترقيم | |
| | 64 | الفرق بين الضاد والظاء | |
| | 64 | العربية | |
| | 53 | شرح الفصيح — مقدمة | |
| | 49 | الفرق بين الضاد والظاء (variant) | |
| | 46 | الزيادات على كتاب لحن العامة بالأندلس | |
| | 41 | كتاب السلاح | |
| | 28 | قواعد الإملاء (2) | |
| | 26 | التنبيه على حدوث التصحيف — مقدمة | |
| | 24 | أسرار العربية — مقدمة | |
| | 21 | الأرقام العربية | |
| | 20 | الفروق في اللغة — مقدمة | |
| | 11 | كتاب الأضداد — مقدمة | |
| | 10 | إصلاح المنطق لابن السكيت — مقدمة | |
| | 8 | إصلاح المنطق — نماذج | |
| | 8 | ما اتفق لفظه واختلف معناه — مقدمة | |
| | 5 | تثقيف اللسان العربي — مقدمة | |
| | 4 | مناهج البحث في اللغة — مقدمة | |
| | 1 | رسالتان في اللغة للأصمعي | |
|
|
| </details> |
|
|
| The remaining **339 PDFs** are filename-coded (not titled). Their codes are inventoried in [`VOLUMES.md`](VOLUMES.md) along with page counts and `pdf_url` links to their Archive.org source — you can cross-reference any individual code there to inspect it. |
|
|
| --- |
|
|
| ## Construction |
|
|
| 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. |
| 2. **Normalize text.** `text_norm` derived from `text` via: |
| - Unicode NFC normalization |
| - removal of U+0640 (ـ, tatweel) |
| - removal of U+064B–U+065F and U+0670 (tashkeel / harakat) |
| - expansion of lam-alef ligatures (ﻻ → لا, ﻷ → لأ, ﻹ → لإ, ﻵ → لآ) |
| - collapse of all whitespace — including zero-width joiner, zero-width non-joiner, and NBSP — to a single space |
| 3. **Filter.** Rows were dropped where: |
| - `char_count_norm < 50` (OCR fragments, blank pages) |
| - `arabic_ratio_norm < 0.5` (foreign-language pages, tables, colophons) |
| - `text_norm` exactly duplicates an earlier row (ordered by `book, page`) |
| 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. Filenames consisting purely of letters-then-digits (e.g. `a025`, `tta0104`) are classified as `pdf_code`. |
| 5. **Yield.** 123,062 of 128,105 input rows kept — 96.1%. |
|
|
| ### Drops breakdown |
|
|
| | reason | rows | |
| |---|---:| |
| | empty / < 50 chars after normalization | 3,730 | |
| | Arabic-letter ratio < 0.5 | 1,128 | |
| | exact-duplicate normalized text | 185 | |
|
|
| ### Arabic-letter ratio distribution (of merged input) |
|
|
| | bucket | rows | |
| |---|---:| |
| | < 30% Arabic | 3,208 | |
| | 30–50% | 415 | |
| | 50–70% | 1,085 | |
| | 70–90% | 7,933 | |
| | ≥ 90% Arabic | 115,464 | |
|
|
| ### book_title_source breakdown |
|
|
| | source | rows | PDFs | |
| |---|---:|---:| |
| | `parsed_from_pdf_name` | 45,013 | 122 | |
| | `pdf_code` | 78,049 | 339 | |
|
|
| --- |
|
|
| ## Suggested use |
|
|
| - **Causal LM pre-training / continued pre-training** on classical Arabic — `text_norm`. |
| - **OCR denoising**: `raw_text` ↔ `text` as noisy-clean training pairs. |
| - **Lexical and grammatical resources**: the top ten volumes are dictionaries, fiqh al-lugha works, and commentaries. |
| - **Domain adapters** for models that need to handle pre-modern Arabic registers. |
|
|
| For tasks where diacritics or glyph form matter — Quranic recitation alignment, classical prosody, tashkeel restoration — use `text` or `raw_text` rather than `text_norm`. |
|
|
| --- |
|
|
| ## Licensing & provenance |
|
|
| 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`. |
|
|
| --- |
|
|
| ## Citation |
|
|
| ```bibtex |
| @dataset{haroon_asfar_2026, |
| author = {Haroon, Hesham}, |
| title = {Asfar: An Arabic Heritage Text Corpus}, |
| year = {2026}, |
| url = {https://huggingface.co/datasets/HeshamHaroon/asfar}, |
| } |
| ``` |
|
|