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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
- config_name: default
|
| 4 |
+
features:
|
| 5 |
+
- name: book_id
|
| 6 |
+
dtype: int32
|
| 7 |
+
- name: shamela_id
|
| 8 |
+
dtype: int32
|
| 9 |
+
- name: title_ar
|
| 10 |
+
dtype: string
|
| 11 |
+
- name: category_id
|
| 12 |
+
dtype: int8
|
| 13 |
+
- name: category_name_ar
|
| 14 |
+
dtype: string
|
| 15 |
+
- name: main_author_id
|
| 16 |
+
dtype: int32
|
| 17 |
+
- name: main_author_name_ar
|
| 18 |
+
dtype: string
|
| 19 |
+
- name: main_author_death_hijri
|
| 20 |
+
dtype: int16
|
| 21 |
+
- name: page_count
|
| 22 |
+
dtype: int32
|
| 23 |
+
- name: body
|
| 24 |
+
dtype: string
|
| 25 |
+
- name: footnotes
|
| 26 |
+
dtype: string
|
| 27 |
+
- name: page_num
|
| 28 |
+
dtype: int16
|
| 29 |
+
splits:
|
| 30 |
+
- name: full
|
| 31 |
+
num_bytes: 19000000000
|
| 32 |
+
num_examples: 8589
|
| 33 |
+
download_size: 19000000000
|
| 34 |
+
dataset_size: 19000000000
|
| 35 |
+
- config_name: meta
|
| 36 |
+
features:
|
| 37 |
+
- name: authors
|
| 38 |
+
dtype: struct
|
| 39 |
+
- name: book_metadata
|
| 40 |
+
dtype: struct
|
| 41 |
+
- name: categories
|
| 42 |
+
dtype: struct
|
| 43 |
+
- name: quran_verses
|
| 44 |
+
dtype: struct
|
| 45 |
+
- name: narrators
|
| 46 |
+
dtype: struct
|
| 47 |
+
- name: root_dictionary
|
| 48 |
+
dtype: struct
|
| 49 |
+
- name: hadith_xrefs
|
| 50 |
+
dtype: struct
|
| 51 |
+
- name: tafsir_xrefs
|
| 52 |
+
dtype: struct
|
| 53 |
+
- name: page_isnads
|
| 54 |
+
dtype: struct
|
| 55 |
+
splits:
|
| 56 |
+
- name: meta
|
| 57 |
+
num_bytes: 185000000
|
| 58 |
+
num_examples: 1
|
| 59 |
+
configs:
|
| 60 |
+
- config_name: default
|
| 61 |
+
data_files:
|
| 62 |
+
- split: full
|
| 63 |
+
path: "*/**"
|
| 64 |
+
- config_name: meta
|
| 65 |
+
data_files:
|
| 66 |
+
- split: meta
|
| 67 |
+
path: "_meta/**"
|
| 68 |
+
license: mit
|
| 69 |
+
license_url: https://shamela.ws
|
| 70 |
+
language:
|
| 71 |
+
- ar
|
| 72 |
+
multilinguality:
|
| 73 |
+
- monolingual
|
| 74 |
+
size_categories:
|
| 75 |
+
- 10M<n<100M
|
| 76 |
+
annotations_creators:
|
| 77 |
+
- found
|
| 78 |
+
source_datasets:
|
| 79 |
+
- original
|
| 80 |
+
task_categories:
|
| 81 |
+
- text-generation
|
| 82 |
+
- fill-mask
|
| 83 |
+
- token-classification
|
| 84 |
+
- question-answering
|
| 85 |
+
- text-retrieval
|
| 86 |
+
task_ids:
|
| 87 |
+
- language-modeling
|
| 88 |
+
- named-entity-recognition
|
| 89 |
+
pretty_name: Shamela 4 — Full Islamic Library Corpus
|
| 90 |
+
tags:
|
| 91 |
+
- islamic-studies
|
| 92 |
+
- arabic
|
| 93 |
+
- classical-arabic
|
| 94 |
+
- quran
|
| 95 |
+
- hadith
|
| 96 |
+
- fiqh
|
| 97 |
+
- tafsir
|
| 98 |
+
- aqeedah
|
| 99 |
+
- arabic-linguistics
|
| 100 |
+
- shamela
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
# Shamela 4 — Full Islamic Library Corpus
|
| 104 |
+
|
| 105 |
+
A complete extraction of **al-Maktaba al-Shamela (الشاملة) v4**, containing **8,589 books** across **40 categories** of classical Islamic sciences. Extracted from the production PostgreSQL database on 2026-04-26 with ~7.6 million pages and ~19 GB of Arabic text.
|
| 106 |
+
|
| 107 |
+
## Dataset Structure
|
| 108 |
+
|
| 109 |
+
```
|
| 110 |
+
stage0_raw/
|
| 111 |
+
├── _meta/ # Cross-cutting metadata (Parquet + JSONL)
|
| 112 |
+
│ ├── extraction_manifest.json # Global extraction record
|
| 113 |
+
│ ├── authors.parquet # 3,187 authors
|
| 114 |
+
│ ├── book_metadata.parquet # All 8,589 book records
|
| 115 |
+
│ ├── categories.parquet # 41 categories
|
| 116 |
+
│ ├── quran_verses.parquet # 6,236 verses (entire Quran)
|
| 117 |
+
│ ├── narrators.parquet # 18,989 hadith narrators
|
| 118 |
+
│ ├── root_dictionary.parquet # ~1.95M Arabic root entries
|
| 119 |
+
│ ├── hadith_xrefs.parquet # ~37K cross-references
|
| 120 |
+
│ ├── tafsir_xrefs.parquet # ~84K exegesis links
|
| 121 |
+
│ ├── page_isnads.parquet # ~35K transmission chains
|
| 122 |
+
│ └── *.jsonl # Text-preview equivalents
|
| 123 |
+
│
|
| 124 |
+
├── 01__العقيدة/ # Category directories (numbered 01–40)
|
| 125 |
+
│ └── 1__الفواكه-العذاب-في-الرد/ # Per-book directories
|
| 126 |
+
│ ├── manifest.json # Integrity checksums + metadata
|
| 127 |
+
│ ├── book_metadata.json # Bibliographic record
|
| 128 |
+
│ ├── toc.jsonl # Table of contents (JSONL)
|
| 129 |
+
│ └── pages.jsonl # Full page text (JSONL)
|
| 130 |
+
│
|
| 131 |
+
├── ...
|
| 132 |
+
│
|
| 133 |
+
└── 40__علوم-أخرى/
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
### Per-Book Files
|
| 137 |
+
|
| 138 |
+
| File | Format | Description |
|
| 139 |
+
|------|--------|-------------|
|
| 140 |
+
| `manifest.json` | JSON | Extraction metadata, SHA-256 checksums, page/toc counts |
|
| 141 |
+
| `book_metadata.json` | JSON | Title, author(s), death dates, category, edition info |
|
| 142 |
+
| `toc.jsonl` | JSONL | Hierarchical table of contents with page anchors |
|
| 143 |
+
| `pages.jsonl` | JSONL | Full page content: body text, footnotes, page numbers |
|
| 144 |
+
|
| 145 |
+
### Pages JSONL Schema
|
| 146 |
+
|
| 147 |
+
```jsonc
|
| 148 |
+
{
|
| 149 |
+
"page_id": 1, // Sequential page ID
|
| 150 |
+
"book_id": 1, // FK to book
|
| 151 |
+
"shamela_page_id": 1, // Original Shamela ID
|
| 152 |
+
"part": null, // Volume/part (for multi-volume books)
|
| 153 |
+
"page_num": 3, // Printed page number
|
| 154 |
+
"sequence_num": 1, // Reading order
|
| 155 |
+
"body": "Arabic text...", // Main text with minimal HTML:
|
| 156 |
+
// <span data-type='title' id=toc-N>Heading</span>
|
| 157 |
+
"footnotes": null, // Footnote text (¬١, ¬٢ markers)
|
| 158 |
+
"hints": null, // Additional annotations
|
| 159 |
+
"services_raw": null // Source service data
|
| 160 |
+
}
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
### TOC JSONL Schema
|
| 164 |
+
|
| 165 |
+
```jsonc
|
| 166 |
+
{
|
| 167 |
+
"title_id": 1,
|
| 168 |
+
"book_id": 1,
|
| 169 |
+
"page_id": 5, // Page where heading appears
|
| 170 |
+
"parent_id": null, // Hierarchical parent (null = root)
|
| 171 |
+
"shamela_title_id": 2,
|
| 172 |
+
"title_text": "مقدمة المحقق" // Heading text
|
| 173 |
+
}
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
### Book Metadata Schema
|
| 177 |
+
|
| 178 |
+
```jsonc
|
| 179 |
+
{
|
| 180 |
+
"book_id": 1,
|
| 181 |
+
"shamela_id": 1,
|
| 182 |
+
"title_ar": "الفواكه العذاب في الرد على من لم يحكم السنة والكتاب",
|
| 183 |
+
"book_type": 1,
|
| 184 |
+
"book_type_label": "كتاب",
|
| 185 |
+
"category_id": 1,
|
| 186 |
+
"category_name_ar": "العقيدة",
|
| 187 |
+
"main_author_id": 513,
|
| 188 |
+
"main_author_name_ar": "حمد بن ناصر آل معمر",
|
| 189 |
+
"main_author_death_hijri": 1225,
|
| 190 |
+
"authors": [
|
| 191 |
+
{ "author_id": 513, "role": "author", "name_ar": "...", "death_hijri": 1225 }
|
| 192 |
+
],
|
| 193 |
+
"printed": true,
|
| 194 |
+
"is_hidden": false,
|
| 195 |
+
"betaka_text": "Full bibliographic description...",
|
| 196 |
+
"version_major": 5,
|
| 197 |
+
"version_minor": 0,
|
| 198 |
+
"volume_count_observed": 0,
|
| 199 |
+
"has_multi_part": false
|
| 200 |
+
}
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
## Statistics
|
| 204 |
+
|
| 205 |
+
| Metric | Count |
|
| 206 |
+
|--------|-------|
|
| 207 |
+
| **Books** | 8,589 |
|
| 208 |
+
| **Pages** | 7,611,186 |
|
| 209 |
+
| **TOC entries** | 4,060,485 |
|
| 210 |
+
| **Authors** | 3,187 |
|
| 211 |
+
| **Categories** | 41 |
|
| 212 |
+
| **Isnad (chains)** | 35,526 |
|
| 213 |
+
| **Narrators** | 18,989 |
|
| 214 |
+
| **Quran verses** | 6,236 |
|
| 215 |
+
| **Tafsir cross-refs** | 84,430 |
|
| 216 |
+
| **Hadith cross-refs** | 37,076 |
|
| 217 |
+
| **Root dictionary** | 1,952,803 |
|
| 218 |
+
| **Total size** | ~19 GB |
|
| 219 |
+
| **Meta directory** | ~177 MB |
|
| 220 |
+
| **Rejected books** | 0 |
|
| 221 |
+
|
| 222 |
+
### Largest Categories
|
| 223 |
+
|
| 224 |
+
| # | Category | Books |
|
| 225 |
+
|---|----------|-------|
|
| 226 |
+
| 06 | كتب السنة (Hadith Collections) | 1,241 |
|
| 227 |
+
| 01 | العقيدة (Creed) | 807 |
|
| 228 |
+
| 23 | الرقائق والآداب والأذكار (Spirituality) | 625 |
|
| 229 |
+
| 26 | التراجم والطبقات (Biographies) | 579 |
|
| 230 |
+
| 19 | مسائل فقهية (Fiqh Issues) | 429 |
|
| 231 |
+
| 32 | الأدب (Literature) | 406 |
|
| 232 |
+
| 39 | كتب عامة (General) | 357 |
|
| 233 |
+
| 10 | علوم الحديث (Hadith Sciences) | 320 |
|
| 234 |
+
|
| 235 |
+
## Coverage
|
| 236 |
+
|
| 237 |
+
All major Islamic disciplines:
|
| 238 |
+
|
| 239 |
+
- **Quranic:** Tafsir, Quran Sciences, Tajwid & Qira'at
|
| 240 |
+
- **Hadith:** The six canonical collections (Kutub al-Sittah), Musnad Ahmad, Muwatta Malik, plus commentaries, sciences (`ilal, rijāl, `ilal), takhrij
|
| 241 |
+
- **Fiqh:** All four Sunni madhahib (Hanafi, Maliki, Shafi'i, Hanbali), general fiqh, usul al-fiqh, fiqh maxims, fatāwā
|
| 242 |
+
- **Aqeedah:** Classical creedal works, refutations, theological debates
|
| 243 |
+
- **Arabic Language:** Grammar (nahw), morphology (sarf), rhetoric (balāgha), lexicons, poetry, prosody
|
| 244 |
+
- **History & Biography:** Sirah, tarikh, tabaqat, genealogy, geography
|
| 245 |
+
- **Other:** Logic, medicine, general works
|
| 246 |
+
|
| 247 |
+
## Data Notes
|
| 248 |
+
|
| 249 |
+
- **Text is raw** — minimal HTML markup preserved (`<span data-type='title'>`, `<hr>`, `<table>`)
|
| 250 |
+
- **Footnote markers** — `(¬N)` notation linking body to footnotes
|
| 251 |
+
- **Quranic text** — bracketed with `﴿...﴾` markers
|
| 252 |
+
- **Honorifics** — ﷺ (SAW), ﵁, ﷿, etc. are single Unicode codepoints
|
| 253 |
+
- **Multi-volume works** — linked via `parent_id` / `group_id` in metadata
|
| 254 |
+
- **Author death dates** — Hijri years; negative values = CE dates
|
| 255 |
+
- **Hidden books** — `is_hidden: true` indicates copyright/access restrictions
|
| 256 |
+
- **`\r` line endings** — Shamela uses `\r` (carriage return) instead of `\n`
|
| 257 |
+
- **Base64 images** — some pages contain inline `<img>` with base64 data
|
| 258 |
+
|
| 259 |
+
## Extraction
|
| 260 |
+
|
| 261 |
+
- **Source:** Production PostgreSQL 16 (dockerized)
|
| 262 |
+
- **Method:** psycopg server-side cursor stream, constant memory
|
| 263 |
+
- **Date:** 2026-04-26
|
| 264 |
+
- **Extractor:** shamela-extractor v0.3.0
|
| 265 |
+
- **Snapshot:** `shamela4_full_extraction_pg_2026_04_26`
|
| 266 |
+
- **No books rejected** — all 8,589 books extracted successfully
|
| 267 |
+
|
| 268 |
+
## Usage Examples
|
| 269 |
+
|
| 270 |
+
### Load with Hugging Face Datasets
|
| 271 |
+
|
| 272 |
+
```python
|
| 273 |
+
from datasets import load_dataset
|
| 274 |
+
|
| 275 |
+
# Load a single book by filtering
|
| 276 |
+
ds = load_dataset("yourusername/Shamela4_Full_DB", split="full")
|
| 277 |
+
book_1 = ds.filter(lambda x: x["book_id"] == 1)
|
| 278 |
+
|
| 279 |
+
# Or stream individual JSONL files directly
|
| 280 |
+
import json
|
| 281 |
+
with open("01__العقيدة/1__الفواكه-العذاب/pages.jsonl") as f:
|
| 282 |
+
for line in f:
|
| 283 |
+
page = json.loads(line)
|
| 284 |
+
print(page["body"][:200])
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
### Load metadata with Polars
|
| 288 |
+
|
| 289 |
+
```python
|
| 290 |
+
import polars as pl
|
| 291 |
+
|
| 292 |
+
df = pl.read_parquet("_meta/book_metadata.parquet")
|
| 293 |
+
df.filter(pl.col("category_id") == 3) # All tafsir books
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
+
### Query roots from the root dictionary
|
| 297 |
+
|
| 298 |
+
```python
|
| 299 |
+
df = pl.read_parquet("_meta/root_dictionary.parquet")
|
| 300 |
+
df.filter(pl.col("token").str.contains("صلو"))
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
## Intended Uses
|
| 304 |
+
|
| 305 |
+
- **Classical Islamic text research** — full-text search, citation extraction, cross-book linking
|
| 306 |
+
- **Arabic NLP** — language modeling on classical Arabic (pre-modern, diacritized, diverse genres)
|
| 307 |
+
- **Hadith studies** — chain-of-transmission analysis, narrator networks, takhrij
|
| 308 |
+
- **Intertextuality analysis** — quotation detection, author attribution, topic propagation
|
| 309 |
+
- **Lexicography** — root extraction, semantic field analysis from medieval dictionaries
|
| 310 |
+
- **LLM training/evaluation** — high-quality classical Arabic data for fine-tuning or evaluation
|
| 311 |
+
|
| 312 |
+
## Limitations
|
| 313 |
+
|
| 314 |
+
- This is a full DB dump, including the encoded Narrator tables, etc.
|
| 315 |
+
|
| 316 |
+
## License
|
| 317 |
+
|
| 318 |
+
This dataset is derived from **al-Maktaba al-Shamela (الشاملة)**, a free digital library of classical Islamic texts. The original texts are in the public domain. The compilation and digitization rights belong to their respective owners.
|
| 319 |
+
|
| 320 |
+
**Terms of use:** Research and personal use. Respect the intellectual property rights of muhaqqiqīn (editors) and publishers for critical editions.
|
| 321 |
+
|
| 322 |
+
## Citation
|
| 323 |
+
|
| 324 |
+
```bibtex
|
| 325 |
+
@misc{shamela4_full_2026,
|
| 326 |
+
title = {Shamela 4 — Full Islamic Library Corpus},
|
| 327 |
+
author = {{AuthenticIlm}},
|
| 328 |
+
year = {2026},
|
| 329 |
+
note = {Extracted from al-Maktaba al-Shamela v4. 8,589 books, 7.6M pages.},
|
| 330 |
+
url = {https://huggingface.co/datasets/AuthenticIlm/Shamela4_Full_DB}
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
@online{shamela,
|
| 334 |
+
title = {al-Maktaba al-Shamela},
|
| 335 |
+
url = {https://shamela.ws}
|
| 336 |
+
}
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
---
|