Skip to content

Resolve copula predicate to subject's licensed type (issue #128 R12)#130

Merged
konard merged 2 commits into
mainfrom
issue-128-fed1f7a14626
May 29, 2026
Merged

Resolve copula predicate to subject's licensed type (issue #128 R12)#130
konard merged 2 commits into
mainfrom
issue-128-fed1f7a14626

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented May 29, 2026

Issue #128 R12 — resolve "Hawaii is a state." to the most-correct sense

This follow-up to PR #129 (which delivered R1–R11) addresses the deeper
requirement raised in review: the predicate "state" in "Hawaii is a state."
must resolve to the most correct sense in context
Q35657 U.S. state
(Russian: Штат США) — not the
generic federated-state concept Q7275.

Root cause

A bare noun like "state" cannot be disambiguated on its own. But in a copula
sentence the subject already carries an asserted type: Hawaii instance of
(P31) Q35657 "U.S. state". The formalizer never used that licensed type to
constrain the predicate, so "state" stayed generic and the translation leaned
on a hardcoded English→Russian rule.

Fix — language-neutral copula type resolution at formalization time

A new pass promotes the copula predicate to the subject's asserted
instance-of / subclass-of type when their head words agree:

  • Hawaii is a state. → "state" resolves to Q35657en.wikipedia.org/wiki/U.S._state
  • Гавайи это штат. resolves identically via the same logic — no per-language rule

The bespoke english-us-state-predicate-to-russian-shtat translation rule is
removed; targetLabelFor now prefers the interlingua concept form. The Rust
core, its curated reference, and the committed WASM build are flipped to
Q35657 for JS↔Rust parity (rule_count 3→2; Q7275 retained as a documented
generic reference).

How to reproduce / verify

node examples/copula-type-resolution.js

Output (fully offline):

Sentence: "Hawaii is a state."
  "state" resolved to: Q35657 (U.S. state)
  Wikipedia: https://en.wikipedia.org/wiki/U.S._state
  English -> Russian: Гавайи это штат.
  transformations: english-article-omission, english-copula-to-russian-eto

Architecture

  • js/src/copula-types.jsresolveCopulaTypes pass (dependency-injected to avoid a circular import).
  • js/src/wikidata-entity-context.js — shared Wikidata-entity helpers used by both formalize.js and the new pass; also keeps formalize.js within the 1500-line budget.

Tests

  • New offline example examples/copula-type-resolution.js exercises the full path.
  • Updated JS integration/e2e tests (issue-16, -35, -37, -56, -61-wasm, -74) and Rust tests (issue35_translation, semantic_relations) assert the Q35657 outcome.
  • Full suite green locally: JS unit 63 / integration 295 / e2e 82, cargo 70, and npm run check (lint, format, duplication, docs, parity, cache) all pass.

Docs

  • docs/REQUIREMENTS.md and the issue-128 / issue-35 case studies updated (R12, RC7, solution plan, timeline, README).
  • Changeset: .changeset/issue-128-copula-type-resolution.md (meta-expression: minor).

Closes #128.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #128
@konard konard self-assigned this May 29, 2026
Promote the predicate noun in an 'X is a Y' copula to the subject's
asserted instance-of / subclass-of type at formalization time, language-
neutrally. 'Hawaii is a state.' now resolves 'state' to Q35657 (U.S.
state, ru: Штат США) instead of the generic federated-state concept
Q7275, so no per-language translation rule is needed.

- Add js/src/copula-types.js (resolveCopulaTypes pass, dependency-injected)
- Add js/src/wikidata-entity-context.js shared by formalize.js and the
  new pass; keeps formalize.js within the 1500-line budget
- Remove the bespoke english-us-state-predicate-to-russian-shtat rule
  from translate.js; targetLabelFor prefers the interlingua concept form
- Flip 'state'/'штат' to Q35657 in the Rust core, its curated reference,
  and the committed WASM build for JS<->Rust parity
- Update issue-128/issue-35 case studies, docs/REQUIREMENTS.md, the
  affected JS/Rust tests, add an offline example and a changeset
@konard konard changed the title [WIP] Issue on Translate page: Hawaii is a state. Resolve copula predicate to subject's licensed type (issue #128 R12) May 29, 2026
@konard konard marked this pull request as ready for review May 29, 2026 22:13
@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 29, 2026

Working session summary

Everything is complete and green. Final summary:

Done — Issue #128 R12 fully addressed in PR #130

The deep fix: "Hawaii is a state." now resolves the predicate "state" to its most-correct contextual sense — Q35657 U.S. state (Russian Штат США) — instead of the generic federated-state concept Q7275, language-neutrally and without any per-language translation rule.

How it works: a new formalization pass promotes the copula predicate to the subject's asserted type (Hawaii instance of Q35657) when their head words agree. The same logic resolves "Гавайи это штат" identically, so the bespoke english-us-state-predicate-to-russian-shtat rule was removed.

Architecture changes:

  • js/src/copula-types.js — the dependency-injected resolveCopulaTypes pass.
  • js/src/wikidata-entity-context.js — shared Wikidata-entity helpers used by both formalize.js and the new pass (also brought formalize.js from 1711 → 1463 lines, under the 1500-line budget).
  • Rust core / curated reference / committed WASM flipped to Q35657 for JS↔Rust parity.

Verification (all green):

  • npm run check — lint, format, duplication, docs, parity, cache ✓
  • JS tests: unit 63, integration 295, e2e 82, 0 failures ✓
  • cargo test: 70 passed ✓
  • Offline example examples/copula-type-resolution.js prints the expected Q35657 / U.S._state / "Гавайи это штат." output ✓
  • CI on commit 8269caa: Broken Link Checker, JS Checks, Rust Checks — all success

Docs: docs/REQUIREMENTS.md, issue-128 case study (R12, RC7, plan, timeline, README), issue-35 supersession notes, and changeset .changeset/issue-128-copula-type-resolution.md (meta-expression: minor).

PR #130 is updated, marked ready for review (no longer draft), working tree clean: #130


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 29, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $24.015280

📊 Context and tokens usage:

Claude Opus 4.8: (6 sub-sessions)

  1. 116.7K / 1M (12%) input tokens, 30.0K / 128K (23%) output tokens
  2. 113.5K / 1M (11%) input tokens, 40.5K / 128K (32%) output tokens
  3. 111.4K / 1M (11%) input tokens, 39.8K / 128K (31%) output tokens
  4. 117.0K / 1M (12%) input tokens, 36.9K / 128K (29%) output tokens
  5. 116.5K / 1M (12%) input tokens, 33.8K / 128K (26%) output tokens
  6. 78.9K / 1M (8%) input tokens, 21.5K / 128K (17%) output tokens

Total: (45.2K new + 617.9K cache writes + 27.1M cache reads) input tokens, 242.7K output tokens, $23.729123 cost

Claude Haiku 4.5:

  • 96.4K / 200K (48%) input tokens, 7.6K / 64K (12%) output tokens

Total: (2.8K new + 93.7K cache writes + 1.3M cache reads) input tokens, 7.6K output tokens, $0.286157 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.8 (claude-opus-4-8)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (11626KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 353473c into main May 29, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue on Translate page: Hawaii is a state.

1 participant