Spaces:
Running on Zero
Running on Zero
| # scripts/make_sample_articles.py | |
| import json | |
| from pathlib import Path | |
| source = Path("data/articles.json") | |
| target = Path("data/samples/articles_10.json") | |
| articles = json.loads(source.read_text()) | |
| valid = [ | |
| a | |
| for a in articles | |
| if isinstance(a, dict) | |
| and isinstance(a.get("DOI"), str) | |
| and a["DOI"] | |
| and isinstance(a.get("Title"), str) | |
| and a["Title"] | |
| and isinstance(a.get("Abstract"), str) | |
| and isinstance(a.get("Year"), int) | |
| and not isinstance(a.get("Year"), bool) | |
| ] | |
| target.parent.mkdir(parents=True, exist_ok=True) | |
| target.write_text(json.dumps(valid[:10], indent=2), encoding="utf-8") | |
| print(f"Wrote {len(valid[:10])} articles to {target}") | |