|
|
|
import json |
|
import os |
|
import shutil |
|
from tqdm import tqdm |
|
|
|
|
|
if os.path.exists('default'): |
|
shutil.rmtree('default') |
|
if os.path.exists('default-fixed'): |
|
shutil.rmtree('default-fixed') |
|
|
|
|
|
os.makedirs('simple_dataset', exist_ok=True) |
|
|
|
|
|
data_dir = "data" |
|
|
|
|
|
pdf_files = sorted(os.listdir(data_dir))[:10] |
|
|
|
|
|
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) |
|
|
|
|
|
metadata = { |
|
"file_name": pdf_file, |
|
"file_path": file_path, |
|
"file_size": file_size, |
|
"content_type": "application/pdf" |
|
} |
|
|
|
f.write(json.dumps(metadata) + '\n') |
|
|
|
|
|
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") |
|
|