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
|
|
|
|
| 22 |
path: data/train-*
|
| 23 |
---
|
| 24 |
|
| 25 |
+
# Gutenberg-BookCorpus-Cleaned-Data-English
|
| 26 |
+
|
| 27 |
+
This dataset is been cleaned and preprocessed from preference Kaggle dataset [75,000+ Gutenberg Books and Metadata 2025](https://www.kaggle.com/datasets/lokeshparab/gutenberg-books-and-metadata-2025).
|
| 28 |
+
Following reference metadata of Gutenberg is also available and downloaded it using following CLI command below :-
|
| 29 |
+
|
| 30 |
+
```
|
| 31 |
+
pip install kaggle
|
| 32 |
+
kaggle kernels output lokeshparab/gutenberg-metadata-downloader -p /path/to/dest
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## About Project Gutenberg
|
| 36 |
+
Project Gutenberg is a digital library that hosts over 75,000 free eBooks. Users can choose among EPUB, Kindle, and plain text formats, download them, or read them online. The library primarily focuses on older literary works whose U.S. copyright has expired. Thousands of volunteers have digitized and meticulously proofread the eBooks for readers to enjoy.
|
| 37 |
+
|
| 38 |
+
## Dataset Details
|
| 39 |
+
| Column | Description |
|
| 40 |
+
|-----------------------------------------|--------------------------------------------------------------------|
|
| 41 |
+
| **book_title** | Title of the book. |
|
| 42 |
+
| **Authors** | Author(s) of the respective book. |
|
| 43 |
+
| **Issued** | Date when the book was published or added to the collection. |
|
| 44 |
+
| **Context** | Cleaned and preprocessed the plain text version in UTF-8 encoding. |
|
| 45 |
+
|
| 46 |
+
## Gutenberg English Preprocessor (Methodolody)
|
| 47 |
+
|
| 48 |
+
The **Gutenberg English Preprocessor** is designed to clean and preprocess text data from Project Gutenberg files by removing unwanted patterns such as special markers, Gutenberg-specific sentences, and decorative text blocks.
|
| 49 |
+
|
| 50 |
+
* **Notebook Reference** :- [Click here](https://www.kaggle.com/code/lokeshparab/demo-of-using-gutenberg-for-english)
|
| 51 |
+
|
| 52 |
+
* **Following Features** :-
|
| 53 |
+
- **Removes Blocks Enclosed in `=` Symbols** — Eliminates text sections framed by lines of `=` symbols, often found in decorative headers or footers.
|
| 54 |
+
- **Removes Gutenberg-Specific Sentences** — Filters out sentences containing the term "Gutenberg" in any case (uppercase, lowercase, or mixed).
|
| 55 |
+
- **Removes Small Print Notices** — Identifies and removes text segments marked as "Small Print" content.
|
| 56 |
+
- **Trims Text Between Project Gutenberg Start/End Markers** — Extracts content enclosed between `*** START OF THE PROJECT GUTENBERG...` and `*** END OF THE PROJECT GUTENBERG...`.
|
| 57 |
+
- **Removes Inline and Block Patterns Marked with `*`, `**`, `***`, etc.** — Effectively cleans unwanted text patterns that are enclosed in stars.
|
| 58 |
+
|
| 59 |
+
* **Class function** :-
|
| 60 |
+
```python
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class Gutenberg_English_Preprocessor:
|
| 64 |
+
"""
|
| 65 |
+
A text preprocessor designed to clean Project Gutenberg text data.
|
| 66 |
+
This class removes unwanted patterns like:
|
| 67 |
+
- Blocks enclosed in '=' lines
|
| 68 |
+
- Sentences containing "Gutenberg" (case insensitive)
|
| 69 |
+
- "Small Print" sections from Project Gutenberg files
|
| 70 |
+
- Blocks enclosed in '*' patterns
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
def __init__(self, text: str):
|
| 74 |
+
"""
|
| 75 |
+
Initializes the Gutenberg_English_Preprocessor with the provided text.
|
| 76 |
+
|
| 77 |
+
Args:
|
| 78 |
+
text (str): The text content to be processed.
|
| 79 |
+
"""
|
| 80 |
+
self.text = text
|
| 81 |
+
|
| 82 |
+
def remove_equal_sign_blocks(self):
|
| 83 |
+
"""
|
| 84 |
+
Removes blocks of text enclosed by lines containing only '=' symbols.
|
| 85 |
+
|
| 86 |
+
Example:
|
| 87 |
+
========================
|
| 88 |
+
This content will be removed.
|
| 89 |
+
========================
|
| 90 |
+
"""
|
| 91 |
+
equal_block_pattern = r'^\s*=+\s*\n(?:.*?\n)*?\s*=+\s*$'
|
| 92 |
+
self.text = re.sub(equal_block_pattern, '', self.text, flags=re.MULTILINE)
|
| 93 |
+
self.text = self.text.strip()
|
| 94 |
+
|
| 95 |
+
def remove_gutenberg_sentences(self):
|
| 96 |
+
"""
|
| 97 |
+
Removes sentences that contain the word "Gutenberg" in any case format.
|
| 98 |
+
|
| 99 |
+
Example:
|
| 100 |
+
"This is a Project Gutenberg text." → Removed
|
| 101 |
+
"Random sentence without Gutenberg." → Removed
|
| 102 |
+
"This is a normal sentence." → Retained
|
| 103 |
+
"""
|
| 104 |
+
gutenberg_pattern = r'^[^\n]*\bgutenberg\b[^\n]*\n?'
|
| 105 |
+
self.text = re.sub(gutenberg_pattern, '', self.text, flags=re.IGNORECASE | re.MULTILINE)
|
| 106 |
+
self.text = self.text.strip()
|
| 107 |
+
|
| 108 |
+
def remove_small_print(self):
|
| 109 |
+
"""
|
| 110 |
+
Removes Project Gutenberg's "Small Print" sections.
|
| 111 |
+
These sections often contain legal disclaimers and metadata.
|
| 112 |
+
"""
|
| 113 |
+
pattern1 = r'\*\*\*START\*\*THE SMALL PRINT.*?\*END\*THE SMALL PRINT!'
|
| 114 |
+
pattern2 = r'\*\*\*START\*\*THE SMALL PRINT.*?\*END THE SMALL PRINT'
|
| 115 |
+
|
| 116 |
+
self.text = re.sub(pattern1, '', self.text, flags=re.DOTALL)
|
| 117 |
+
self.text = re.sub(pattern2, '', self.text, flags=re.DOTALL)
|
| 118 |
+
self.text = self.text.strip()
|
| 119 |
+
|
| 120 |
+
def start_end(self):
|
| 121 |
+
"""
|
| 122 |
+
Trims the text to retain only the content between:
|
| 123 |
+
- "*** START OF THE PROJECT GUTENBERG..."
|
| 124 |
+
- "*** END OF THE PROJECT GUTENBERG..."
|
| 125 |
+
|
| 126 |
+
Ensures non-essential content outside these markers is excluded.
|
| 127 |
+
"""
|
| 128 |
+
str_str = "*** START OF THE PROJECT GUTENBERG"
|
| 129 |
+
end_str = "*** END OF THE PROJECT GUTENBERG"
|
| 130 |
+
|
| 131 |
+
start_idx = self.text.find(str_str)
|
| 132 |
+
end_idx = self.text.find(end_str)
|
| 133 |
+
|
| 134 |
+
if start_idx != -1 and end_idx != -1:
|
| 135 |
+
self.text = self.text[start_idx:end_idx]
|
| 136 |
+
|
| 137 |
+
def remove_patterns(self):
|
| 138 |
+
"""
|
| 139 |
+
Removes patterns enclosed by '*' characters, such as:
|
| 140 |
+
- Inline patterns like "* text *", "** text **", etc.
|
| 141 |
+
- Standalone patterns and multi-line blocks enclosed in '*'
|
| 142 |
+
"""
|
| 143 |
+
star_pattern = r'^\s*\*{1,4}.*?\*{1,4}\s*$'
|
| 144 |
+
self.text = re.sub(star_pattern, '', self.text, flags=re.MULTILINE | re.DOTALL)
|
| 145 |
+
self.text = self.text.strip()
|
| 146 |
+
|
| 147 |
+
def preprocess(self):
|
| 148 |
+
"""
|
| 149 |
+
Executes the full text preprocessing pipeline by calling all individual
|
| 150 |
+
cleaning functions in the desired sequence.
|
| 151 |
+
|
| 152 |
+
Returns:
|
| 153 |
+
str: The cleaned and processed text content.
|
| 154 |
+
"""
|
| 155 |
+
self.start_end()
|
| 156 |
+
self.remove_small_print()
|
| 157 |
+
self.remove_patterns()
|
| 158 |
+
self.remove_equal_sign_blocks()
|
| 159 |
+
self.remove_gutenberg_sentences()
|
| 160 |
+
return self.text
|
| 161 |
+
```
|
| 162 |
+
* **Execution Steps**
|
| 163 |
+
|
| 164 |
+
```python
|
| 165 |
+
preprocessor = Gutenberg_English_Preprocessor(text="Here contents Gutenberg text")
|
| 166 |
+
clean_text = preprocessor.preprocess()
|
| 167 |
+
```
|
| 168 |
+
## Usage
|
| 169 |
+
|
| 170 |
+
This dataset can be effectively applied to various Natural Language Processing (NLP) and Machine Learning (ML) tasks, such as:
|
| 171 |
+
|
| 172 |
+
* **Creating Embeddings**: Extract meaningful vector representations for search engines and recommendation systems.
|
| 173 |
+
* **Training Transformers**: Utilize the dataset to train transformer models like BERT, GPT, etc., for improved language understanding and generation.
|
| 174 |
+
* **Language Model Fine-tuning**: Fine-tune LLMs (Large Language Models) to enhance performance in specific domains or tasks.
|
| 175 |
+
* **Text Analysis and Classification**: Conduct topic modeling, sentiment analysis, or language detection.
|
| 176 |
+
* **Information Retrieval**: Develop powerful search systems by indexing the dataset with metadata attributes.
|
| 177 |
+
|