language:
- fr
license: apache-2.0
size_categories:
- 1M<n<10M
task_categories:
- text2text-generation
tags:
- postocr
- ocr
dataset_info:
features:
- name: input
dtype: string
- name: output
dtype: string
splits:
- name: train
num_bytes: 8945325563
num_examples: 2101890
download_size: 4113768600
dataset_size: 8945325563
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
Synthetic OCR Correction Dataset
This dataset is a synthetic dataset generated for post-OCR correction tasks. It contains over 2,000,000 rows of French text pairs and follows the Croissant format. It is designed to train small language models (LLMs) for text correction.
Description
To ensure the dataset closely resembles OCR-malformed texts, we applied various transformations randomly. This approach helps avoid the LLM identifying specific patterns and encourages it to select the correct word based on the surrounding context. Below are some of the transformations applied:
alterations = [
lambda x: re.sub(r'[aeiouAEIOU]', '', x), # Remove vowels
lambda x: re.sub(r'\s+', ' ', x), # Replace multiple spaces with a single space
lambda x: re.sub(r'\b\w\b', '', x), # Remove single letters
lambda x: re.sub(r'[^\w\s]', '', x), # Remove punctuation
lambda x: ''.join(random.choice((char, '')) for char in x), # Randomly drop characters
lambda x: ' '.join([
''.join(random.sample(word, len(word))) if random.random() < X else word # Scramble words with X% probability
for word in x.split()
]) # Randomly scramble words
]
In addition to the transformations listed above, we also modify punctuation, add words, and create repetitions. Feel free to customize these transformations as needed.
Recipe
Each word in the text has a 60% chance of being selected for alteration. A random number of alterations is applied to the selected words. In this release, between 30% and 60% of the words in each text can be altered. We welcome community feedback to improve this dataset further. Please feel free to share your thoughts or suggestions!