CoolFace
Datasetpublic

FatimahEmadEldin/Gutenberg-Arabic-OCR-HTML-Pages

Gutenberg Arabic HTML-Page Dataset ๐Ÿ“– Dataset Description The Gutenberg Arabic HTML-Page Dataset is a large-scale, synthetically generated dataset designed for training and evaluating document understanding and Optical Character Recognition (OCR) models. The primary goal of this project is to provide a comprehensive resource of page images paired with their corresponding structured HTML ground truth, with a focus on the Arabic language. The dataset was created byโ€ฆ See the full description on the dataset page: https://huggingface.co/datasets/FatimahEmadEldin/Gutenberg-Arabic-OCR-HTML-Pages.

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
3likes125downloads
Dataset Card

Gutenberg Arabic HTML-Page Dataset

๐Ÿ“– Dataset Description

The Gutenberg Arabic HTML-Page Dataset is a large-scale, synthetically generated dataset designed for training and evaluating document understanding and Optical Character Recognition (OCR) models. The primary goal of this project is to provide a comprehensive resource of page images paired with their corresponding structured HTML ground truth, with a focus on the Arabic language.

The dataset was created by processing classic English literature from the Project Gutenberg library. The content was automatically translated into Arabic and then rendered into thousands of unique page images, featuring a wide variety of layouts, fonts, and sizes to ensure model robustness.

This resource is ideal for tasks such as:

  • โ€”OCR for non-standard Arabic fonts.
  • โ€”Document layout analysis.
  • โ€”Training models to understand the semantic structure of a page (e.g., headers, paragraphs).

๐Ÿ› ๏ธ Dataset Creation

The creation process followed a multi-stage automated pipeline:

1. Source Data Acquisition

A selection of popular books was downloaded in HTML format from the Project Gutenberg library. This provided the base text and initial document structure.

2. Automated Translation

The raw English HTML content of each book was parsed, and all text nodes were translated into Arabic using the Google Translate API (via the deep-translator library). This step preserved the original HTML tags while replacing the text content.

3. Page Segmentation and Rendering

The translated HTML books were too large to be used as single data points. Therefore, a script using Playwright was developed to intelligently segment the content into individual pages. This process works by:

  • โ€”Virtually rendering the book in a headless browser.
  • โ€”Measuring the content height as text is added.
  • โ€”"Cutting" the page once it reaches the maximum height for a given layout.

4. Synthetic Data Augmentation

To create a diverse and robust dataset, several augmentation techniques were applied during the rendering phase:

  • โ€”Page Layouts: Pages were rendered using multiple dimensions and aspect ratios.
  • โ€”A4 (794x1123 px)
  • โ€”Letter (816x1056 px)
  • โ€”Small (600x850 px)
  • โ€”Typography: A variety of high-quality, open-source Arabic fonts were used randomly for each page to ensure models do not overfit to a single style.
  • โ€”Fonts Used: Noto Naskh Arabic, Amiri, Tajawal, Cairo, Lateef, IBM Plex Sans Arabic.
  • โ€”Font Sizes: Ranged from 14pt to 24pt.

5. Structural Heuristics

A key feature of this dataset is its structured ground truth. Simple heuristics were applied to the HTML of each page to automatically add basic semantic tags, better reflecting a real-world document structure.

  • โ€”Short, standalone lines at the start of a page were wrapped in <header><h1>...</h1></header>.
  • โ€”All page content was enclosed within <main><section>...</section></main> tags.

๐Ÿ“Š Dataset Statistics

The current version of the dataset consists of 1,316 pages generated from 16 distinct books.

Included Books

Book TitleGutenberg IDPage Count
Pride and Prejudice1342629
The Adventures of Tom Sawyer74333
A Tale of Two Cities23 & 9870
The Adventures of Huckleberry Finn7648
Anne of Green Gables4542
The War of the Worlds3632
Frankenstein8431
The Wonderful Wizard of Oz5528
A Christmas Carol4620
Peter Pan1620
Through the Looking-Glass1217
Alice's Adventures in Wonderland1115
The Adventures of Sherlock Holmes166115
The Strange Case of Dr. Jekyll and Mr. Hyde4313
The Legend of Sleepy Hollow413
Total-1,316

Exploratory Data Analysis (EDA)

An analysis of the generated HTML files reveals the following distribution of key structural tags:

TagTotal OccurrencesPages with TagPercentage of Pages
<main>1,3161,316 / 1,316100.00%
<section>1,3161,316 / 1,316100.00%
<p>21,2121,260 / 1,31695.74%
<h1>194180 / 1,31613.68%
<header>178178 / 1,31613.53%
<footer>00 / 1,3160.00%

This shows that every page has a consistent base structure (<main>, <section>), and a significant portion (~13.5%) were identified as having headers. The absence of <footer> tags is an artifact of the simple heuristics used, which could be expanded in future versions.


๐Ÿ“ Dataset Structure

The dataset is organized into three main components:

  • โ€”/images: A folder containing all rendered PNG page images.
  • โ€”/html: A folder containing the corresponding structured HTML ground truth files.
  • โ€”metadata.csv: A manifest file that links each image to its HTML file. It contains two columns: image_path and html_path.

๐Ÿš€ How to Use

You can easily load and work with this dataset using the datasets library.

python
from datasets import load_dataset
from PIL import Image
import requests
from io import BytesIO

# Load the dataset from the Hugging Face Hub
dataset = load_dataset("FatimahEmadEldin/Gutenberg-Arabic-OCR-HTML-Pages")

# Function to fetch and process the data
def get_example(index):
    example = dataset['train'][index]
    
    # The image_path is now a PIL Image object automatically loaded by datasets
    image = example['image_path']
    
    # The html_path is now the string content of the HTML file
    html_content = example['html_path']
    
    return image, html_content

# Get the first example
image, html = get_example(0)

print("Displaying Image:")
display(image)

print("\nCorresponding HTML:")
print(html)

Citing the Dataset

If you use this dataset in your research, please consider citing it:

python

@misc{EmadEldin_2025_gutenberg_arabic,
  author = {Fatimah Emad Eldin},
  title = {Gutenberg Arabic HTML-Page Dataset},
  year = {2025},
  publisher = {Hugging Face},
  journal = {Hugging Face repository},
  howpublished = {\url{[https://huggingface.co/datasets/FatimahEmadEldin/Gutenberg-Arabic-OCR-HTML-Pages](https://huggingface.co/datasets/FatimahEmadEldin/Gutenberg-Arabic-OCR-HTML-Pages)}},
}