@polycode-projects/the-mechanical-code-talker 5.0.36 → 5.0.38
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.
- package/README.md +1 -1
- package/bin/tmct.mjs +22 -3
- package/package.json +1 -1
- package/src/domain/ask-vocab.mjs +52 -2
- package/src/domain/ask.mjs +271 -18
- package/src/domain/interpret/strategies/grammar.mjs +14 -12
- package/src/domain/interpret/strategies/keywords.mjs +23 -10
- package/src/surfaces/web/memory-ask-browser.bundle.js +117 -117
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import {
|
|
9
9
|
VERB_TO_KIND, ENTITY_TO_TYPE, MODIFIER_TO_KIND,
|
|
10
10
|
WHERE_MARKERS, MENTION_MARKERS, PLACEHOLDER_NOUNS, PASSIVE_PARTICIPLE_TO_KIND,
|
|
11
|
-
|
|
11
|
+
REDUCED_RELATIVE_CLAUSES,
|
|
12
|
+
readConverse, HAS_FAMILY_VERBS, CALLS_VERB_REPORT_NOUNS,
|
|
12
13
|
} from "../../ask-vocab.mjs";
|
|
13
14
|
import { STOPWORDS } from "../normalize.mjs";
|
|
14
15
|
import { VOCAB_WORDS, eligibleForCanon, fuzzyVocabWord } from "../fuzzy.mjs";
|
|
@@ -243,6 +244,7 @@ export function parseKeywordSpot(text, nlp = null) {
|
|
|
243
244
|
// against the canonicalized array, whose word IS the table key.
|
|
244
245
|
const entityType = entityHit ? ENTITY_TO_TYPE[canonWords.slice(entityHit.start, entityHit.end).join(" ")] : null;
|
|
245
246
|
const modifier = modifierHit ? MODIFIER_TO_KIND[canonWords.slice(modifierHit.start, modifierHit.end).join(" ")] : "direct";
|
|
247
|
+
const verbPhrase = canonWords.slice(verbHit.start, verbHit.end).join(" ");
|
|
246
248
|
|
|
247
249
|
// "when" turns a touches decomposition temporal; other verbs fall through.
|
|
248
250
|
if (kind === "touches" && lcWords.includes("when")) {
|
|
@@ -310,19 +312,30 @@ export function parseKeywordSpot(text, nlp = null) {
|
|
|
310
312
|
if (verbFromParticiple && byIdx < 0 && afterText && lcWords[verbHit.start] === "called") return null;
|
|
311
313
|
|
|
312
314
|
if (beforeText && afterText) {
|
|
313
|
-
const verbPhrase = canonWords.slice(verbHit.start, verbHit.end).join(" ");
|
|
314
315
|
// The bare have-family "ask" shape ("does X have Y") declines here, same
|
|
315
316
|
// reasoning as grammar.mjs's T1 (see HAS_FAMILY_VERBS above) — never for
|
|
316
317
|
// the entityType-driven forward/reverse branches below, which keep their
|
|
317
318
|
// own tested grain-check decline.
|
|
318
319
|
if (kind === "defines" && HAS_FAMILY_VERBS.has(verbPhrase)) return null;
|
|
319
320
|
if (kind === "calls" && (leadsWithCallsReportNoun(afterText) || isBareCallsVerbWord(beforeText))) return null;
|
|
320
|
-
// A
|
|
321
|
-
//
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
// A passive participle whose complement is introduced by a preposition
|
|
322
|
+
// rather than "by" ("is Widget DEFINED IN app/lib/b.mjs") names its AGENT
|
|
323
|
+
// after that preposition, so the leading term is the relation's object.
|
|
324
|
+
// REDUCED_RELATIVE_CLAUSES already curates which participle+preposition
|
|
325
|
+
// bigrams read that way; the "by" bigrams never reach here, since the
|
|
326
|
+
// passive branch above claims every sentence carrying one.
|
|
327
|
+
const bigram = verbFromParticiple && byIdx < 0
|
|
328
|
+
? REDUCED_RELATIVE_CLAUSES[`${lcWords[verbHit.start]} ${lcWords[verbHit.end]}`]
|
|
329
|
+
: null;
|
|
330
|
+
if (bigram && bigram.role === "agent" && bigram.kind === kind) {
|
|
331
|
+
return stamp({ shape: "ask", entityType: null, modifier: "direct", kind, subject: afterText, object: beforeText });
|
|
332
|
+
}
|
|
333
|
+
// A converse verb ("superclass of", "belongs to") swaps subject/object, same
|
|
334
|
+
// as grammar.mjs's T1.
|
|
335
|
+
return stamp(readConverse({
|
|
336
|
+
shape: "ask", entityType: null, modifier: "direct", kind,
|
|
337
|
+
subject: beforeText, object: afterText,
|
|
338
|
+
}, verbPhrase));
|
|
326
339
|
}
|
|
327
340
|
if (afterText) {
|
|
328
341
|
if (kind === "calls" && leadsWithCallsReportNoun(afterText)) return null;
|
|
@@ -333,7 +346,7 @@ export function parseKeywordSpot(text, nlp = null) {
|
|
|
333
346
|
// answered "no classes" over a module-level graph. Only a type word on
|
|
334
347
|
// the wh-side of the verb ("which CLASSES use Store") filters the result.
|
|
335
348
|
const resultType = entityHit && entityHit.start >= verbHit.end ? null : entityType;
|
|
336
|
-
return stamp({ shape: "reverse", entityType: resultType, modifier, kind, object: afterText });
|
|
349
|
+
return stamp(readConverse({ shape: "reverse", entityType: resultType, modifier, kind, object: afterText }, verbPhrase));
|
|
337
350
|
}
|
|
338
351
|
// "what is a kind of class": when the object is itself an entity-type noun, the
|
|
339
352
|
// entity match swallows the whole post-verb span as a grain qualifier, leaving
|
|
@@ -365,7 +378,7 @@ export function parseKeywordSpot(text, nlp = null) {
|
|
|
365
378
|
}
|
|
366
379
|
// forward keeps the spotted entityType (traverse()'s commit-as-subject grain
|
|
367
380
|
// selection); modifier stays hardcoded since no forward closure traversal exists.
|
|
368
|
-
if (beforeText) return stamp({ shape: "forward", entityType, modifier: "direct", kind, object: beforeText });
|
|
381
|
+
if (beforeText) return stamp(readConverse({ shape: "forward", entityType, modifier: "direct", kind, object: beforeText }, verbPhrase));
|
|
369
382
|
return null;
|
|
370
383
|
}
|
|
371
384
|
|