@polycode-projects/the-mechanical-code-talker 5.0.23 → 5.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -931,6 +931,54 @@
|
|
|
931
931
|
{"subject":"guest sprite","predicate":"mgx:offer-variant","object":"half-right"}
|
|
932
932
|
{"subject":"guest sprite","predicate":"mgx:offer-variant","object":"left"}
|
|
933
933
|
{"subject":"guest sprite","predicate":"mgx:offer-variant","object":"right"}
|
|
934
|
+
{"subject":"butler sprite","predicate":"mgx:take-parameter","object":"emotion"}
|
|
935
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"happy"}
|
|
936
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"sad"}
|
|
937
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"angry"}
|
|
938
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"scared"}
|
|
939
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"surprised"}
|
|
940
|
+
{"subject":"butler sprite","predicate":"mgx:accept-emotion","object":"calm"}
|
|
941
|
+
{"subject":"cook sprite","predicate":"mgx:take-parameter","object":"emotion"}
|
|
942
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"happy"}
|
|
943
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"sad"}
|
|
944
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"angry"}
|
|
945
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"scared"}
|
|
946
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"surprised"}
|
|
947
|
+
{"subject":"cook sprite","predicate":"mgx:accept-emotion","object":"calm"}
|
|
948
|
+
{"subject":"gardener sprite","predicate":"mgx:take-parameter","object":"emotion"}
|
|
949
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"happy"}
|
|
950
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"sad"}
|
|
951
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"angry"}
|
|
952
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"scared"}
|
|
953
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"surprised"}
|
|
954
|
+
{"subject":"gardener sprite","predicate":"mgx:accept-emotion","object":"calm"}
|
|
955
|
+
{"subject":"housekeeper sprite","predicate":"mgx:take-parameter","object":"emotion"}
|
|
956
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"happy"}
|
|
957
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"sad"}
|
|
958
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"angry"}
|
|
959
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"scared"}
|
|
960
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"surprised"}
|
|
961
|
+
{"subject":"housekeeper sprite","predicate":"mgx:accept-emotion","object":"calm"}
|
|
962
|
+
{"subject":"butler sprite","predicate":"mgx:offer-variant","object":"half-left"}
|
|
963
|
+
{"subject":"cook sprite","predicate":"mgx:offer-variant","object":"half-left"}
|
|
964
|
+
{"subject":"gardener sprite","predicate":"mgx:offer-variant","object":"half-left"}
|
|
965
|
+
{"subject":"housekeeper sprite","predicate":"mgx:offer-variant","object":"half-left"}
|
|
966
|
+
{"subject":"butler sprite","predicate":"mgx:offer-variant","object":"moving"}
|
|
967
|
+
{"subject":"cook sprite","predicate":"mgx:offer-variant","object":"moving"}
|
|
968
|
+
{"subject":"gardener sprite","predicate":"mgx:offer-variant","object":"moving"}
|
|
969
|
+
{"subject":"housekeeper sprite","predicate":"mgx:offer-variant","object":"moving"}
|
|
970
|
+
{"subject":"butler sprite","predicate":"mgx:offer-variant","object":"half-right"}
|
|
971
|
+
{"subject":"cook sprite","predicate":"mgx:offer-variant","object":"half-right"}
|
|
972
|
+
{"subject":"gardener sprite","predicate":"mgx:offer-variant","object":"half-right"}
|
|
973
|
+
{"subject":"housekeeper sprite","predicate":"mgx:offer-variant","object":"half-right"}
|
|
974
|
+
{"subject":"butler sprite","predicate":"mgx:offer-variant","object":"left"}
|
|
975
|
+
{"subject":"cook sprite","predicate":"mgx:offer-variant","object":"left"}
|
|
976
|
+
{"subject":"gardener sprite","predicate":"mgx:offer-variant","object":"left"}
|
|
977
|
+
{"subject":"housekeeper sprite","predicate":"mgx:offer-variant","object":"left"}
|
|
978
|
+
{"subject":"butler sprite","predicate":"mgx:offer-variant","object":"right"}
|
|
979
|
+
{"subject":"cook sprite","predicate":"mgx:offer-variant","object":"right"}
|
|
980
|
+
{"subject":"gardener sprite","predicate":"mgx:offer-variant","object":"right"}
|
|
981
|
+
{"subject":"housekeeper sprite","predicate":"mgx:offer-variant","object":"right"}
|
|
934
982
|
{"subject":"horse sprite","predicate":"mgx:take-parameter","object":"emotion"}
|
|
935
983
|
{"subject":"horse sprite","predicate":"mgx:accept-emotion","object":"happy"}
|
|
936
984
|
{"subject":"horse sprite","predicate":"mgx:accept-emotion","object":"sad"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polycode-projects/the-mechanical-code-talker",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Mechanical Code Talker (tmct) — a tolerant, offline, $0 chat surface that guides you toward precision queries about a software repository. ELIZA/PARRY-style but domain-obsessed with code. No model calls; indexes a repo on request (tmct index) or reads any producer's graph.",
|
|
@@ -159,8 +159,6 @@
|
|
|
159
159
|
"bench:receipts": "node scripts/bench-receipts.mjs",
|
|
160
160
|
"claims": "node scripts/claims/run-all.mjs",
|
|
161
161
|
"claim:prose-band": "node scripts/claims/claim-prose-band.mjs",
|
|
162
|
-
"claim:paraphrase": "node scripts/claims/claim-paraphrase.mjs",
|
|
163
|
-
"claim:definitions": "node scripts/claims/claim-definitions.mjs",
|
|
164
162
|
"claim:openbookqa": "node scripts/claims/claim-openbookqa.mjs",
|
|
165
163
|
"claim:planner": "node scripts/claims/claim-planner.mjs",
|
|
166
164
|
"roll": "node scripts/roll.mjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
// beyond this module's own exports, which is what keeps a raw `.toString()`
|
|
41
41
|
// splice safe.
|
|
42
42
|
//
|
|
43
|
-
//
|
|
43
|
+
// Five further pure helpers are exported for testing but NOT spliced,
|
|
44
44
|
// because each calls another module's export — the in-page script instead
|
|
45
45
|
// reaches through the browser bundle's own `tmct` surface (mirroring
|
|
46
46
|
// how the spider-fly page's inline script calls it rather than re-importing
|
|
@@ -52,12 +52,16 @@
|
|
|
52
52
|
// `pillsFor` mirrors it against `tmct.page.roomAffordances`),
|
|
53
53
|
// `goalStatusLines` (calls `foldWorldState` and adventure-autoplay.mjs's own
|
|
54
54
|
// `exposedFacts`; the in-page `goalStatusLinesFor` mirrors both against the
|
|
55
|
-
// `tmct` surface too),
|
|
55
|
+
// `tmct` surface too), `visitedRoomGraph` (a directions-only
|
|
56
56
|
// layout of the rooms a session has actually visited, now a thin wrapper over
|
|
57
57
|
// viz-room-graph.mjs's shared `directedGridLayout` — mud-viz.mjs's own
|
|
58
58
|
// burrowGraph wrote the same BFS-grid layout a second time under its own
|
|
59
59
|
// name, and that shared module is where the layout lives now; see its own
|
|
60
|
-
// header for the algorithm and what `hints`/disconnected components mean)
|
|
60
|
+
// header for the algorithm and what `hints`/disconnected components mean),
|
|
61
|
+
// and `roomWalkerPropertyFacts` (calls sprite-animation.mjs's own
|
|
62
|
+
// `oscillateWalkStep`; the in-page `walkerFactsFor` mirrors it against
|
|
63
|
+
// `tmct.page.spriteAnimation.oscillateWalkStep` — see the room-sprite
|
|
64
|
+
// resolution section below for how its output reaches the resolver).
|
|
61
65
|
// The in-page script never splices `directedGridLayout`/`roomGraphSvg`
|
|
62
66
|
// either, for the same not-self-contained reason: it calls
|
|
63
67
|
// `tmct.page.directedGridLayout`/`tmct.page.roomGraphSvg` straight
|
|
@@ -93,13 +97,14 @@
|
|
|
93
97
|
// (adventure-browser-entry.mjs), never here — this module only renders and
|
|
94
98
|
// reads.
|
|
95
99
|
import { THEME_TOKENS_CSS, SERIF_STACK, MONO_STACK, escapeHtml, embedJson, embedScriptText, scenarioLabel, rowsForWorld, wordBeforeCursor, demoEyebrowHtml, EYEBROW_LINKS_CSS } from "./viz-theme.mjs";
|
|
96
|
-
import { createTicker, createSerialQueue } from "./viz-ticker.mjs";
|
|
100
|
+
import { createTicker, createSerialQueue, prefersReducedMotion } from "./viz-ticker.mjs";
|
|
97
101
|
import { directedGridLayout } from "./viz-room-graph.mjs";
|
|
98
102
|
import { worldDigestRows, roomAffordances, foldWorldState } from "./adventure.mjs";
|
|
99
103
|
import { exposedFacts } from "./adventure-autoplay.mjs";
|
|
100
104
|
import { relatedForTerm } from "../domain/skos-view.mjs";
|
|
101
105
|
import { classAncestorChain } from "../domain/sprite-map.mjs";
|
|
102
106
|
import { renderWorldEditorText } from "./adventure-editor.mjs";
|
|
107
|
+
import { oscillateWalkStep, SPRITE_POSE_MOVING } from "../domain/sprite-animation.mjs";
|
|
103
108
|
|
|
104
109
|
const DEFAULT_TITLE = "tmct — the adventure";
|
|
105
110
|
const PREVIEW_MAX_TICKS = 30;
|
|
@@ -165,6 +170,35 @@ export function factsForSubject(rows, subject) {
|
|
|
165
170
|
return (rows || []).filter((r) => r.subject === subject);
|
|
166
171
|
}
|
|
167
172
|
|
|
173
|
+
/** A stable animation-cycle offset for `subject` — the sum of its own
|
|
174
|
+
* character codes — so two members of staff sharing a room usually turn at
|
|
175
|
+
* different points of the SAME shared clock rather than in lockstep (a
|
|
176
|
+
* same-total coincidence between two particular names is possible, since
|
|
177
|
+
* the walk cycle only has 18 steps; harmless either way, as the two just
|
|
178
|
+
* read as turning together). Pure. */
|
|
179
|
+
function walkerPhase(subject) {
|
|
180
|
+
return [...String(subject || "")].reduce((sum, ch) => sum + ch.charCodeAt(0), 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The synthetic mgx:faces/mgx:pose property facts a room's own walking NPC
|
|
184
|
+
* `subject` renders with at animation `tick` — sprite-animation.mjs's own
|
|
185
|
+
* oscillateWalkStep read as the small `{predicate, object}` fact shape
|
|
186
|
+
* sprite-templates.mjs's resolver already matches a TAUGHT fact against, so
|
|
187
|
+
* household staff (butler/cook/gardener/housekeeper) cycle through the
|
|
188
|
+
* turntable art data/sprites-large/*.toml's own household-staff aliases
|
|
189
|
+
* carry, with nothing ever written to the store. `walkerPhase` offsets one
|
|
190
|
+
* NPC's own cycle from another's. Empty at the walk's own front-facing/
|
|
191
|
+
* at-rest instants (oscillateWalkStep's null facing, "static" pose) — the
|
|
192
|
+
* class's own resting template already draws that, so this never asks for a
|
|
193
|
+
* fact that changes nothing. Pure. */
|
|
194
|
+
export function roomWalkerPropertyFacts(subject, tick) {
|
|
195
|
+
const step = oscillateWalkStep(Number(tick) + walkerPhase(subject), {});
|
|
196
|
+
const facts = [];
|
|
197
|
+
if (step.facing) facts.push({ predicate: "mgx:faces", object: step.facing });
|
|
198
|
+
if (step.pose === SPRITE_POSE_MOVING) facts.push({ predicate: "mgx:pose", object: step.pose });
|
|
199
|
+
return facts;
|
|
200
|
+
}
|
|
201
|
+
|
|
168
202
|
/** The room a subject's placement resolves into, for VISIBILITY — a room
|
|
169
203
|
* resolves to itself; an object placed directly in a room resolves to that
|
|
170
204
|
* room; an object one containment hop inside an OPEN container resolves to
|
|
@@ -1119,6 +1153,7 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1119
1153
|
"use strict";
|
|
1120
1154
|
const createTicker = ${createTicker.toString()};
|
|
1121
1155
|
const createSerialQueue = ${createSerialQueue.toString()};
|
|
1156
|
+
const prefersReducedMotion = ${prefersReducedMotion.toString()};
|
|
1122
1157
|
const spriteClassForObject = ${spriteClassForObject.toString()};
|
|
1123
1158
|
const visibleRoomOf = ${visibleRoomOf.toString()};
|
|
1124
1159
|
const roomSceneObjects = ${roomSceneObjects.toString()};
|
|
@@ -1573,10 +1608,35 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1573
1608
|
// unknown character as a figure, and neither should ever draw a creature.
|
|
1574
1609
|
const ROOT_FALLBACK_BY_CLASS = { adventurer: "person", person: "person", room: "room" };
|
|
1575
1610
|
const rootFallbackFor = (cls) => ROOT_FALLBACK_BY_CLASS[cls] || "portable";
|
|
1611
|
+
|
|
1612
|
+
// ---- NPC idle turn — a synthetic mgx:faces/mgx:pose fact pair (never
|
|
1613
|
+
// written to the store) merged onto a person-classed room NPC's own
|
|
1614
|
+
// property facts, so household staff (butler/cook/gardener/housekeeper)
|
|
1615
|
+
// cycle through the turning/walking art data/sprites-large/*.toml's own
|
|
1616
|
+
// household-staff aliases carry, the same [match] resolver path a taught
|
|
1617
|
+
// fact would take. Mirrors the module's own exported, tested
|
|
1618
|
+
// roomWalkerPropertyFacts against the bundle's published
|
|
1619
|
+
// tmct.page.spriteAnimation.oscillateWalkStep (see this module's own
|
|
1620
|
+
// header for why the calling-another-module pieces are mirrored rather
|
|
1621
|
+
// than spliced). walkTick advances on its own clock below, separate from
|
|
1622
|
+
// the game ticker — this never touches the store or the persisted save.
|
|
1623
|
+
// Skipped entirely under prefers-reduced-motion, so a room with staff in
|
|
1624
|
+
// it looks exactly as it did before this feature shipped.
|
|
1625
|
+
const reducedMotion = prefersReducedMotion();
|
|
1626
|
+
let walkTick = 0;
|
|
1627
|
+
function walkerFactsFor(subject) {
|
|
1628
|
+
const phase = [...String(subject || "")].reduce((sum, ch) => sum + ch.charCodeAt(0), 0);
|
|
1629
|
+
const step = tmct.page.spriteAnimation.oscillateWalkStep(walkTick + phase, {});
|
|
1630
|
+
const facts = [];
|
|
1631
|
+
if (step.facing) facts.push({ predicate: "mgx:faces", object: step.facing });
|
|
1632
|
+
if (step.pose === "moving") facts.push({ predicate: "mgx:pose", object: step.pose });
|
|
1633
|
+
return facts;
|
|
1634
|
+
}
|
|
1576
1635
|
function resolveObjectSprite(rows, s) {
|
|
1577
1636
|
if (s.subject === "you") return tmct.page.resolveSpriteAsset("adventurer", [], [], activeSpriteTemplates, tmct.page.SPRITE_REGISTRY, { rootFallback: "person", instanceKey: "you" });
|
|
1637
|
+
const walkFacts = !reducedMotion && s.spriteClass === "person" ? walkerFactsFor(s.subject) : [];
|
|
1578
1638
|
return tmct.page.resolveSpriteAsset(
|
|
1579
|
-
s.subject, spriteAncestryRows(rows, s.subject), factsForSubject(rows, s.subject),
|
|
1639
|
+
s.subject, spriteAncestryRows(rows, s.subject), factsForSubject(rows, s.subject).concat(walkFacts),
|
|
1580
1640
|
activeSpriteTemplates, tmct.page.SPRITE_REGISTRY,
|
|
1581
1641
|
{ rootFallback: rootFallbackFor(s.spriteClass), instanceKey: s.subject },
|
|
1582
1642
|
);
|
|
@@ -1622,8 +1682,13 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1622
1682
|
runTurn("go " + btn.getAttribute("data-direction"));
|
|
1623
1683
|
});
|
|
1624
1684
|
|
|
1625
|
-
|
|
1626
|
-
|
|
1685
|
+
// The room's own sprite tiles (wall band, floor stacks, the player's own
|
|
1686
|
+
// slot) — factored out of redraw() so the NPC idle-turn clock below can
|
|
1687
|
+
// refresh JUST these tiles on its own faster/independent cadence, without
|
|
1688
|
+
// re-running the caption/pills/map/goal rebuilds redraw() also does, and
|
|
1689
|
+
// critically without re-triggering schedulePersistSave() on every walk
|
|
1690
|
+
// frame.
|
|
1691
|
+
function redrawRoomSprites(snap) {
|
|
1627
1692
|
const layout = roomSceneLayout(snap.rows, snap.state, snap.here);
|
|
1628
1693
|
wallRowEl.innerHTML = layout.wall.map((s) => spriteCardHtml(s.subject, s.spriteClass, resolveObjectSprite(snap.rows, s), s.subject)).join("");
|
|
1629
1694
|
floorRowEl.innerHTML = layout.floor.map((stack) => {
|
|
@@ -1634,6 +1699,11 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1634
1699
|
}).join("") + "</div>";
|
|
1635
1700
|
}).join("");
|
|
1636
1701
|
youSlotEl.innerHTML = spriteCardHtml("you", "adventurer", resolveObjectSprite(snap.rows, { subject: "you", spriteClass: "adventurer" }));
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
function redraw(snap) {
|
|
1705
|
+
lastSnapshot = snap;
|
|
1706
|
+
redrawRoomSprites(snap);
|
|
1637
1707
|
roomNameEl.textContent = "the " + snap.here;
|
|
1638
1708
|
roomFrameEl.setAttribute("data-room-kind", roomKindForRoom(snap.rows, snap.here));
|
|
1639
1709
|
roomKindIconEl.innerHTML = roomKindIconSvg(snap.rows, snap.here);
|
|
@@ -1852,6 +1922,18 @@ ${engineBundleJs ? `<script>\n${embedScriptText(engineBundleJs)}\n</script>` : `
|
|
|
1852
1922
|
if (scenarioSelectEl) scenarioSelectEl.disabled = false;
|
|
1853
1923
|
}
|
|
1854
1924
|
|
|
1925
|
+
// The NPC idle-turn clock — its own interval, separate from the game
|
|
1926
|
+
// ticker above (that one drives real turns and the persisted save; this
|
|
1927
|
+
// one only cycles which frame the room's own staff show). Paused rooms,
|
|
1928
|
+
// edit mode and an as-yet-unbooted session all just skip the redraw.
|
|
1929
|
+
if (!reducedMotion) {
|
|
1930
|
+
setInterval(() => {
|
|
1931
|
+
walkTick += 1;
|
|
1932
|
+
if (!lastSnapshot || document.body.classList.contains("editing")) return;
|
|
1933
|
+
redrawRoomSprites(lastSnapshot);
|
|
1934
|
+
}, ADVENTURE.tickWaitMs);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1855
1937
|
const ticker = createTicker({
|
|
1856
1938
|
onTick: () => withLock(async () => {
|
|
1857
1939
|
const result = await session.autoplayTick();
|
package/src/services/chat.mjs
CHANGED
|
@@ -4319,6 +4319,29 @@ const quantifiedHasObject = (m) => (/^all$/i.test(m[1])
|
|
|
4319
4319
|
* the single noun between the determiner and the verb; a two-token subject stays
|
|
4320
4320
|
* declined, like the preposition-pinned frame, because nothing names its head. */
|
|
4321
4321
|
const DETERMINER_HAS_TEACH_RE = /^(?:the|an?|my|your|our|their|his|her|its)\s+([\w'-]+)\s+(?:has|have|had)\s+(.+?)[.!?]*$/i;
|
|
4322
|
+
/** The quantified LOCATIVE teach ("every disk rests on peg-a", "each disk
|
|
4323
|
+
* rests on peg-a", "all disks rest on peg-a") — QUANTIFIED_HAS_TEACH_RE's own
|
|
4324
|
+
* sibling for the board-fact verb family. The has/have frame can pin the
|
|
4325
|
+
* verb by naming it outright; a locative verb (rests/stands/sits/lies/…) has
|
|
4326
|
+
* no closed set to name, so the PREP_SRC preposition pins the split instead,
|
|
4327
|
+
* the same way GENERAL_VERB_DETERMINER_TEACH_RE's does. Same subject fold as
|
|
4328
|
+
* QUANTIFIED_HAS_TEACH_RE: "every"/"each" keep the singular noun, "all" folds
|
|
4329
|
+
* the plural. */
|
|
4330
|
+
const QUANTIFIED_LOCATIVE_TEACH_RE = new RegExp(
|
|
4331
|
+
`^(every|each|all)\\s+([\\w'-]+)\\s+([a-z]+)\\s+(${PREP_SRC})\\s+(.+?)[.!?]*$`, "i",
|
|
4332
|
+
);
|
|
4333
|
+
const quantifiedLocativeSubject = (m) => (/^all$/i.test(m[1]) ? singularizeSurface(m[2]) : m[2]);
|
|
4334
|
+
/** The counting/indefinite lead that introduces ONE additional, unnamed
|
|
4335
|
+
* individual — "one more"/"another more" mirrors ACK_COUNTING_SRC's own
|
|
4336
|
+
* counting-aside vocabulary (normalize.mjs's ack-preamble arm), and bare
|
|
4337
|
+
* "another" is the ordinary English determiner "a"/"an" already is. None of
|
|
4338
|
+
* the three name WHICH disk, so all three fold onto the exact stored shape
|
|
4339
|
+
* "a disk rests on peg-a" already uses — no quantifier field, same subject,
|
|
4340
|
+
* same predicate. */
|
|
4341
|
+
const LOCATIVE_COUNTING_LEAD_SRC = "(?:just\\s+)?(?:one|another)\\s+more|another";
|
|
4342
|
+
const LOCATIVE_COUNTING_TEACH_RE = new RegExp(
|
|
4343
|
+
`^(?:${LOCATIVE_COUNTING_LEAD_SRC})\\s+([\\w'-]+)\\s+([a-z]+)\\s+(${PREP_SRC})\\s+(.+?)[.!?]*$`, "i",
|
|
4344
|
+
);
|
|
4322
4345
|
/** Verbs owned by an earlier, more specific recognizer in this lane — is/are
|
|
4323
4346
|
* (class-membership/property, above) and owns/maintains (ownership, above).
|
|
4324
4347
|
* generalVerbTeach declines outright on these so it can never race a more
|
|
@@ -4500,14 +4523,24 @@ async function generalVerbTeach(payload) {
|
|
|
4500
4523
|
const m = p.match(GENERAL_VERB_TEACH_RE);
|
|
4501
4524
|
if (!m) return null;
|
|
4502
4525
|
let [, subjectRaw, verbRaw, objectRaw] = m;
|
|
4526
|
+
let quantifier = "";
|
|
4503
4527
|
// A determiner in the subject slot means the single-token subject bound has
|
|
4504
4528
|
// bound the article and misread the real subject's second word as the verb
|
|
4505
4529
|
// ("the small disk rests on…" gives subject="the", verb="small"). Re-read it
|
|
4506
4530
|
// with the preposition pinning the verb; a sentence that frame can't pin
|
|
4507
4531
|
// declines here exactly as it always has.
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4532
|
+
//
|
|
4533
|
+
// The locative quantifier leads are checked here too, even though neither
|
|
4534
|
+
// is in GENERAL_VERB_DETERMINER_RE's own single-token set: "another"/"one"
|
|
4535
|
+
// (the first word of "another disk"/"one more disk") aren't articles, so
|
|
4536
|
+
// without this OR the redirect below never triggers and the mis-bound
|
|
4537
|
+
// subjectRaw/verbRaw from GENERAL_VERB_TEACH_RE ("another"/"disk" instead
|
|
4538
|
+
// of "disk"/"rests") stands uncorrected.
|
|
4539
|
+
const quantLoc = p.match(QUANTIFIED_LOCATIVE_TEACH_RE);
|
|
4540
|
+
const countLoc = !quantLoc ? p.match(LOCATIVE_COUNTING_TEACH_RE) : null;
|
|
4541
|
+
if (GENERAL_VERB_DETERMINER_RE.test(subjectRaw) || quantLoc || countLoc) {
|
|
4542
|
+
const quantHas = (!quantLoc && !countLoc) ? p.match(QUANTIFIED_HAS_TEACH_RE) : null;
|
|
4543
|
+
const detHas = (!quantHas && !quantLoc && !countLoc) ? p.match(DETERMINER_HAS_TEACH_RE) : null;
|
|
4511
4544
|
if (quantHas) {
|
|
4512
4545
|
subjectRaw = quantifiedHasSubject(quantHas);
|
|
4513
4546
|
verbRaw = "has";
|
|
@@ -4516,6 +4549,22 @@ async function generalVerbTeach(payload) {
|
|
|
4516
4549
|
subjectRaw = detHas[1];
|
|
4517
4550
|
verbRaw = "has";
|
|
4518
4551
|
objectRaw = detHas[2];
|
|
4552
|
+
} else if (quantLoc) {
|
|
4553
|
+
// Universal locative ("every disk rests on peg-a") — the same
|
|
4554
|
+
// "every"-only quantifier-field convention unknownSubjectFallback's
|
|
4555
|
+
// isa teach already uses: "each"/"all" gate as universal too but
|
|
4556
|
+
// record no quantifier string of their own.
|
|
4557
|
+
subjectRaw = quantifiedLocativeSubject(quantLoc);
|
|
4558
|
+
verbRaw = quantLoc[3];
|
|
4559
|
+
objectRaw = `${quantLoc[4]} ${quantLoc[5]}`;
|
|
4560
|
+
quantifier = /^every$/i.test(quantLoc[1]) ? "every" : "";
|
|
4561
|
+
} else if (countLoc) {
|
|
4562
|
+
// "one more disk"/"another disk" name one additional, unnamed
|
|
4563
|
+
// individual — stored exactly like its bare-article twin "a disk
|
|
4564
|
+
// rests on peg-a" below, no quantifier field.
|
|
4565
|
+
subjectRaw = countLoc[1];
|
|
4566
|
+
verbRaw = countLoc[2];
|
|
4567
|
+
objectRaw = `${countLoc[3]} ${countLoc[4]}`;
|
|
4519
4568
|
} else {
|
|
4520
4569
|
const det = p.match(GENERAL_VERB_DETERMINER_TEACH_RE);
|
|
4521
4570
|
if (!det) return null; // not a bare-name subject, and no preposition to pin the verb
|
|
@@ -4556,7 +4605,10 @@ async function generalVerbTeach(payload) {
|
|
|
4556
4605
|
if (PLACE_ADVERB_OBJECT_RE.test(object)) return null; // a place adverb is never a real object
|
|
4557
4606
|
if (await readsAsNarratedEvent(verb, folded.predicate !== mintedPredicate)) return null;
|
|
4558
4607
|
if (await readsAsUnknownEverywhere(subject, verb, object)) return null;
|
|
4559
|
-
return {
|
|
4608
|
+
return {
|
|
4609
|
+
subject, predicate: negated ? negatedPredicate(folded.predicate) : folded.predicate, object,
|
|
4610
|
+
...(quantifier ? { quantifier } : {}),
|
|
4611
|
+
};
|
|
4560
4612
|
}
|
|
4561
4613
|
|
|
4562
4614
|
/** Does this word read as a WORD at all — the committed lexicon knows it as a
|
|
@@ -4728,7 +4780,13 @@ async function bareTeachWrapperNudgeText(text) {
|
|
|
4728
4780
|
// Wired into factReadBack, gated on an already-true `miss` so a real graph
|
|
4729
4781
|
// query is never shadowed. Reuses generalVerbTeach's own exclude guards and
|
|
4730
4782
|
// generalVerbPredicate, plus the SAME adverb-skip, so the two never disagree. ----
|
|
4731
|
-
|
|
4783
|
+
// The optional every/each/all/any lead lets "does every disk rest on peg-a"
|
|
4784
|
+
// reach the same subject the quantified locative teach stores under
|
|
4785
|
+
// ("disk") instead of mis-binding the quantifier itself as the subject
|
|
4786
|
+
// token — a plain "a"/"an" lead already worked because no article can be
|
|
4787
|
+
// mistaken for a subject noun, but "every"/"each"/"all"/"any" all look like
|
|
4788
|
+
// ordinary single-token subjects to this regex without the carve-out.
|
|
4789
|
+
const GENERAL_VERB_YESNO_RE = new RegExp(`^(?:does|did)\\s+(?:(?:every|each|all|any)\\s+)?([\\w'-]+)\\s+${TEACH_ADVERB_SKIP_SRC}([a-z]+)\\s+(.+?)[?.!\\s]*$`, "i");
|
|
4732
4790
|
const GENERAL_VERB_OPEN_RE = new RegExp(`^what\\s+(?:does|did)\\s+([\\w'-]+)\\s+${TEACH_ADVERB_SKIP_SRC}([a-z]+(?:\\s+(?:${PREP_SRC}))?)[?.!\\s]*$`, "i");
|
|
4733
4791
|
/** GENERAL_VERB_EXCLUDE_RE was written for generalVerbTeach's fully-conjugated
|
|
4734
4792
|
* declarative verb ("X OWNS Y", "X MAINTAINS Y") — but "does/did X <verb> Y"
|
|
@@ -6364,9 +6422,19 @@ async function teachLane(query, { memoryDir, sessionId = "", lexicon = null, cac
|
|
|
6364
6422
|
const detLed = raw.match(GENERAL_VERB_DETERMINER_TEACH_RE);
|
|
6365
6423
|
const detHasLed = detLed ? null : raw.match(DETERMINER_HAS_TEACH_RE);
|
|
6366
6424
|
const quantHasLed = (detLed || detHasLed) ? null : raw.match(QUANTIFIED_HAS_TEACH_RE);
|
|
6425
|
+
// The two locative quantifier leads ("every disk rests…", "one more disk
|
|
6426
|
+
// rests…") need the same override as quantHasLed/detHasLed just below:
|
|
6427
|
+
// their own first word ("every"/"one"/"another") never POS-tags as a
|
|
6428
|
+
// NOUN/PROPN, so without this the bare-sentence POS gate silently drops
|
|
6429
|
+
// them exactly the way it used to drop "every overbid has a gouger".
|
|
6430
|
+
const quantLocLed = (detLed || detHasLed || quantHasLed) ? null : raw.match(QUANTIFIED_LOCATIVE_TEACH_RE);
|
|
6431
|
+
const countLocLed = (detLed || detHasLed || quantHasLed || quantLocLed)
|
|
6432
|
+
? null : raw.match(LOCATIVE_COUNTING_TEACH_RE);
|
|
6367
6433
|
const subjectWord = detLed ? detLed[1].split(/\s+/).pop()
|
|
6368
6434
|
: (detHasLed ? detHasLed[1]
|
|
6369
|
-
: (quantHasLed ? quantifiedHasSubject(quantHasLed)
|
|
6435
|
+
: (quantHasLed ? quantifiedHasSubject(quantHasLed)
|
|
6436
|
+
: (quantLocLed ? quantifiedLocativeSubject(quantLocLed)
|
|
6437
|
+
: (countLocLed ? countLocLed[1] : raw.match(/^([\w'-]+)/)?.[1]))));
|
|
6370
6438
|
// The quantifier lead ("every … has …") is itself a strong declarative
|
|
6371
6439
|
// signal, so it overrides the single-token POS gate: a noun that doubles
|
|
6372
6440
|
// as a verb ("every overbid has a gouger" — wink tags "overbid" VERB)
|
|
@@ -6375,7 +6443,7 @@ async function teachLane(query, { memoryDir, sessionId = "", lexicon = null, cac
|
|
|
6375
6443
|
// NON_DECLARATIVE_OPENER_RE runs even for these leads — "every umm has a
|
|
6376
6444
|
// thing" isn't a real quantified sentence, just filler that fits the shape.
|
|
6377
6445
|
if (subjectWord && !NON_DECLARATIVE_OPENER_RE.test(subjectWord)
|
|
6378
|
-
&& (quantHasLed || detHasLed || (await subjectIsNounOrPropn(subjectWord)))) {
|
|
6446
|
+
&& (quantHasLed || detHasLed || quantLocLed || countLocLed || (await subjectIsNounOrPropn(subjectWord)))) {
|
|
6379
6447
|
// A PLURAL explicit-capability surface ("wrens can hum") whose
|
|
6380
6448
|
// SINGULAR is a grounded term stores under the singular first — the
|
|
6381
6449
|
// spelling the grounding fact and every query-side variant fold use —
|