Learn from Abstract Wikipedia: implement Q/P → text generation service#19
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #18
- Research Abstract Wikipedia's technical approach and development challenges - Identify key lessons for human-language project including modular architecture, lexicographic integration, and context-aware transformation - Provide specific implementation recommendations for enhanced n-gram processing, semantic validation, and multi-language generation - Document risk mitigation strategies and performance optimization patterns - Create actionable roadmap based on Abstract Wikipedia's successes and pitfalls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Get latest fresh data about Abstract Wikipedia research, and improve quality of all our services, and also point to missing features we can also support. |
|
🤖 AI Work Session Started Starting automated work session at 2026-06-09T22:54:47.259Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
… analysis - Update abstract-wikipedia-analysis.md with current (June 2026) status: Wikifunctions metrics, 2025 NLG semantic fragments, NLG SIG, published roadmap (late-2025 sentence functions, 2026 soft launch), the 6-stage NLG architecture, Ninai/Udiron, and the Google.org risk evaluation. Added Sources. - Add missing-features-and-improvements.md: feature-gap map (reverse Q/P->text generation, lexeme integration, typed constructors, UD parsing, multi-language rendering) and concrete per-service quality improvements grounded in repo files.
|
Addressed the feedback ("get latest fresh data… improve quality of all our services… point to missing features we can also support"): Fresh research (June 2026) added to Missing features + service quality in new
Commit: e13c141 |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $1.290519📊 Context and tokens usage:Claude Opus 4.8:
Total: (2.6K new + 71.1K cache writes + 678.2K cache reads) input tokens, 14.3K output tokens, $1.154360 cost Claude Haiku 4.5:
Total: 91.8K input tokens, 2.9K output tokens, $0.136159 cost 🤖 Models used:
📎 Log file uploaded as Gist (770KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
|
Get latest changes from default branch, and implement everything in the established style our other features have. Please plan and execute everything in this single pull request, you have unlimited time and context, as context auto-compacts and you can continue indefinitely, until it is each and every requirement fully addressed, and everything is totally done. |
|
🤖 AI Work Session Started Starting automated work session at 2026-06-10T00:01:53.088Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
Batch label resolution (getLabels) feeds the new generation renderer; searchLexemes adds Wikidata Lexeme lookup (Abstract-Wikipedia gap #2). Mirrored in both the Node and browser clients.
Typed constructors with named roles + one templatic renderer per constructor-per-language across the six official UN languages, plus English a/an phonotactics and negation. Pure, offline-testable data layer (constructors.js) with a thin orchestration renderer (QPRenderer).
transformToConstructor folds the flat Q/P sequence into a typed constructor and extracts negation/tense modifiers, enabling the text -> Q/P -> text round-trip.
Wires the new QPRenderer into the unified SPA as a 'generation' mode (routing + shell tab + app.html module exposure), adds the generation/index.html legacy redirect shell, and a landing-page card.
Adds ./generate and ./generate/constructors subpath exports, re-exports QPRenderer and the constructor helpers from index.js, declares them in index.d.ts (plus getLabels/searchLexemes), and bumps the version to trigger the release workflow.
…d pre-deploy 404)
Working session summaryAll work is complete. Here's a summary of what was accomplished on PR #19 (branch What shippedIssue #18 ("Learn from Abstract Wikipedia development") is now addressed in both halves — the research and a working implementation of the highest-leverage missing capability it identified: reverse generation (Q/P → text). New: Generation service (Q/P → text)
Service-quality improvements
Established-style wiring
Verification
One CI iteration was needed — the first run's only failure was the not-yet-deployed This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $8.843501📊 Context and tokens usage:Claude Opus 4.8: (2 sub-sessions)
Total: (14.4K new + 265.6K cache writes + 10.0M cache reads) input tokens, 83.5K output tokens, $8.843502 cost 🤖 Models used:
📎 Log file uploaded as Gist (4006KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
🤖 AI Work Session Started Starting automated work session at 2026-06-10T00:28:34.481Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
The renderer extracted and exposed tense (transformer modifier, UI selector, Constructor.tense type) but silently dropped it: 'Caesar was a general' round-tripped to the present 'Caesar is a general'. Add past/future template variants that inflect the verb only — copula tense for en/es/fr instance_of, and the locative verb for en/es/fr/ru/ar located_in — where it stays grammatical without noun-case morphology. Languages that would need morphology (ru/ar instance_of past) fall back to the present form; Chinese copulas (是/在) do not inflect, so present is already correct for every tense. Also sync package-lock.json to 0.2.0 (was left at 0.1.0 by the version bump). Adds tense unit + round-trip tests; present-tense output is unchanged.
Exercise QPRenderer.render's non-labelProvider branch with an injected mock client, asserting only id-shaped roles are looked up and plain-text roles skip the network entirely.
🔎 Double-check pass — closed the one half-implemented gapReviewed every claimed capability against its implementation and test coverage. Everything held up except one real gap, now fixed: Tense was extracted + exposed but silently dropped in rendering
Fix (
Present-tense output is byte-for-byte unchanged, so nothing regressed. Tests
Other findings
All gating CI green on |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $3.427067📊 Context and tokens usage:
Total: (3.3K new + 91.5K cache writes + 4.1M cache reads) input tokens, 31.1K output tokens, $3.427067 cost 🤖 Models used:
📎 Log file uploaded as Gist (1780KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
|
Double check again, and implement unimplemented or delayed, make sure we support all test cases abstract wikipedia project has. And also expand on our use cases and features, to make sure we support highest possible quality of everything. If you see clearly wrong tests (in the entire codebase), that can be improved - do it. |
|
🤖 AI Work Session Started Starting automated work session at 2026-06-10T09:26:39.975Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
The Romance instance_of templates hardcoded masculine 'un', producing the
ungrammatical 'Berlín es un ciudad' / 'Berlin est un ville' (ciudad/ville are
feminine). Add a romanceIndefiniteArticle(lang, gender) helper and a 'gender'
constructor modifier; generalize fillTemplate's {article} handling to es/fr
(un/una, un/une) with a documented masculine fallback (pending Wikidata
Lexeme P5185 integration). Correct the ungrammatical assertions and add
direct coverage for the helper and gender agreement.
…tition
The flat Q/P list silently dropped three of the documented limitations in
limitations-found.json. Capture them structurally the way negation/tense are
already kept:
- detectQuestion(text) classifies wh-/polar questions (who->entity,
when->time, 'how many'->quantity, …) instead of treating them as statements.
- extractQuantities(text) preserves numbers + units ('8848 meters',
'299792458 meters per second') as { value, unit } pairs rather than losing
them to entity search.
- dedupeSequence() collapses adjacent duplicate ids ('Paris Paris France
France' -> 'Q90 Q142'); wired into transform() via a default-on dedupe
option.
transformToConstructor now surfaces question + quantities alongside the
constructor. Adds offline unit coverage and TypeScript declarations.
A new 'quantity' constructor { subject, value, unit } renders a measurement
in all six UN languages (en 'X is N unit', es 'mide', fr 'mesure', ru/zh/ar
copula), mirroring a Wikidata quantity claim. toConstructor() now emits it
whenever extractQuantities() finds a number with a unit, so 'Mount Everest is
8848 meters tall' round-trips instead of losing its value. Adds offline
render/validation/round-trip tests.
limitation-test.mjs now drives the structured transformToConstructor() pipeline and scores negation, questions, numerical quantities and repetition against the fields that actually carry that signal (modifiers.negated, question.isQuestion, quantities[].unit / quantity constructor, deduped sequence). The eight previously-flagged logic gaps are gone; the four remaining are genuine knowledge-base/data limits (Turkey disambiguation, ChatGPT/TikTok coverage, non-Latin script) rather than transformer defects. Regenerates limitations-found.json.
…neration mode The Generation SPA mode is now role-aware: it reads each constructor's roles from CONSTRUCTORS instead of hard-coding subject/predicate/object, so the new 'quantity' constructor surfaces Value + Unit inputs, and an 'Object gender' selector appears whenever a template uses the Romance indefinite article (es un/una, fr un/une). Adds gender + quantity examples and demo runners, and an offline e2e test for the measurement path.
…-gap closures Updates README (feature list, mode table, architecture bullets) and the issue-18 case study (concepts, requirements R11/R15-R20, architecture.md diagram + constructor/bridge sections) to reflect the new quantity constructor, Romance gender agreement, and the question/quantity/dedupe detection now on transformToConstructor.
✅ Follow-up round completeAddressed the latest request ("implement unimplemented or delayed, support all test cases Abstract Wikipedia has, expand features, fix clearly-wrong tests") in this same PR: New grammatical feature — Romance gender agreement
New constructor —
Closed the documented analysis gaps on Limitation harness now reflects reality — UI — Generation mode is role-aware: Tests — Requirements R15–R20 in |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $10.184543📊 Context and tokens usage:Claude Opus 4.8: (3 sub-sessions)
Total: (22.0K new + 292.0K cache writes + 12.0M cache reads) input tokens, 90.3K output tokens, $10.184543 cost 🤖 Models used:
📎 Log file uploaded as Gist (5211KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
|
Make sure our roadmap, vision and all requirements listed in the repository are fully and correctly implemented. Double check tests for obviously wrong cases and fix them also. Please plan and execute everything in this single pull request, you have unlimited time and context, as context auto-compacts and you can continue indefinitely, until it is each and every requirement fully addressed, and everything is totally done. |
|
🤖 AI Work Session Started Starting automated work session at 2026-06-10T23:35:25.710Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
…tional case The ru located_in template emitted the nominative Wikidata label after «в» («Берлин находится в Германия»), which is ungrammatical — «в» governs the prepositional case. Add a guarded russianPrepositional helper wired via a per-role inflect map, correct the test that blessed the nominative form, and document the third grammatical-feature seed.
Working session summaryCI is green on the latest commit ( DoneThe standing request — verify all requirements are correctly implemented and fix obviously-wrong test cases — is complete for this session. The one genuinely obviously-wrong case was the Russian locative output. The fix (commit
Verification:
The documented round-trip examples were checked against live code output and match exactly. This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $5.436513📊 Context and tokens usage:Claude Opus 4.8: (2 sub-sessions)
Total: (11.1K new + 218.6K cache writes + 5.3M cache reads) input tokens, 41.2K output tokens, $5.113437 cost Claude Haiku 4.5:
Total: (100 new + 72.6K cache writes + 2.0M cache reads) input tokens, 7.2K output tokens, $0.323076 cost 🤖 Models used:
📎 Log file uploaded as Gist (3516KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
Issue #18 asked us to learn from Abstract Wikipedia. This PR does both halves:
research/).text → Q/P → textround-trip the README vision depends on.Everything follows the project's established style (pure data layer, injectable renderer, offline-first tests, package exports, hand-written types, a unified-SPA mode, a legacy redirect shell, and e2e coverage).
What shipped
New: Generation service (Q/P → text)
js/src/generation/constructors.js— typed constructors with named roles (instance_of,located_in,relation) and one templatic renderer per constructor-per-language across the six official UN languages (en, ar, es, fr, ru, zh). Includes Englisha/anphonotactics, negation patterns, andvalidateConstructor/buildConstructor/fillTemplate. Pure and dependency-free.js/src/generation/qp-to-text.js—QPRendererwithrenderWithLabels(pure),render(resolves id-shaped roles via labels), andrenderAll(UN 6). Label resolution is pluggable (labelProviderfor offline use, or a lazily-constructed Wikidata client — browser vs Node, like the transformer).Service-quality improvements (per the research)
getLabels(ids, lang)— batch label resolution, andsearchLexemes(term, lang)— Wikidata Lexeme lookup, added to both the Node and browser API clients.transformToConstructor(text)on the transformer — folds the flat Q/P sequence into a typed, role-labelled constructor and extracts negation and tense (present/past/future, incl. irregular pasts), addressing two documented limitations.UI + packaging
app.html#mode=generation) wired into routing, the shell tab bar, andapp.html; plus ageneration/index.htmlredirect shell and a landing-page card../generateand./generate/constructorssubpath exports,index.jsre-exports,index.d.tsdeclarations. Version bumped0.1.0→0.2.0.How to reproduce / verify
Round-trip via the transformer:
transformToConstructor('Berlin is a city')→{ type:'instance_of', subject, object }→renderAll→ the table above.Tests
js/tests/unit/qp-to-text.test.mjs— 19 offline unit tests (phonotactics, validation,fillTemplate, multi-language render incl. negation/located_in/relation, asyncrender/renderAll, transformerextractModifiers/toConstructor, and atext → Q/P → textround-trip). Added to the gatingFAST_SUITES.js/tests/e2e/app.spec.mjs— Generation mode boots, the Generate button enables, and the default constructor renders across the UN 6 offline. Mode-count assertions updated (six → seven).Docs
docs/case-studies/issue-18/— README, requirements, and architecture.research/missing-features-and-improvements.md— gap table updated with the now-closed items.README.md+index.html— Generation feature, demo, and architecture entries.Files Changed
js/src/generation/{constructors,qp-to-text}.js— new generation service.js/src/wikidata-api.js,js/src/wikidata-api-browser.js—getLabels+searchLexemes.js/src/transformation/text-to-qp-transformer.js— typed-constructor output.js/src/app/modes/generation.jsx,js/src/app/routing.js,js/src/app/shell.jsx,app.html,generation/index.html,index.html— SPA mode + redirect + landing.js/src/index.js,js/src/index.d.ts,package.json— exports, types, version.js/tests/unit/qp-to-text.test.mjs,js/tests/e2e/app.spec.mjs,js/tests/unit/routing.test.mjs,js/scripts/run-unit-tests.mjs— tests.docs/case-studies/issue-18/*,research/*— research + case study.🤖 Generated with Claude Code
Resolves #18
Follow-up round: support all Abstract-Wikipedia test cases, expand features, fix wrong tests
Acting on the latest binding PR comment ("Double check again, and implement unimplemented or delayed, make sure we support all test cases … expand on our use cases and features … If you see clearly wrong tests … do it."):
New grammatical feature — Romance gender agreement
romanceIndefiniteArticle(lang, gender)agrees the Spanish/French indefinite article (un/una,un/une) with the object noun's grammatical gender (the constructor'sgender, ultimately a Wikidata Lexeme P5185 statement), defaulting to masculine. Theinstance_ofes/fr templates now use the agreeing{article}token.una/unewere missing). Corrected toBerlín es una ciudad,Berlin est une ville, etc.New constructor —
quantity(measurement)quantityconstructor (subject·value·unit) renders a measurement across all six UN languages (en is, es mide, fr mesure, ru/zh/ar copula) — the direct analogue of a Wikidata quantity claim (e.g. P2048 height).toConstructornow emits it whenever a number-with-unit is present, soMount Everest is 8848 meters tallround-trips instead of losing its value.Closed the documented analysis gaps
transformToConstructornow also:detectQuestion(text)— classifies wh-questions (who→entity,what→thing,when→time,where→place,why→reason,how→manner,how many/much→quantity) and polar questions.extractQuantities(text)— pulls out{ value, unit }pairs.dedupeSequence(sequence)— collapses adjacent duplicate ids (never merging ambiguous), on by default intransform.Limitation harness reflects reality
js/scripts/limitation-test.mjsnow drives the structuredtransformToConstructorpipeline and scores against the fields that actually carry the signal. Documented problems dropped 12 → 4; the remaining four are genuine knowledge-base/data limits (Turkey disambiguation, ChatGPT/TikTok coverage, non-Latin script), not transformer logic.limitations-found.jsonregenerated.UI
The Generation SPA mode is now role-aware: it reads each constructor's roles from
CONSTRUCTORS, so thequantityconstructor surfaces Value + Unit inputs and an Object gender selector appears for templates that use the Romance article. Added gender + quantity examples, demo runners, and an offline e2e test for the measurement path.Tests
js/tests/unit/qp-to-text.test.mjsis now 36 offline tests (gender agreement,romanceIndefiniteArticle,detectQuestion,extractQuantities,dedupeSequence, quantity render across UN 6 + negation, quantity validation/toConstructor, and a measurement round-trip). All gating suites pass.