diff --git a/crates/weksa/examples/show_working.rs b/crates/weksa/examples/show_working.rs index cf24b64..897bc13 100644 --- a/crates/weksa/examples/show_working.rs +++ b/crates/weksa/examples/show_working.rs @@ -254,6 +254,10 @@ fn lower_error(e: &LowerError) -> Value { LowerError::NoForm { entity } => ("NoForm", format!("{entity} has no en-US form")), LowerError::NoPronunciation { entity } => ("NoPronunciation", format!("{entity} has no ruled en-US pronunciation")), LowerError::NoEntityReferent => ("NoEntityReferent", "the packet cites no entity".to_string()), + LowerError::UnknownPhone { entity, at, .. } => ("UnknownPhone", format!("the ruled pronunciation of {entity} holds a symbol at {at} with no listed phone")), + LowerError::DanglingStress { entity, at } => ("DanglingStress", format!("the ruled pronunciation of {entity} has a stress mark at {at} with no vowel after it")), + LowerError::ConsentMissing { predication } => ("ConsentMissing", format!("{predication} is a request the packet does not carry the addressee's consent to")), + LowerError::AskerNotAddressee { predication } => ("AskerNotAddressee", format!("the agent of {predication} is not the addressee")), LowerError::EntityRead { entity, why } => ("EntityRead", format!("reading {entity}: {why}")), }; json!({ "variant": variant, "reason": reason, "debug": format!("{e:?}") }) diff --git a/tools/show-working/build.py b/tools/show-working/build.py index 269032e..a4c9bc5 100755 --- a/tools/show-working/build.py +++ b/tools/show-working/build.py @@ -46,10 +46,17 @@ weksa_bin = target / "weksa" data = json.loads(run([str(target / "examples" / "show_working")])) # -- 2. the real scorer ------------------------------------------------------- +REFS_EXTRA = ["item:nibu:2"] +# The page publishes only the corpus items its fixtures cite (plus the extra +# reference each lowered fixture is scored against). A Validation or Test item +# is never published: the dump holds every split. +cited = {fx["corpus_item"] for fx in data["fixtures"]} | set(REFS_EXTRA) corpus = {} for m in re.finditer(r'^(item:\S+) \[(.*?)\]\n "(.*)"$', run([str(weksa_bin), "corpus", "dump"]), re.M): - corpus[m.group(1)] = {"text": m.group(3), "meta": m.group(2)} -REFS_EXTRA = ["item:nibu:2"] + if m.group(1) in cited: + corpus[m.group(1)] = {"text": m.group(3), "meta": m.group(2)} +if set(corpus) != cited: + sys.exit(f"corpus dump lacks cited items {sorted(cited - set(corpus))}; unexpected {sorted(set(corpus) - cited)}") model = "qwen3-embedding:0.6b" @@ -77,6 +84,11 @@ data["build"] = { } out_dir.mkdir(parents=True, exist_ok=True) (out_dir / "data.json").write_text(json.dumps(data, indent=1, ensure_ascii=False), encoding="utf-8") +# Guard, read back from the published file: no item key outside what a fixture cites. +published = json.loads((out_dir / "data.json").read_text(encoding="utf-8")) +stray = set(published["corpus"]) - cited +if stray or set(published["corpus"]) != cited: + sys.exit(f"data.json corpus {sorted(published['corpus'])} is not exactly the cited items {sorted(cited)}; stray: {sorted(stray)}") # -- 3. the page -------------------------------------------------------------- CSS = """