| #!/usr/bin/env python3 | |
| import json | |
| import os | |
| import shutil | |
| from tqdm import tqdm | |
| # First, let's clean up our previous attempts | |
| if os.path.exists('default'): | |
| shutil.rmtree('default') | |
| if os.path.exists('default-fixed'): | |
| shutil.rmtree('default-fixed') | |
| # Create a simple dataset with just 10 examples to test | |
| os.makedirs('simple_dataset', exist_ok=True) | |
| # Directory containing the PDF files | |
| data_dir = "data" | |
| # Get all PDF files (just the first 10 for testing) | |
| pdf_files = sorted(os.listdir(data_dir))[:10] | |
| # Create a simple metadata.jsonl file | |
| with open('simple_dataset/metadata.jsonl', 'w') as f: | |
| for pdf_file in tqdm(pdf_files, desc="Creating metadata"): | |
| file_path = os.path.join(data_dir, pdf_file) | |
| if os.path.isfile(file_path) and pdf_file.endswith('.pdf'): | |
| file_size = os.path.getsize(file_path) | |
| # Create a simple metadata entry | |
| metadata = { | |
| "file_name": pdf_file, | |
| "file_path": file_path, | |
| "file_size": file_size, | |
| "content_type": "application/pdf" | |
| } | |
| f.write(json.dumps(metadata) + '\n') | |
| # Create a simple README.md file for the dataset | |
| with open('simple_dataset/README.md', 'w') as f: | |
| f.write("""# JFK Document Collection Sample | |
| This is a sample of the JFK Document Release 2025 collection. The full collection contains over 2,000 declassified documents related to the assassination of President John F. Kennedy. | |
| ## Files | |
| The documents are PDF files named according to the National Archives naming convention (e.g., `104-10003-10041.pdf`). | |
| ## Usage | |
| You can access the full collection at: https://huggingface.co/datasets/varunh/jfk-files-2025 | |
| For a more user-friendly interface, visit: https://huggingface.co/datasets/varunh/jfk-files-2025/blob/main/index.html | |
| """) | |
| print("Created simple dataset with 10 examples") | |