Download scripts/loop_organ.py from spark-school/school-corpus: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/datasets/spark-school/school-corpus/resolve/main/scripts/loop_organ.py
- Command line
-
hf download hf://datasets/spark-school/school-corpus/scripts/loop_organ.py
-
curl -L -o loop_organ.py https://huggingface.co/datasets/spark-school/school-corpus/resolve/main/scripts/loop_organ.py
2.26 kB
| #!/usr/bin/env python3 | |
| """loop_organ.py — loop-quality census (keeper directive 2026-10-19: 'how to improve the quality of the loop?') | |
| Counts, over a named window of CORPUS rows: | |
| datums = rows carrying new laws/datums/batteries (erosion pass, P-KNOW/P-COLD filed, datum) | |
| firings = rows naming a firing/sweep of a claim (firing, swept, caught) | |
| taste = rows carrying aesthetic artifacts (eros-taste-notes admitted, journal admitted, MEDITATION admitted, DREAM) | |
| Prints per-category counts and per-day rates. A ratio is a claim: the organ prints its window endpoints and unit. | |
| """ | |
| import re, sys, time, calendar | |
| U = r"C:/Users/user/1f916-contribution" | |
| def census(since_iso, until_iso=None): | |
| txt = open(U + r"\CORPUS.md", encoding="utf-8").read() | |
| # store carries date-only header rows ('| 2026-10-11 — ...'); require full ISO stamp shape | |
| iso = re.compile(r"^\| (2026-\d\d-\d\dT\d\d:\d\d:\d\dZ) \|") | |
| rows = [l for l in txt.splitlines() if iso.match(l)] | |
| def ts(l): | |
| return calendar.timegm(time.strptime(iso.match(l).group(1), "%Y-%m-%dT%H:%M:%SZ")) | |
| a = calendar.timegm(time.strptime(since_iso, "%Y-%m-%dT%H:%M:%SZ")) | |
| b = calendar.timegm(time.strptime(until_iso, "%Y-%m-%dT%H:%M:%SZ")) if until_iso else time.time() | |
| win = [l for l in rows if a <= ts(l) <= b] | |
| datums = [l for l in win if re.search(r"erosion pass \d+ shipped|P-KNOW-\d+ filed|P-COLD-\d+ filed|datum:", l)] | |
| firings = [l for l in win if re.search(r"firing|swept|caught", l, re.I)] | |
| taste = [l for l in win if re.search(r"eros-taste-notes-\d+ admitted|journal-\d+ admitted|MEDITATION-\d+ admitted|DREAM-\d+", l)] | |
| days = (b - a) / 86400.0 | |
| print(f"WINDOW: {since_iso} -> {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(b))} ({round(days,2)} days)") | |
| print(f"rows in window: {len(win)}") | |
| for name, lst in [("datums", datums), ("firings", firings), ("taste", taste)]: | |
| print(f"{name}: {len(lst)} rows = {round(len(lst)/days, 2)} /day (unit: CORPUS rows, substring match)") | |
| return {"rows": len(win), "datums": len(datums), "firings": len(firings), "taste": len(taste), "days": round(days,2)} | |
| if __name__ == "__main__": | |
| since = sys.argv[1] if len(sys.argv) > 1 else "2026-10-19T00:00:00Z" | |
| census(since) | |