Tablinum-2: the Lite-Beam engram, release 2 (card, code, recipes, 9 released tables)
901f964 verified Download code/cdc_dolma.py from tablinum/tablinum-2: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/datasets/tablinum/tablinum-2/resolve/main/code/cdc_dolma.py
- Command line
-
hf download hf://datasets/tablinum/tablinum-2/code/cdc_dolma.py
-
curl -L -o cdc_dolma.py https://huggingface.co/datasets/tablinum/tablinum-2/resolve/main/code/cdc_dolma.py
1.64 kB
| """cdc_dolma.py META.csv OUT.json.gz ZIP... (10-27) - CDC journals (MMWR weekly / RR / SS / supplements / notifiable diseases, EID, | |
| PCD) from github.com/cmheilig/harvest-cdc-journals (CC0; research/health.md #1: surveillance numbers, vaccine schedules, outbreak | |
| firsts that PubMed abstracts lack) -> dolma json.gz for dolma_chunk.py doc. Each zip holds {url: plain text}; titles and datelines | |
| come from csv-output/cdc_corpus_df.csv. Title "CDC <SERIES> (<dateline>): <title>". Health: local only.""" | |
| import sys, csv, json, gzip, zipfile, os, re | |
| meta, dst, zips = sys.argv[1], sys.argv[2], sys.argv[3:] | |
| csv.field_size_limit(1 << 30) | |
| M = {r["url"]: r for r in csv.DictReader(open(meta, encoding="utf-8"))} | |
| BOIL = re.compile(r"^.{0,400}?(subject line of e-mail\.|Accommodation and the title of the report[^.]*\.)\s*", re.S) | |
| n = 0 | |
| with gzip.open(dst + ".tmp", "wt") as f: | |
| for z in zips: | |
| zf = zipfile.ZipFile(z) | |
| for name in zf.namelist(): | |
| for url, txt in json.load(zf.open(name)).items(): | |
| m = M.get(url, {}); txt = BOIL.sub("", txt or "") | |
| if len(txt.split()) < 40: | |
| continue | |
| t = re.sub(r"^CDC - |\s+", " ", m.get("title") or "").strip() or txt.split("\n", 1)[0][:120] | |
| title = f"CDC {(m.get('series') or name.split('_')[0]).upper()} ({m.get('dateline') or m.get('dl_year_mo') or ''}): {t}" | |
| f.write(json.dumps({"id": url, "text": txt, "metadata": {"title": re.sub(r"\s+", " ", title)[:160]}}) + "\n"); n += 1 | |
| print(z, "docs so far", n, flush=True) | |
| os.replace(dst + ".tmp", dst) | |
| print("docs", n, flush=True) | |