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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
data_files:
|
| 31 |
- split: train
|
| 32 |
path: data/train-*
|
| 33 |
+
license: cc0-1.0
|
| 34 |
+
language:
|
| 35 |
+
- en
|
| 36 |
+
size_categories:
|
| 37 |
+
- 100K<n<1M
|
| 38 |
+
tags:
|
| 39 |
+
- ocr
|
| 40 |
+
- handwriting-recognition
|
| 41 |
+
- library-science
|
| 42 |
+
- glam
|
| 43 |
+
pretty_name: Boston Public Library Card Catalog
|
| 44 |
---
|
| 45 |
+
|
| 46 |
+
# Boston Public Library Rare Books Card Catalog Dataset
|
| 47 |
+
|
| 48 |
+
## Dataset Description
|
| 49 |
+
|
| 50 |
+
This dataset contains approximately **410,000 digitized catalog cards** from the Boston Public Library's Rare Books Department card catalog. The cards represent the main entry catalog (author/title cross-referenced) covering printed materials from various historical periods.
|
| 51 |
+
|
| 52 |
+
### Why This Dataset?
|
| 53 |
+
|
| 54 |
+
Historical card catalogs are rich sources of:
|
| 55 |
+
|
| 56 |
+
- **Bibliographic information** structured in semi-standardized formats
|
| 57 |
+
- **Handwritten and typewritten text** from multiple time periods and catalogers
|
| 58 |
+
- **Historical cataloging practices** including subject classification and cross-referencing
|
| 59 |
+
- **Metadata about rare and historically significant materials**
|
| 60 |
+
|
| 61 |
+
This dataset is valuable for training and evaluating AI models on:
|
| 62 |
+
- OCR and handwriting recognition for historical documents
|
| 63 |
+
- Information extraction from semi-structured text
|
| 64 |
+
- Layout analysis of document formats
|
| 65 |
+
- Vision-language model performance on library/archival materials
|
| 66 |
+
|
| 67 |
+
### Dataset Summary
|
| 68 |
+
|
| 69 |
+
- **Total Cards**: ~410,000 individual catalog cards
|
| 70 |
+
- **Total Drawers**: 386 drawers organized alphabetically
|
| 71 |
+
- **Image Format**: JPG (converted from JP2)
|
| 72 |
+
- **OCR Coverage**: ~100% (Tesseract 5.x via Internet Archive)
|
| 73 |
+
- **Source**: [Internet Archive - BPL Rare Books Catalog](https://archive.org/details/bplrbcatalog)
|
| 74 |
+
- **Original Institution**: Boston Public Library Rare Books Department
|
| 75 |
+
|
| 76 |
+
## Dataset Structure
|
| 77 |
+
|
| 78 |
+
### Data Fields
|
| 79 |
+
|
| 80 |
+
| Field | Type | Description |
|
| 81 |
+
|-------|------|-------------|
|
| 82 |
+
| `image` | Image | JPG image of the catalog card (~800-1000px width) |
|
| 83 |
+
| `drawer_id` | string | Internet Archive item identifier (e.g., "248-pach-palmas") |
|
| 84 |
+
| `card_number` | int | Card position within drawer (0-indexed) |
|
| 85 |
+
| `filename` | string | Original filename of the card image |
|
| 86 |
+
| `text` | string | OCR-extracted text from the card (Tesseract 5.x) |
|
| 87 |
+
| `has_ocr` | bool | Whether OCR text is available for this card |
|
| 88 |
+
| `source` | string | Attribution string |
|
| 89 |
+
| `source_url` | string | Direct link to source drawer on Internet Archive |
|
| 90 |
+
| `ia_collection` | string | Internet Archive collection identifier |
|
| 91 |
+
|
| 92 |
+
### Data Splits
|
| 93 |
+
|
| 94 |
+
This dataset contains a single `train` split with all catalog cards.
|
| 95 |
+
|
| 96 |
+
### Example
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
from datasets import load_dataset
|
| 100 |
+
|
| 101 |
+
dataset = load_dataset("davanstrien/bpl-card-catalog")
|
| 102 |
+
|
| 103 |
+
# Access a sample
|
| 104 |
+
sample = dataset['train'][0]
|
| 105 |
+
print(f"Card #{sample['card_number']}")
|
| 106 |
+
print(f"OCR Text:\n{sample['text']}")
|
| 107 |
+
|
| 108 |
+
# Display the card image
|
| 109 |
+
sample['image'].show()
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Typical Card Contents
|
| 113 |
+
|
| 114 |
+
Catalog cards typically contain:
|
| 115 |
+
- **Author names** (surname, forename)
|
| 116 |
+
- **Book titles** and subtitles
|
| 117 |
+
- **Publication information** (publisher, place, date)
|
| 118 |
+
- **Physical description** (pages, illustrations, size)
|
| 119 |
+
- **Call numbers** and shelfmarks
|
| 120 |
+
- **Subject headings** and cross-references
|
| 121 |
+
- **Notes** on condition, provenance, or special features
|
| 122 |
+
|
| 123 |
+
## Dataset Creation
|
| 124 |
+
|
| 125 |
+
### Source Data
|
| 126 |
+
|
| 127 |
+
The cards were originally created by Boston Public Library catalogers over many decades, representing a historical record of the library's rare books collection. The physical cards were digitized by BPL and uploaded to the Internet Archive with OCR processing.
|
| 128 |
+
|
| 129 |
+
### Collection Process
|
| 130 |
+
|
| 131 |
+
1. **Digitization**: Boston Public Library photographed each drawer of cards
|
| 132 |
+
2. **OCR Processing**: Internet Archive applied Tesseract OCR to create searchable text
|
| 133 |
+
3. **Dataset Creation**: Images were extracted from JP2 archives, converted to JPG, and paired with OCR text
|
| 134 |
+
|
| 135 |
+
### Data Processing
|
| 136 |
+
|
| 137 |
+
- Original format: JP2 images in ZIP archives on Internet Archive
|
| 138 |
+
- Converted to: JPG at 95% quality for ML compatibility
|
| 139 |
+
- OCR format: HOCR (HTML with bounding boxes) → plain text extraction
|
| 140 |
+
- Organization: Preserved original drawer organization and card order
|
| 141 |
+
|
| 142 |
+
## Uses
|
| 143 |
+
|
| 144 |
+
### Example Use Cases
|
| 145 |
+
|
| 146 |
+
**OCR Model Evaluation**
|
| 147 |
+
```python
|
| 148 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
| 149 |
+
|
| 150 |
+
processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten')
|
| 151 |
+
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten')
|
| 152 |
+
|
| 153 |
+
# Evaluate on catalog cards with ground truth OCR
|
| 154 |
+
for sample in dataset['train'].select(range(100)):
|
| 155 |
+
pixel_values = processor(sample['image'], return_tensors="pt").pixel_values
|
| 156 |
+
generated_ids = model.generate(pixel_values)
|
| 157 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 158 |
+
|
| 159 |
+
# Compare with ground truth
|
| 160 |
+
print(f"Ground truth: {sample['text'][:100]}")
|
| 161 |
+
print(f"Generated: {generated_text[:100]}")
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
**Information Extraction**
|
| 165 |
+
```python
|
| 166 |
+
# Extract structured bibliographic data
|
| 167 |
+
import re
|
| 168 |
+
|
| 169 |
+
def extract_author(text):
|
| 170 |
+
# Authors typically appear at start, often in "Surname, Forename" format
|
| 171 |
+
lines = text.split('\n')
|
| 172 |
+
if lines:
|
| 173 |
+
return lines[0].strip()
|
| 174 |
+
return None
|
| 175 |
+
|
| 176 |
+
# Process cards to extract authors
|
| 177 |
+
authors = [extract_author(card['text']) for card in dataset['train']]
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
**VLM Evaluation**
|
| 181 |
+
```python
|
| 182 |
+
from transformers import AutoProcessor, AutoModelForVision2Seq
|
| 183 |
+
|
| 184 |
+
processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b")
|
| 185 |
+
model = AutoModelForVision2Seq.from_pretrained("HuggingFaceM4/idefics2-8b")
|
| 186 |
+
|
| 187 |
+
# Ask questions about catalog cards
|
| 188 |
+
messages = [
|
| 189 |
+
{
|
| 190 |
+
"role": "user",
|
| 191 |
+
"content": [
|
| 192 |
+
{"type": "image"},
|
| 193 |
+
{"type": "text", "text": "What is the author and title of this book?"}
|
| 194 |
+
]
|
| 195 |
+
}
|
| 196 |
+
]
|
| 197 |
+
|
| 198 |
+
for card in dataset['train'].select(range(10)):
|
| 199 |
+
text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
| 200 |
+
inputs = processor(images=[card['image']], text=text, return_tensors="pt")
|
| 201 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 202 |
+
print(processor.decode(outputs[0], skip_special_tokens=True))
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
## Bias, Risks, and Limitations
|
| 206 |
+
|
| 207 |
+
### Known Biases
|
| 208 |
+
|
| 209 |
+
1. **Historical Language**: Cards use terminology that may be considered offensive by modern standards, reflecting historical cataloging practices and societal biases.
|
| 210 |
+
|
| 211 |
+
2. **Western Canon Bias**: The collection reflects the collecting priorities and interests of a major American library, which historically focused on Western European and American materials.
|
| 212 |
+
|
| 213 |
+
3. **Cataloger Variation**: Cataloging practices evolved over time; older cards may use different standards than newer ones.
|
| 214 |
+
|
| 215 |
+
### OCR Limitations
|
| 216 |
+
|
| 217 |
+
- **Handwriting Variation**: Some cards are handwritten with varying legibility
|
| 218 |
+
- **Typewriter Quality**: Older typewritten cards may have faded or unclear text
|
| 219 |
+
- **Special Characters**: Diacritical marks, mathematical symbols, or non-Latin scripts may be incorrectly recognized
|
| 220 |
+
- **Layout Complexity**: Multi-column layouts, annotations, or crossed-out text may confuse OCR
|
| 221 |
+
|
| 222 |
+
## Additional Information
|
| 223 |
+
|
| 224 |
+
### Dataset Curators
|
| 225 |
+
|
| 226 |
+
- **Digitization**: Boston Public Library Rare Books Department
|
| 227 |
+
- **Hosting & OCR**: Internet Archive
|
| 228 |
+
- **Dataset Creation**: Daniel van Strien ([@davanstrien](https://huggingface.co/davanstrien))
|
| 229 |
+
|
| 230 |
+
### Licensing Information
|
| 231 |
+
|
| 232 |
+
The catalog card images are in the **public domain** as works of the U.S. government or works whose copyright has expired. The dataset is released under **CC0 1.0 Universal (Public Domain Dedication)**.
|
| 233 |
+
|
| 234 |
+
### Acknowledgments
|
| 235 |
+
|
| 236 |
+
- **Boston Public Library** for digitizing this invaluable historical resource and making it publicly accessible
|
| 237 |
+
- **Internet Archive** for hosting the collection and providing OCR processing
|
| 238 |
+
- The **catalogers** who created these cards over many decades, preserving knowledge about rare books
|
| 239 |
+
|
| 240 |
+
### Links
|
| 241 |
+
|
| 242 |
+
- **Source Collection**: https://archive.org/details/bplrbcatalog
|
| 243 |
+
- **BPL Guide**: https://guides.bpl.org/rarebooks/book-search
|
| 244 |
+
- **Statement on Harmful Language**: https://guides.bpl.org/rarebooks/book-search#s-lg-box-27736072
|
| 245 |
+
|
| 246 |
+
### Version History
|
| 247 |
+
|
| 248 |
+
- **v1.0** (2025): Initial release with ~410,000 cards from 386 drawers
|
| 249 |
+
|
| 250 |
+
### Contact
|
| 251 |
+
|
| 252 |
+
For questions about this dataset, please open an issue in the dataset repository
|