Download doc/HOW_TO_ADD_AN_ENTRY.py from tailot/lingologos-thinkingpython: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/doc/HOW_TO_ADD_AN_ENTRY.py
- Command line
-
hf download hf://datasets/tailot/lingologos-thinkingpython/doc/HOW_TO_ADD_AN_ENTRY.py
-
curl -L -o HOW_TO_ADD_AN_ENTRY.py https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/doc/HOW_TO_ADD_AN_ENTRY.py
2.46 kB
| """How to add one entry to the catalog, as an executable checklist. | |
| Run it: python doc/HOW_TO_ADD_AN_ENTRY.py | |
| It does not add anything. It states, in code, the seven things a new entry owes the | |
| bundle, and checks each one against the catalog as it stands, so the list cannot rot. | |
| 1. an id, a family, a shape, a source, in catalog/patterns.json | |
| 2. an effect sentence and a lock sentence, both about the observable change | |
| 3. refusals: the reason codes this entry may legitimately answer with | |
| 4. a min_assurance the entry must reach before a run may claim VERIFIED | |
| 5. a frame id, and a phrase set for that frame in each of the six lexicon files | |
| 6. a rule and a lock test: shapes.py edit_<shape> plus tests/test_edit_pair.py | |
| 7. a conflict policy for every pair of entries that can claim the same symbol | |
| Then: python tools/build_corpus.py && python tools/measure_coverage.py | |
| python tools/run_gates.py --catalog-regress | |
| The last command compares the eval top-1 against results/coverage.baseline.json and | |
| fails if a pre-existing entry lost more than 0.02, which is how growth stays safe. | |
| """ | |
| import json | |
| import os | |
| import sys | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, ROOT) | |
| from lingologos_thinkingpython import catalog, lexicon # noqa: E402 | |
| REQUIRED = ("id", "family", "shape", "source", "effect", "lock", "refusals", | |
| "min_assurance", "frames") | |
| def check() -> int: | |
| entries = catalog.load_entries() | |
| policies = catalog.load_policies() | |
| problems = [] | |
| for entry in entries: | |
| for key in REQUIRED: | |
| if key not in entry: | |
| problems.append("%s: missing %s" % (entry.get("id", "?"), key)) | |
| for frame in entry.get("frames", []): | |
| for lang in lexicon.LANGS: | |
| phrases = lexicon.load(lang)["frames"].get(frame) or [] | |
| if not phrases: | |
| problems.append("%s: no %s phrase for frame %s" % (entry["id"], lang, frame)) | |
| claims = {} | |
| for entry in entries: | |
| claims.setdefault(entry["shape"], []).append(entry["id"]) | |
| defects, _resolved = catalog.conflict_lines(claims, policies) | |
| problems.extend(defects) | |
| for line in problems: | |
| print("MISSING " + line) | |
| print("entries=%d checked=%d problems=%d" % (len(entries), len(entries), len(problems))) | |
| return 1 if problems else 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(check()) | |