Book-Data / README.md
Ouaill's picture
Update README.md
1cf3883 verified
|
Raw
History Blame Contribute Delete
5.34 kB
metadata
language:
  - ar
  - ary
license: cc-by-nc-sa-4.0
size_categories:
  - 50K<n<100K
task_categories:
  - text-generation
  - fill-mask
  - question-answering
  - text-classification
multilinguality: monolingual
pretty_name: Moroccan Cultural Books OCR Dataset
tags:
  - morocco
  - arabic
  - darija
  - history
  - culture
  - religion
  - ocr
  - books
  - north-africa

Moroccan Cultural Books OCR Dataset

Dataset Description

This dataset contains 85,600+ page-level records extracted from PDF books covering the multifaceted cultural heritage of Morocco. The corpus spans historical chronicles, religious texts, Islamic scholarship, and social commentary, reflecting Morocco's complex identity across Arab, Amazigh, Andalusian, and Mediterranean influences.

The texts were extracted using a hybrid PDF-to-text + OCR pipeline designed to handle both digital-born PDFs and scanned historical documents written in Arabic script (with extensive diacritics and occasional Latin transliterations).

Languages

  • Primary: Classical Arabic (Modern Standard Arabic)
  • Secondary: Moroccan Darija (Arabic dialect with Amazigh and French loanwords)
  • Tertiary: Occasional French and Latin terms in historical/anthropological passages

Dataset Details

Split Records Unique Books Categories
train 85,600 299 8

Data Fields

Field Type Description
name string Source PDF filename (e.g., مجمل تاريخ المغرب.pdf)
page int64 Page number within the source document
content string Extracted text content (UTF-8 Arabic script)
category string Thematic category assigned to the book
char int64 Character count of the extracted page text

Categories

The dataset covers 8 thematic categories, including but not limited to:

  • Historique — Moroccan history, pre-colonial and colonial periods, historiography
  • Religion — Islamic theology, Sufism, religious practice in Morocco
  • Muslim — Islamic civilization, jurisprudence, and scholarly works
  • (Additional categories present in the full corpus)

Source Data

The source material consists of digitized books and manuscripts stored in a categorized folder structure (/Category/Book.pdf). The corpus prioritizes works that document:

  • Pre-Islamic and Amazigh history of the Maghreb
  • Islamic dynasties (Idrisid, Almoravid, Almohad, Marinid, Saadi, Alaouite)
  • Colonial and post-colonial historiography
  • Religious and legal scholarship (fiqh, hadith, tafsir)
  • Cultural anthropology and social structures

Data Generation Pipeline

The extraction pipeline was implemented in Python using a multiprocessing architecture for scalability.

1. Text Extraction (Primary)

  • Library: pypdf (PdfReader)
  • Each page is processed sequentially; text is extracted natively from PDF content streams.
  • Cleaning: Aggressive whitespace normalization (re.sub(r'\s+', ' ', text)).

2. OCR Fallback (Secondary)

When native extraction yields fewer than 30 characters (indicating a scanned/image-based page):

  • PDF Rendering: pdf2image.convert_from_path() (Poppler backend)
  • OCR Engine: Tesseract v5.x
  • Language Pack: ara+eng (Arabic + English)
  • The OCR output undergoes the same whitespace normalization before storage.

3. Parallelization

  • Worker Pool: multiprocessing.Pool using N = CPU_COUNT - 1 workers
  • Incremental Persistence: Results are appended to a CSV in real-time to prevent data loss during long-running extractions.

4. Deduplication & Resumption

  • A processed_set tracks (category, filename) tuples.
  • The pipeline skips already-ingested books upon restart.

Code Snippet

def clean_text(text):
    text = re.sub(r'\s+', ' ', text)
    return text.strip()

# Primary extraction
text = page.extract_text()
text = "" if text is None else clean_text(text)

# OCR fallback for scanned pages
if len(text) < 30:
    images = convert_from_path(pdf_path, first_page=page_num+1, last_page=page_num+1)
    ocr_text = pytesseract.image_to_string(images[0], lang="ara+eng")
    text = clean_text(ocr_text)

License

This dataset is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).

Summary:

  • ✅ Free to use and share
  • ✅ Attribution required
  • ❌ Non-commercial use only
  • ✅ ShareAlike (derivative works must be under same license)

Citation

@dataset{mawdoo3_arabic_articles_2026,
  author       = {Ouail LAAMIRI},
  title        = {Mawdoo3 Arabic Articles Dataset - 96K+ Educational Articles from Mawdoo3.com},
  year         = 2026,
  month        = february,
  note         = {Complete dataset of 96,983 articles from Mawdoo3.com, the largest Arabic encyclopedia. Covers 18 categories including education, Islam, cooking, health, self-care, world geography, animals, family, business, technology, sports, arts, stories, wisdom, and fitness. Suitable for Arabic language modeling, QA systems, information retrieval, and NLP research.}
}