diff --git a/README.md b/README.md
index 3220c59..295888b 100644
--- a/README.md
+++ b/README.md
@@ -18,8 +18,9 @@ The whole project is published to GitHub Pages as a single unified single-page a
| [Entities](https://link-assistant.github.io/human-language/app.html#mode=entity) | Browse any Wikidata Q-id, with IPA toggle and an inline test runner. | [`js/src/app/modes/entity.jsx`](js/src/app/modes/entity.jsx) |
| [Properties](https://link-assistant.github.io/human-language/app.html#mode=property) | Same lens as Entities but for P-ids. | [`js/src/app/modes/property.jsx`](js/src/app/modes/property.jsx) |
| [Text → Q/P Transformer](https://link-assistant.github.io/human-language/app.html#mode=transformer) | Turn English text into a sequence of Wikidata entities (Q) and properties (P), with n-gram support. | [`js/src/app/modes/transformer.jsx`](js/src/app/modes/transformer.jsx) |
+| [Q/P → Text Generation](https://link-assistant.github.io/human-language/app.html#mode=generation) | The reverse direction: render a typed constructor (subject · predicate · object, or a subject · value · unit measurement, with negation, tense, Romance gender agreement and Russian prepositional case) into sentences across the six official UN languages. | [`js/src/app/modes/generation.jsx`](js/src/app/modes/generation.jsx) |
-The legacy URLs (`entities.html`, `properties.html`, `transformation/index.html`, and bare hashes like `entities.html#Q35120`) still work — they now redirect into the unified SPA preserving any parameters.
+The legacy URLs (`entities.html`, `properties.html`, `transformation/index.html`, `generation/index.html`, and bare hashes like `entities.html#Q35120`) still work — they now redirect into the unified SPA preserving any parameters.
### Internal pages (for contributors)
@@ -62,28 +63,36 @@ This project will fundamentally transform how we store, access, and verify human
- **Real-time transformation**: Interactive web demo at `transformation/index.html`
- [Learn more →](transformation/README.md)
-### 2. Entity & Property Viewer
+### 2. Q/P-to-Text Generation (reverse renderer)
+- **Closes the round-trip**: the reverse of the transformer — typed meaning → natural-language text
+- **Abstract-Wikipedia-style constructors**: typed containers (`instance_of`, `located_in`, `relation`, `quantity`) with named roles — including a `quantity` measurement constructor (`subject` · `value` · `unit`) mirroring a Wikidata quantity claim
+- **Multi-language rendering**: one templatic renderer per constructor-per-language across the six official UN languages (en, ar, es, fr, ru, zh)
+- **Grammatical features**: negation, tense, English `a`/`an` indefinite-article phonotactics, Romance gender agreement (es `un`/`una`, fr `un`/`une`), and Russian prepositional-case inflection for the locative object (Германия → Германии)
+- **Offline-friendly**: role values may be Wikidata ids (resolved to labels) or plain text (rendered verbatim, no network)
+- Interactive web demo at `app.html#mode=generation`; library entry point [`human-language/generate`](js/src/generation/qp-to-text.js)
+
+### 3. Entity & Property Viewer
- **Beautiful UI**: Modern, responsive interface with dark/light themes
- **Multi-language support**: Automatic language detection and switching
- **Rich statements display**: View all properties and relationships
- **Direct Wikidata links**: Seamlessly navigate to source data
- View entities at `entities.html` and properties at `properties.html`
-### 3. Advanced Search & Disambiguation
+### 4. Advanced Search & Disambiguation
- **Exact & fuzzy matching**: Find entities even with typos
- **Context-aware ranking**: Domain and type preferences
- **Batch searching**: Efficient parallel searches
- **Multi-language search**: Search in any supported language
- [API Documentation →](SEARCH_README.md)
-### 4. Intelligent Caching System
+### 5. Intelligent Caching System
- **Multi-tier caching**: File system (Node.js) and IndexedDB (browser)
- **Automatic fallback**: Seamless switching between cache types
- **Performance optimized**: Reduces API calls and improves response times
- **Cross-platform**: Works in both Node.js and browser environments
- **Persistent storage**: Cached data survives across sessions
-### 5. Comprehensive Language Support
+### 6. Comprehensive Language Support
- **100+ languages**: Full support for all major Wikidata languages
- **Locale-specific quotes**: Proper quotation marks for each language
- **Flag emojis**: Visual language indicators for better UX
@@ -179,18 +188,25 @@ Based on our [GitHub issues](https://github.com/link-assistant/human-language/is
- N-gram generation and matching
- Parallel search execution
- Priority-based result merging
+ - Typed-constructor output (`transformToConstructor`) with negation, tense, question (`detectQuestion`) and quantity (`extractQuantities`) detection, plus adjacent-duplicate collapsing (`dedupeSequence`)
+
+3. **Q/P → Text Renderer** (`js/src/generation/qp-to-text.js`, `js/src/generation/constructors.js`)
+ - Typed constructors with named roles (Abstract-Wikipedia-style), including a `quantity` measurement constructor
+ - One templatic renderer per constructor-per-language across the UN 6 languages
+ - Negation, tense, English `a`/`an` phonotactics, Romance gender agreement (`un`/`una`, `un`/`une`) and Russian prepositional-case inflection on the locative object (`russianPrepositional`)
+ - Batch label resolution via the Wikidata client (`getLabels`), pluggable for offline use
-3. **Search Utilities** (`js/src/wikidata-api.js`)
+4. **Search Utilities** (`js/src/wikidata-api.js`)
- Exact and fuzzy search algorithms
- Context-aware ranking system
- Multi-language support
-4. **Caching System** (`js/src/unified-cache.js`)
+5. **Caching System** (`js/src/unified-cache.js`)
- Factory pattern for cache creation
- File system cache for Node.js
- IndexedDB cache for browsers
-5. **UI Components** (`js/src/statements.jsx`, `js/src/loading.jsx`)
+6. **UI Components** (`js/src/statements.jsx`, `js/src/loading.jsx`)
- React 19 components with JSX
- No build step required (Babel in-browser)
- Responsive and theme-aware design
@@ -259,6 +275,7 @@ See the [🎬 Demos](#-demos) section above for the full table — every demo is
- **Entity Viewer** — [`entities.html`](https://link-assistant.github.io/human-language/entities.html)
- **Property Viewer** — [`properties.html`](https://link-assistant.github.io/human-language/properties.html)
- **Text Transformer** — [`transformation/index.html`](https://link-assistant.github.io/human-language/transformation/index.html)
+- **Q/P → Text Generation** — [`app.html#mode=generation`](https://link-assistant.github.io/human-language/app.html#mode=generation)
- **N-gram Test** — [`transformation/test-ngram.html`](https://link-assistant.github.io/human-language/transformation/test-ngram.html)
- **Search Demo** — [`search-demo.html`](https://link-assistant.github.io/human-language/search-demo.html)
- **Caching Demo** — [`cache-demo.html`](https://link-assistant.github.io/human-language/cache-demo.html)
@@ -269,9 +286,9 @@ See the [🎬 Demos](#-demos) section above for the full table — every demo is
The text transformation system currently has some limitations:
-1. **Negation handling**: Phrases with "not" aren't properly processed
+1. **Negation handling**: The raw Q/P sequence does not encode negation — but `transformToConstructor` now detects it and the generation renderer expresses it ("X is not a Y")
2. **Question parsing**: Direct questions (who, what, when) aren't supported
-3. **Verb tenses**: Past/future tenses may not be accurately captured
+3. **Verb tenses**: The raw sequence drops tense — `transformToConstructor` detects past/present/future and the renderer inflects the copula where grammatical (e.g. English "X was a Y", "X will be a Y", and the Spanish/French/Russian/Arabic equivalents). Languages that need noun-case morphology for a given tense (e.g. Russian/Arabic *instance_of* past) fall back to the present form, pending the Wikidata Lexeme integration tracked in `research/`
4. **Pronoun resolution**: Cannot resolve pronouns like "he", "she", "it"
5. **Complex sentences**: Struggles with subordinate clauses
diff --git a/app.html b/app.html
index 05f6ede..0d2383a 100644
--- a/app.html
+++ b/app.html
@@ -40,6 +40,9 @@
import * as ipa from './js/src/app/ipa.js';
import { TextToQPTransformer } from './js/src/transformation/text-to-qp-transformer.js';
import { TextTransformerTest, demonstrateTransformer } from './js/src/transformation/text-transformer-test.js';
+ import { QPRenderer } from './js/src/generation/qp-to-text.js';
+ import { CONSTRUCTORS, UN6_LANGUAGES, LANGUAGE_NAMES, buildConstructor, validateConstructor }
+ from './js/src/generation/constructors.js';
// Shared globals expected by the unified shell and legacy components
// (statements.jsx, loading.jsx) that we re-mount inside the SPA.
@@ -70,6 +73,12 @@
TextToQPTransformer,
TextTransformerTest,
demonstrateTransformer,
+ QPRenderer,
+ CONSTRUCTORS,
+ UN6_LANGUAGES,
+ LANGUAGE_NAMES,
+ buildConstructor,
+ validateConstructor,
modes: {},
};
@@ -88,6 +97,7 @@
+