tpmkms_4wp 8.0.0-beta.4 → 8.0.0-beta.41
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/common/animals.instance.json +2855 -1363
- package/common/animals.js +2 -2
- package/common/articles.js +108 -0
- package/common/articles.test.json +310 -0
- package/common/avatar.js +2 -2
- package/common/characters.js +9 -11
- package/common/colors.instance.json +6980 -3523
- package/common/colors.js +2 -2
- package/common/colors.test.json +345 -780
- package/common/comparable.js +2 -15
- package/common/concept.js +17 -11
- package/common/countable.js +5 -5
- package/common/crew.instance.json +13032 -6570
- package/common/crew.js +4 -4
- package/common/crew.test.json +714 -452
- package/common/currency.js +7 -7
- package/common/dialogues.js +117 -238
- package/common/dimension.instance.json +265 -264
- package/common/dimension.js +13 -13
- package/common/dimension.test.json +446 -1640
- package/common/edible.instance.json +19910 -9988
- package/common/edible.js +2 -2
- package/common/emotions.instance.json +146 -128
- package/common/emotions.js +4 -4
- package/common/evaluate.instance.json +2 -0
- package/common/evaluate.js +55 -0
- package/common/evaluate.test.json +574 -0
- package/common/events.js +6 -6
- package/common/fastfood.instance.json +221110 -111293
- package/common/fastfood.js +25 -25
- package/common/formulas.instance.json +241 -255
- package/common/formulas.js +14 -14
- package/common/gdefaults.js +19 -19
- package/common/help.js +4 -4
- package/common/help.test.json +22 -22
- package/common/helpers/concept.js +9 -6
- package/common/helpers/dialogues.js +2 -3
- package/common/helpers/properties.js +48 -58
- package/common/helpers.js +1 -1
- package/common/hierarchy.js +12 -16
- package/common/javascript.js +8 -8
- package/common/kirk.instance.json +583 -289
- package/common/kirk.js +2 -2
- package/common/length.instance.json +5530 -4754
- package/common/length.js +2 -2
- package/common/listener.js +54 -0
- package/common/listener.test.json +104 -0
- package/common/math.instance.json +176 -1168
- package/common/math.js +11 -11
- package/common/meta.js +22 -29
- package/common/nameable.instance.json +2 -0
- package/common/nameable.js +142 -0
- package/common/nameable.test.json +2121 -0
- package/common/negation.instance.json +2 -0
- package/common/negation.js +38 -0
- package/common/negation.test.json +308 -0
- package/common/numbers.js +3 -3
- package/common/ordering.instance.json +340 -228
- package/common/ordering.js +5 -5
- package/common/people.instance.json +2066 -1014
- package/common/people.js +4 -5
- package/common/percentages.instance.json +2 -0
- package/common/percentages.js +57 -0
- package/common/percentages.test.json +751 -0
- package/common/pipboy.instance.json +7974 -6300
- package/common/pipboy.js +29 -32
- package/common/pokemon.instance.json +4207 -2069
- package/common/pokemon.js +4 -4
- package/common/pos.js +1 -1
- package/common/pressure.instance.json +1341 -1189
- package/common/pressure.js +2 -2
- package/common/properties.instance.json +130 -60
- package/common/properties.js +54 -125
- package/common/punctuation.js +2 -2
- package/common/reports.instance.json +595 -557
- package/common/reports.js +58 -76
- package/common/scorekeeper.js +14 -22
- package/common/sdefaults.js +13 -3
- package/common/sizeable.js +2 -2
- package/common/spock.instance.json +583 -289
- package/common/spock.js +2 -2
- package/common/stgame.js +13 -9
- package/common/stm.js +162 -19
- package/common/stm.test.json +1734 -1
- package/common/tell.js +10 -10
- package/common/temperature.instance.json +1484 -1204
- package/common/temperature.js +2 -2
- package/common/tester.js +2 -2
- package/common/testing.js +5 -5
- package/common/time.js +7 -7
- package/common/tokenize.js +1 -1
- package/common/ui.instance.json +257 -258
- package/common/ui.js +9 -9
- package/common/weight.instance.json +5212 -4233
- package/common/weight.js +2 -2
- package/common/yesno.js +1 -1
- package/main.js +59 -46
- package/package.json +27 -6
package/common/dialogues.js
CHANGED
@@ -2,7 +2,9 @@ const { Config, knowledgeModule, where, stableId } = require('./runtime').thepro
|
|
2
2
|
const meta = require('./meta.js')
|
3
3
|
const gdefaults = require('./gdefaults.js')
|
4
4
|
const sdefaults = require('./sdefaults.js')
|
5
|
+
const articles = require('./articles.js')
|
5
6
|
const pos = require('./pos.js')
|
7
|
+
const negation = require('./negation.js')
|
6
8
|
const punctuation = require('./punctuation.js')
|
7
9
|
const stm = require('./stm.js')
|
8
10
|
const _ = require('lodash')
|
@@ -49,17 +51,16 @@ let configStruct = {
|
|
49
51
|
{ pattern: "([nevermindTestSetup] (allowed))", development: true },
|
50
52
|
"([why])",
|
51
53
|
"([reason])",
|
52
|
-
"([thisitthat|])",
|
53
|
-
"([it])",
|
54
|
-
"([this])",
|
55
|
-
"([that])",
|
54
|
+
// "([thisitthat|])",
|
55
|
+
// "([it])",
|
56
|
+
// "([this])",
|
57
|
+
// "([that])",
|
56
58
|
|
57
59
|
"(<what> ([whatAble|]))",
|
58
60
|
"([what:optional])",
|
59
|
-
"(<the|> ([theAble|]))",
|
60
|
-
"(<a|a,an> ([theAble|]))",
|
61
|
+
// "(<the|> ([theAble|]))",
|
62
|
+
// "(<a|a,an> ([theAble|]))",
|
61
63
|
// "([unknown])",
|
62
|
-
"([not] ([notAble|]))",
|
63
64
|
|
64
65
|
"([be] ([briefOrWordy|]))",
|
65
66
|
|
@@ -105,7 +106,7 @@ let configStruct = {
|
|
105
106
|
{
|
106
107
|
id: 'makeObject',
|
107
108
|
bridge: "{ ...next(operator), object: after[0] }",
|
108
|
-
generatorp: ({context, gp}) => `${context.word} ${gp(context.object)}`,
|
109
|
+
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.object)}`,
|
109
110
|
semantic: ({config, context, api}) => {
|
110
111
|
api.makeObject({ context: context.object, config, types: [] })
|
111
112
|
}
|
@@ -113,7 +114,7 @@ let configStruct = {
|
|
113
114
|
{
|
114
115
|
id: 'setIdSuffix',
|
115
116
|
bridge: "{ ...next(operator), suffix: after[0] }",
|
116
|
-
generatorp: ({context, gp}) => `${context.word} ${gp(context.suffix)}`,
|
117
|
+
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.suffix)}`,
|
117
118
|
semantic: ({context, api}) => {
|
118
119
|
api.setIdSuffix(context.suffix.text)
|
119
120
|
}
|
@@ -163,8 +164,8 @@ let configStruct = {
|
|
163
164
|
level: 0,
|
164
165
|
isA: ['preposition'],
|
165
166
|
bridge: "{ ...next(operator), toObject: after[0] }",
|
166
|
-
generatorp: ({context, gp}) => {
|
167
|
-
return `to ${gp(context.toObject)}`
|
167
|
+
generatorp: async ({context, gp}) => {
|
168
|
+
return `to ${await gp(context.toObject)}`
|
168
169
|
},
|
169
170
|
},
|
170
171
|
{ id: "toAble", level: 0, bridge: "{ ...next(operator) }" },
|
@@ -172,15 +173,12 @@ let configStruct = {
|
|
172
173
|
{ id: "be", level: 0, bridge: "{ ...next(operator), type: after[0] }" },
|
173
174
|
{ id: "briefOrWordy", level: 0, bridge: "{ ...next(operator) }" },
|
174
175
|
|
175
|
-
{ id: "notAble", level: 0, bridge: "{ ...next(operator) }" },
|
176
|
-
{ id: "not", level: 0, bridge: "{ ...after, negated: true }" },
|
177
|
-
|
178
176
|
{ id: "yesno", level: 0, bridge: "{ ...next(operator) }" },
|
179
177
|
{ id: "canBeQuestion", level: 0, bridge: "{ ...next(operator) }" },
|
180
178
|
{ id: "canBeQuestion", level: 1, bridge: "{ ...next(operator) }" },
|
181
179
|
// { id: "unknown", level: 0, bridge: "{ ...next(operator), unknown: true, dead: true }" },
|
182
180
|
// { id: "unknown", level: 1, bridge: "{ ...next(operator) }" },
|
183
|
-
{ id: "queryable", level: 0, bridge: "{ ...next(operator) }" },
|
181
|
+
// { id: "queryable", level: 0, bridge: "{ ...next(operator) }" },
|
184
182
|
{ id: "questionMark", level: 0, bridge: "{ ...before[0], query: [before.marker] }" },
|
185
183
|
// { id: "isEd", level: 0, bridge: "{ ...context, query: true }" },
|
186
184
|
// gregbug
|
@@ -209,6 +207,7 @@ let configStruct = {
|
|
209
207
|
{ id: "doesAble", level: 1, bridge: "{ ...next(operator), before: before[0] }" },
|
210
208
|
{ id: "does", level: 0, bridge: "{ query: true, what: operator.marker, ...context, number: operator.number, object.number: operator.number }*" },
|
211
209
|
|
210
|
+
/*
|
212
211
|
{
|
213
212
|
id: 'the',
|
214
213
|
level: 0,
|
@@ -220,13 +219,17 @@ let configStruct = {
|
|
220
219
|
// bridge: "{ ...after[0], pullFromContext: false, instance: true, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
|
221
220
|
bridge: "{ ...after[0], pullFromContext: false, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
|
222
221
|
},
|
222
|
+
*/
|
223
|
+
/*
|
223
224
|
{
|
224
225
|
id: "theAble",
|
225
226
|
children: ['noun'],
|
226
227
|
bridge: "{ ...next(operator) }"
|
227
228
|
},
|
229
|
+
*/
|
228
230
|
|
229
231
|
// TODO make this hierarchy thing work
|
232
|
+
/*
|
230
233
|
{
|
231
234
|
id: "thisitthat",
|
232
235
|
level: 0,
|
@@ -234,6 +237,7 @@ let configStruct = {
|
|
234
237
|
before: ['verby'],
|
235
238
|
bridge: "{ ...next(operator) }"
|
236
239
|
},
|
240
|
+
*/
|
237
241
|
{
|
238
242
|
id: "nevermind",
|
239
243
|
bridge: "{ ...next(operator) }",
|
@@ -282,6 +286,7 @@ let configStruct = {
|
|
282
286
|
isA: ['theAble', 'queryable'],
|
283
287
|
bridge: "{ ...next(operator) }"
|
284
288
|
},
|
289
|
+
/*
|
285
290
|
{
|
286
291
|
id: "it",
|
287
292
|
level: 0,
|
@@ -300,11 +305,12 @@ let configStruct = {
|
|
300
305
|
isA: ['thisitthat'],
|
301
306
|
bridge: "{ ...next(operator), unknown: true, pullFromContext: true }"
|
302
307
|
},
|
308
|
+
*/
|
303
309
|
],
|
304
310
|
words: {
|
305
311
|
"literals": {
|
306
312
|
"?": [{"id": "questionMark", "initial": "{}" }],
|
307
|
-
"the": [{"id": "the", "initial": "{ modifiers: [] }" }],
|
313
|
+
// "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
|
308
314
|
"who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
|
309
315
|
"yes": [{"id": "yesno", "initial": "{ value: true }" }],
|
310
316
|
"no": [{"id": "yesno", "initial": "{ value: false }" }],
|
@@ -337,7 +343,6 @@ let configStruct = {
|
|
337
343
|
// ['questionMark', 'isEd'],
|
338
344
|
['a', 'articlePOS'],
|
339
345
|
['the', 'articlePOS'],
|
340
|
-
['unknown', 'notAble'],
|
341
346
|
['unknown', 'theAble'],
|
342
347
|
['unknown', 'queryable'],
|
343
348
|
['it', 'queryable'],
|
@@ -354,10 +359,10 @@ let configStruct = {
|
|
354
359
|
where: where(),
|
355
360
|
notes: "handle making responses brief",
|
356
361
|
match: ({context, objects}) => (context.topLevel || context.isResponse) && objects.brief && !context.briefWasRun,
|
357
|
-
apply: ({context, g}) => {
|
362
|
+
apply: async ({context, g}) => {
|
358
363
|
const focussed = focus(context)
|
359
364
|
context.briefWasRun = true
|
360
|
-
return g(focussed)
|
365
|
+
return await g(focussed)
|
361
366
|
},
|
362
367
|
priority: -2,
|
363
368
|
},
|
@@ -418,8 +423,8 @@ let configStruct = {
|
|
418
423
|
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
419
424
|
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
420
425
|
match: ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value && context.value.length > 0 && context.value[0].marker == 'yesno',
|
421
|
-
apply: ({context, g, gs}) => {
|
422
|
-
return `${g(context.value[0])} ${gs(context.value.slice(1), ', ', ' and ')}`
|
426
|
+
apply: async ({context, g, gs}) => {
|
427
|
+
return `${await g(context.value[0])} ${await gs(context.value.slice(1), ', ', ' and ')}`
|
423
428
|
}
|
424
429
|
},
|
425
430
|
|
@@ -429,49 +434,24 @@ let configStruct = {
|
|
429
434
|
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
430
435
|
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
431
436
|
match: ({context, hierarchy}) => context.marker == 'list' && context.value,
|
432
|
-
apply: ({context, gs}) => {
|
437
|
+
apply: async ({context, gs}) => {
|
433
438
|
if (context.newLinesOnly) {
|
434
|
-
return gs(context.value, '\n')
|
439
|
+
return await gs(context.value, '\n')
|
435
440
|
} else {
|
436
|
-
return gs(context.value, ', ', ' and ')
|
441
|
+
return await gs(context.value, ', ', ' and ')
|
437
442
|
}
|
438
443
|
}
|
439
444
|
},
|
440
445
|
|
441
|
-
{
|
442
|
-
where: where(),
|
443
|
-
notes: 'paraphrase a negation',
|
444
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'notAble') && context.negated, // && !context.isQuery && !context.paraphrase && context.value,
|
445
|
-
apply: ({context, g}) => {
|
446
|
-
context.negated = false
|
447
|
-
const result = g(context.value)
|
448
|
-
context.negated = true
|
449
|
-
return `not ${result}`
|
450
|
-
}
|
451
|
-
},
|
452
|
-
|
453
446
|
{
|
454
447
|
where: where(),
|
455
448
|
notes: 'paraphrase a queryable response',
|
456
449
|
// || context.evalue.paraphrase -> when the evalue acts as a paraphrase value
|
457
450
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.evalue && (!context.paraphrase || context.evalue.paraphrase),
|
458
|
-
apply: ({context, g}) => {
|
459
|
-
return g(context.evalue)
|
460
|
-
}
|
461
|
-
},
|
462
|
-
/* dup of one above
|
463
|
-
{
|
464
|
-
where: where(),
|
465
|
-
notes: 'paraphrase a queryable',
|
466
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && !context.paraphrase && context.evalue,
|
467
|
-
apply: ({context, g}) => {
|
468
|
-
const oldValue = context.evalue.paraphrase
|
469
|
-
const result = g(context.evalue)
|
470
|
-
context.evalue.paraphrase = oldValue
|
471
|
-
return result
|
451
|
+
apply: async ({context, g}) => {
|
452
|
+
return await g(context.evalue)
|
472
453
|
}
|
473
454
|
},
|
474
|
-
*/
|
475
455
|
{
|
476
456
|
where: where(),
|
477
457
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.isSelf && context.subject == 'my',
|
@@ -480,7 +460,7 @@ let configStruct = {
|
|
480
460
|
{
|
481
461
|
where: where(),
|
482
462
|
match: ({context, hierarchy}) => ['it', 'what'].includes(context.marker) && context.paraphrase,
|
483
|
-
apply: ({
|
463
|
+
apply: ({context}) => `${context.word}`
|
484
464
|
},
|
485
465
|
{
|
486
466
|
where: where(),
|
@@ -490,15 +470,8 @@ let configStruct = {
|
|
490
470
|
{
|
491
471
|
where: where(),
|
492
472
|
match: ({context, hierarchy}) => ['my', 'your'].includes(context.subject) && hierarchy.isA(context.marker, 'queryable') && context.paraphrase,
|
493
|
-
apply: ({
|
494
|
-
},
|
495
|
-
/*
|
496
|
-
{
|
497
|
-
where: where(),
|
498
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'theAble') && context.paraphrase && context.wantsValue && !context.pullFromContext,
|
499
|
-
apply: ({g, context}) => `a ${context.word}`
|
473
|
+
apply: ({context}) => `${context.subject} ${context.marker}`
|
500
474
|
},
|
501
|
-
*/
|
502
475
|
{
|
503
476
|
where: where(),
|
504
477
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.subject,
|
@@ -523,8 +496,8 @@ let configStruct = {
|
|
523
496
|
{
|
524
497
|
where: where(),
|
525
498
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query,
|
526
|
-
apply: ({context, gp}) => {
|
527
|
-
return `${gp({...context, topLevel: undefined})}?`
|
499
|
+
apply: async ({context, gp}) => {
|
500
|
+
return `${await gp({...context, topLevel: undefined})}?`
|
528
501
|
},
|
529
502
|
priority: -1,
|
530
503
|
},
|
@@ -532,27 +505,27 @@ let configStruct = {
|
|
532
505
|
where: where(),
|
533
506
|
notes: "x is y",
|
534
507
|
match: ({context, hierarchy}) => { return hierarchy.isA(context.marker, 'is') && context.paraphrase },
|
535
|
-
apply: ({context, g, gp}) => {
|
536
|
-
return `${g({ ...context.one, paraphrase: true })} ${context.word} ${gp(context.two)}`
|
508
|
+
apply: async ({context, g, gp}) => {
|
509
|
+
return `${await g({ ...context.one, paraphrase: true })} ${context.word} ${await gp(context.two)}`
|
537
510
|
}
|
538
511
|
},
|
539
512
|
{
|
540
513
|
where: where(),
|
541
514
|
notes: 'is with a response defined',
|
542
515
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.evalue,
|
543
|
-
apply: ({context, g, gs}) => {
|
516
|
+
apply: async ({context, g, gs}) => {
|
544
517
|
const response = context.evalue;
|
545
518
|
const concept = response.concept;
|
546
519
|
if (concept) {
|
547
520
|
concept.paraphrase = true
|
548
521
|
concept.isSelf = true
|
549
|
-
const instance = g(response.instance)
|
550
|
-
return `${g(concept)} ${context.word} ${instance}`
|
522
|
+
const instance = await g(response.instance)
|
523
|
+
return `${await g(concept)} ${context.word} ${instance}`
|
551
524
|
} else {
|
552
525
|
if (Array.isArray(response)) {
|
553
|
-
return `${gs(response)}`
|
526
|
+
return `${await gs(response)}`
|
554
527
|
} else {
|
555
|
-
return `${g(response)}`
|
528
|
+
return `${await g(response)}`
|
556
529
|
}
|
557
530
|
}
|
558
531
|
}
|
@@ -561,13 +534,13 @@ let configStruct = {
|
|
561
534
|
where: where(),
|
562
535
|
notes: 'x is y (not a response)',
|
563
536
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && !context.evalue,
|
564
|
-
apply: ({context, g, gp, gr, callId}) => {
|
537
|
+
apply: async ({context, g, gp, gr, callId}) => {
|
565
538
|
if ((context.two.evalue || {}).marker == 'answerNotKnown') {
|
566
|
-
return g(context.two.evalue)
|
539
|
+
return await g(context.two.evalue)
|
567
540
|
}
|
568
541
|
|
569
542
|
if (!context.isResponse) {
|
570
|
-
return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
543
|
+
return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
|
571
544
|
}
|
572
545
|
|
573
546
|
const hasFocus = (property) => {
|
@@ -592,17 +565,15 @@ let configStruct = {
|
|
592
565
|
}
|
593
566
|
// greg101
|
594
567
|
if (focus == 'one') {
|
595
|
-
return `${g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gp(context.one)}`
|
568
|
+
return `${await g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gp(context.one)}`
|
596
569
|
} else {
|
597
570
|
// TODO fix this using the assumed and that whole mess. change isResponse to useValue
|
598
571
|
if (context.isResponse) {
|
599
|
-
return `${gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
572
|
+
return `${await gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
|
600
573
|
} else {
|
601
|
-
return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gr(context.two)}`
|
574
|
+
return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gr(context.two)}`
|
602
575
|
}
|
603
|
-
// return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
604
576
|
}
|
605
|
-
// return `${g({...context.one})} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
606
577
|
},
|
607
578
|
},
|
608
579
|
],
|
@@ -628,107 +599,62 @@ let configStruct = {
|
|
628
599
|
{
|
629
600
|
where: where(),
|
630
601
|
match: ({context}) => context.marker === 'error',
|
631
|
-
apply: ({context, gp}) => {
|
602
|
+
apply: async ({context, gp}) => {
|
632
603
|
context.evalue = "That is not known"
|
633
604
|
if (context.reason) {
|
634
|
-
context.evalue += ` because ${gp(context.reason)}`
|
605
|
+
context.evalue += ` because ${await gp(context.reason)}`
|
635
606
|
}
|
636
607
|
context.isResponse = true
|
637
608
|
}
|
638
609
|
},
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
{
|
688
|
-
"marker": "unknown",
|
689
|
-
"range": {
|
690
|
-
"start": 24,
|
691
|
-
"end": 32
|
692
|
-
},
|
693
|
-
"word": "price",
|
694
|
-
"text": "the price",
|
695
|
-
"value": "price",
|
696
|
-
"unknown": true,
|
697
|
-
"types": [
|
698
|
-
"unknown"
|
699
|
-
],
|
700
|
-
"pullFromContext": true,
|
701
|
-
"concept": true,
|
702
|
-
"wantsValue": true,
|
703
|
-
"determiner": "the",
|
704
|
-
"modifiers": [
|
705
|
-
"determiner"
|
706
|
-
],
|
707
|
-
"evaluate": true
|
708
|
-
}
|
709
|
-
|
710
|
-
*/
|
711
|
-
context.value = kms.stm.api.mentions(context)
|
712
|
-
if (!context.value) {
|
713
|
-
// retry()
|
714
|
-
context.value = { marker: 'answerNotKnown' }
|
715
|
-
return
|
716
|
-
}
|
717
|
-
// avoid loops
|
718
|
-
if (context.marker != 'unknown') {
|
719
|
-
if (context.value.marker != context.marker) {
|
720
|
-
const instance = e(context.value)
|
721
|
-
if (instance.evalue && !instance.edefault) {
|
722
|
-
context.value = instance.evalue
|
723
|
-
}
|
724
|
-
}
|
725
|
-
}
|
726
|
-
if (context.evaluate) {
|
727
|
-
context.evalue = context.value
|
728
|
-
}
|
729
|
-
}
|
730
|
-
},
|
731
|
-
},
|
610
|
+
// {
|
611
|
+
// where: where(),
|
612
|
+
// notes: 'pull from context',
|
613
|
+
// // match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
|
614
|
+
// match: ({context, callId}) => false && context.pullFromContext && !context.same, // && context.value,
|
615
|
+
// apply: async ({callId, context, kms, e, log, retry}) => {
|
616
|
+
// if (true) {
|
617
|
+
// /*
|
618
|
+
// {
|
619
|
+
// "marker": "unknown",
|
620
|
+
// "range": {
|
621
|
+
// "start": 65,
|
622
|
+
// "end": 73
|
623
|
+
// },
|
624
|
+
// "word": "worth",
|
625
|
+
// "text": "the worth",
|
626
|
+
// "value": "worth",
|
627
|
+
// "unknown": true,
|
628
|
+
// "types": [
|
629
|
+
// "unknown"
|
630
|
+
// ],
|
631
|
+
// "pullFromContext": true,
|
632
|
+
// "concept": true,
|
633
|
+
// "wantsValue": true,
|
634
|
+
// "determiner": "the",
|
635
|
+
// "modifiers": [
|
636
|
+
// "determiner"
|
637
|
+
// ],
|
638
|
+
// "evaluate": true
|
639
|
+
// }
|
640
|
+
|
641
|
+
// */
|
642
|
+
// context.value = kms.stm.api.mentions(context)
|
643
|
+
// if (!context.value) {
|
644
|
+
// // retry()
|
645
|
+
// context.value = { marker: 'answerNotKnown' }
|
646
|
+
// return
|
647
|
+
// }
|
648
|
+
//
|
649
|
+
// const instance = await e(context.value)
|
650
|
+
// if (instance.evalue && !instance.edefault) {
|
651
|
+
// context.value = instance.evalue
|
652
|
+
// }
|
653
|
+
// if (context.evaluate) {
|
654
|
+
// context.evalue = context.value
|
655
|
+
// }
|
656
|
+
// },
|
657
|
+
// },
|
732
658
|
{
|
733
659
|
where: where(),
|
734
660
|
notes: 'what x is y?',
|
@@ -739,7 +665,7 @@ let configStruct = {
|
|
739
665
|
*/
|
740
666
|
|
741
667
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query,
|
742
|
-
apply: ({context, s, log, km, objects, e}) => {
|
668
|
+
apply: async ({context, s, log, km, objects, e}) => {
|
743
669
|
const one = context.one;
|
744
670
|
const two = context.two;
|
745
671
|
let concept, value;
|
@@ -753,9 +679,9 @@ let configStruct = {
|
|
753
679
|
// km('dialogues').api.mentioned(concept)
|
754
680
|
// TODO wtf is the next line?
|
755
681
|
value = JSON.parse(JSON.stringify(value))
|
756
|
-
let instance = e(value)
|
682
|
+
let instance = await e(value)
|
757
683
|
if (false && instance.evalue) {
|
758
|
-
km('stm').api.mentioned(value)
|
684
|
+
km('stm').api.mentioned({ context: value })
|
759
685
|
}
|
760
686
|
if (instance.verbatim) {
|
761
687
|
context.evalue = { verbatim: instance.verbatim }
|
@@ -817,14 +743,14 @@ let configStruct = {
|
|
817
743
|
where: where(),
|
818
744
|
notes: 'x is y. handles x is a kind of y or x = y in the stm',
|
819
745
|
match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
|
820
|
-
apply: ({context, s, log, api, kms, config}) => {
|
746
|
+
apply: async ({context, s, log, api, kms, config}) => {
|
821
747
|
// const oneZero = { ...context.one }
|
822
748
|
// const twoZero = { ...context.two }
|
823
749
|
|
824
750
|
const one = context.one;
|
825
751
|
const two = context.two;
|
826
752
|
one.same = two;
|
827
|
-
const onePrime = s(one)
|
753
|
+
const onePrime = await s(one)
|
828
754
|
if (!onePrime.sameWasProcessed) {
|
829
755
|
warningSameNotEvaluated(log, one)
|
830
756
|
} else {
|
@@ -837,7 +763,7 @@ let configStruct = {
|
|
837
763
|
let twoPrime;
|
838
764
|
if (!onePrime.sameWasProcessed) {
|
839
765
|
two.same = one
|
840
|
-
twoPrime = s(two)
|
766
|
+
twoPrime = await s(two)
|
841
767
|
if (!twoPrime.sameWasProcessed) {
|
842
768
|
warningSameNotEvaluated(log, two)
|
843
769
|
} else {
|
@@ -852,24 +778,10 @@ let configStruct = {
|
|
852
778
|
if (!onePrime.sameWasProcessed && !twoPrime.sameWasProcessed) {
|
853
779
|
api.makeObject({ context: one, config, types: context.two.types || [] })
|
854
780
|
kms.stm.api.setVariable(one.value, two)
|
855
|
-
kms.stm.api.mentioned(one, two)
|
781
|
+
kms.stm.api.mentioned({ context: one, value: two })
|
856
782
|
}
|
857
783
|
}
|
858
784
|
},
|
859
|
-
/*
|
860
|
-
{
|
861
|
-
where: where(),
|
862
|
-
notes: 'x = y in the stm',
|
863
|
-
match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
|
864
|
-
apply: ({context, s, log, api, kms, config}) => {
|
865
|
-
const one = context.one;
|
866
|
-
const two = context.two;
|
867
|
-
api.makeObject({ context: one, config, types: context.two.types || [] })
|
868
|
-
kms.stm.api.setVariable(one.value, two)
|
869
|
-
kms.stm.api.mentioned(one, two)
|
870
|
-
}
|
871
|
-
},
|
872
|
-
*/
|
873
785
|
{
|
874
786
|
where: where(),
|
875
787
|
notes: 'get variable from stm',
|
@@ -877,48 +789,15 @@ let configStruct = {
|
|
877
789
|
match: ({context, kms}) => context.evaluate && kms.stm.api.getVariable(context.value) != context.value,
|
878
790
|
// match: ({context, kms}) => context.evaluate,
|
879
791
|
priority: -1,
|
880
|
-
apply: ({context, kms, e}) => {
|
792
|
+
apply: async ({context, kms, e}) => {
|
881
793
|
const api = kms.stm.api
|
882
794
|
context.value = api.getVariable(context.value)
|
883
|
-
/*
|
884
|
-
if (!context.value && context.marker !== 'unknown') {
|
885
|
-
context.value = api.getVariable(context.marker)
|
886
|
-
}
|
887
|
-
*/
|
888
795
|
if (context.value && context.value.marker) {
|
889
|
-
context.evalue = e(context.value)
|
796
|
+
context.evalue = await e(context.value)
|
890
797
|
}
|
891
798
|
context.focusableForPhrase = true
|
892
799
|
}
|
893
800
|
},
|
894
|
-
/*
|
895
|
-
{
|
896
|
-
where: where(),
|
897
|
-
notes: 'default handle evaluate',
|
898
|
-
match: ({context, kms}) => context.evaluate && context.value,
|
899
|
-
// match: ({context, kms}) => context.evaluate,
|
900
|
-
// priority: -1,
|
901
|
-
apply: ({context, kms, e}) => {
|
902
|
-
if (context.value && context.value.marker) {
|
903
|
-
context.evalue = e(context.value)
|
904
|
-
}
|
905
|
-
}
|
906
|
-
},
|
907
|
-
*/
|
908
|
-
/*
|
909
|
-
{
|
910
|
-
priority: 2,
|
911
|
-
notes: 'evaluate top level not already done',
|
912
|
-
match: ({context}) => false && context.topLevel && !context.evalue,
|
913
|
-
apply: ({context, e}) => {
|
914
|
-
const instance = e({ ...context, value: undefined, topLevel: undefined })
|
915
|
-
if (instance.evalue && !instance.edefault) {
|
916
|
-
context.evalue = instance
|
917
|
-
context.isResponse = true
|
918
|
-
}
|
919
|
-
}
|
920
|
-
},
|
921
|
-
*/
|
922
801
|
],
|
923
802
|
};
|
924
803
|
|
@@ -963,9 +842,9 @@ const getAsk = (config) => (uuid) => {
|
|
963
842
|
where: semantic.where || ask.where || where(2),
|
964
843
|
source: 'response',
|
965
844
|
match: (args) => semantic.match(args),
|
966
|
-
apply: (args) => {
|
845
|
+
apply: async (args) => {
|
967
846
|
setWasApplied(true)
|
968
|
-
semantic.apply(args)
|
847
|
+
await semantic.apply(args)
|
969
848
|
},
|
970
849
|
})
|
971
850
|
}
|
@@ -982,7 +861,7 @@ const getAsk = (config) => (uuid) => {
|
|
982
861
|
onNevermind: ask.onNevermind,
|
983
862
|
source: 'question',
|
984
863
|
match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
985
|
-
apply: (args) => {
|
864
|
+
apply: async (args) => {
|
986
865
|
let matchq = ask.matchq
|
987
866
|
let applyq = ask.applyq
|
988
867
|
if (!matchq) {
|
@@ -993,11 +872,11 @@ const getAsk = (config) => (uuid) => {
|
|
993
872
|
return ask.applyq(args)
|
994
873
|
}
|
995
874
|
}
|
996
|
-
if (matchq(args)) {
|
875
|
+
if (await matchq(args)) {
|
997
876
|
setWasAsked(true)
|
998
877
|
setWasApplied(false)
|
999
878
|
// args.context.motivationKeep = true
|
1000
|
-
args.verbatim(applyq(args))
|
879
|
+
args.verbatim(await applyq(args))
|
1001
880
|
/*
|
1002
881
|
args.context.verbatim = applyq(args)
|
1003
882
|
args.context.isResponse = true;
|
@@ -1018,12 +897,12 @@ const getAsk = (config) => (uuid) => {
|
|
1018
897
|
}
|
1019
898
|
|
1020
899
|
|
1021
|
-
const createConfig = () => {
|
900
|
+
const createConfig = async () => {
|
1022
901
|
const config = new Config(configStruct, module)
|
1023
902
|
config.stop_auto_rebuild()
|
1024
|
-
config.api
|
1025
|
-
config.add(gdefaults
|
1026
|
-
config.initializer( ({objects, config, isModule}) => {
|
903
|
+
await config.setApi(api)
|
904
|
+
await config.add(articles, gdefaults, sdefaults, pos, negation, stm, meta, punctuation)
|
905
|
+
await config.initializer( ({objects, config, isModule}) => {
|
1027
906
|
/* TODO add this beck in. some stuff from config needs to be here
|
1028
907
|
config.addArgs((args) => ({
|
1029
908
|
e: (context) => config.api.getEvaluator(args.s, args.log, context),
|
@@ -1063,7 +942,7 @@ const createConfig = () => {
|
|
1063
942
|
config.addWord("doesable", { id: "doesAble", "initial": "{}" })
|
1064
943
|
}
|
1065
944
|
})
|
1066
|
-
config.restart_auto_rebuild()
|
945
|
+
await config.restart_auto_rebuild()
|
1067
946
|
return config
|
1068
947
|
}
|
1069
948
|
|