tpmkms_4wp 8.0.0-beta.7 → 8.0.0-beta.71

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/common/animals.instance.json +2871 -1379
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/avatar.js +5 -9
  6. package/common/characters.js +22 -28
  7. package/common/colors.instance.json +7170 -3657
  8. package/common/colors.js +4 -8
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.instance.json +1750 -0
  11. package/common/comparable.js +36 -28
  12. package/common/comparable.test.json +438 -2
  13. package/common/concept.js +120 -118
  14. package/common/countable.js +19 -13
  15. package/common/countable.test.json +1050 -0
  16. package/common/crew.instance.json +13066 -6469
  17. package/common/crew.js +36 -41
  18. package/common/crew.test.json +714 -452
  19. package/common/currency.js +27 -45
  20. package/common/dialogues.js +161 -285
  21. package/common/dimension.instance.json +474 -253
  22. package/common/dimension.js +16 -22
  23. package/common/dimension.test.json +446 -1640
  24. package/common/edible.instance.json +20053 -10093
  25. package/common/edible.js +3 -8
  26. package/common/emotions.instance.json +147 -69
  27. package/common/emotions.js +35 -38
  28. package/common/evaluate.instance.json +2 -0
  29. package/common/evaluate.js +49 -0
  30. package/common/evaluate.test.json +574 -0
  31. package/common/events.js +10 -14
  32. package/common/fastfood.instance.json +221166 -111223
  33. package/common/fastfood.js +75 -85
  34. package/common/fastfood.test.json +268 -90
  35. package/common/formulas.instance.json +455 -249
  36. package/common/formulas.js +19 -26
  37. package/common/gdefaults.js +24 -26
  38. package/common/help.js +7 -12
  39. package/common/help.test.json +63 -8
  40. package/common/helpers/concept.js +10 -7
  41. package/common/helpers/dialogues.js +2 -3
  42. package/common/helpers/properties.js +54 -62
  43. package/common/helpers.js +6 -5
  44. package/common/hierarchy.js +16 -24
  45. package/common/javascript.js +11 -18
  46. package/common/kirk.instance.json +584 -290
  47. package/common/kirk.js +5 -8
  48. package/common/length.instance.json +8834 -4757
  49. package/common/length.js +4 -8
  50. package/common/listener.js +48 -0
  51. package/common/listener.test.json +104 -0
  52. package/common/math.instance.json +425 -1187
  53. package/common/math.js +16 -20
  54. package/common/meta.js +23 -47
  55. package/common/nameable.instance.json +2 -0
  56. package/common/nameable.js +144 -0
  57. package/common/nameable.test.json +3191 -0
  58. package/common/negation.instance.json +2 -0
  59. package/common/negation.js +38 -0
  60. package/common/negation.test.json +308 -0
  61. package/common/numbers.js +27 -31
  62. package/common/ordering.instance.json +366 -246
  63. package/common/ordering.js +80 -86
  64. package/common/people.instance.json +2074 -1022
  65. package/common/people.js +8 -13
  66. package/common/percentages.instance.json +2 -0
  67. package/common/percentages.js +53 -0
  68. package/common/percentages.test.json +751 -0
  69. package/common/pipboy.instance.json +11745 -6329
  70. package/common/pipboy.js +48 -59
  71. package/common/pokemon.instance.json +4226 -2081
  72. package/common/pokemon.js +7 -20
  73. package/common/pos.js +15 -13
  74. package/common/pressure.instance.json +2208 -1175
  75. package/common/pressure.js +4 -8
  76. package/common/properties.instance.json +131 -61
  77. package/common/properties.js +57 -134
  78. package/common/punctuation.js +15 -7
  79. package/common/reports.instance.json +1018 -530
  80. package/common/reports.js +77 -100
  81. package/common/reports.test.json +15623 -10458
  82. package/common/scorekeeper.js +18 -30
  83. package/common/sdefaults.js +16 -7
  84. package/common/sizeable.js +6 -10
  85. package/common/spock.instance.json +584 -290
  86. package/common/spock.js +5 -8
  87. package/common/stgame.js +19 -19
  88. package/common/stm.js +164 -27
  89. package/common/stm.test.json +1734 -1
  90. package/common/tell.js +14 -18
  91. package/common/temperature.instance.json +2271 -1222
  92. package/common/temperature.js +4 -8
  93. package/common/tester.js +15 -4
  94. package/common/testing.js +8 -12
  95. package/common/time.js +20 -25
  96. package/common/tokenize.js +5 -6
  97. package/common/ui.instance.json +459 -240
  98. package/common/ui.js +16 -22
  99. package/common/weight.instance.json +7646 -4026
  100. package/common/weight.js +4 -8
  101. package/common/yesno.js +5 -5
  102. package/main.js +14 -2
  103. package/package.json +28 -5
@@ -1,8 +1,10 @@
1
- const { Config, knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
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')
@@ -33,7 +35,7 @@ const warningSameNotEvaluated = (log, one) => {
33
35
  }
34
36
 
35
37
  // TODO implement what / what did you say ...
36
- let configStruct = {
38
+ let config = {
37
39
  name: 'dialogues',
38
40
  operators: [
39
41
  "([makeObject] (word))",
@@ -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
  }
@@ -141,8 +142,8 @@ let configStruct = {
141
142
  match: "same",
142
143
  left: [ { pattern: '($type && context.instance == variables.instance)' } ],
143
144
  right: [ { pattern: '($type && context.instance == variables.instance)' } ],
144
- left: [ { pattern: '($type)' } ],
145
- right: [ { pattern: '($type)' } ],
145
+ // left: [ { pattern: '($type)' } ],
146
+ // right: [ { pattern: '($type)' } ],
146
147
  passthrough: true
147
148
  },
148
149
  bridge: "{ ...next(operator), listable: true, isList: true, value: append(before, after) }"
@@ -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
@@ -197,7 +195,7 @@ let configStruct = {
197
195
  { id: "isEder", level: 0, bridge: "{ ...next(operator) }" },
198
196
  { id: "is", level: 0,
199
197
  bridge: "{ ...next(operator), one: { number: operator.number, ...before[0] }, two: after[0] }",
200
- isA: ['verby'],
198
+ isA: ['verb'],
201
199
  queryBridge: "{ ...next(operator), one: after[0], two: after[1], query: true }" ,
202
200
  },
203
201
  { id: "is", level: 1, bridge: "{ ...next(operator) }" },
@@ -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: ({g, context}) => `${context.word}`
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: ({g, context}) => `${context.subject} ${context.marker}`
473
+ apply: ({context}) => `${context.subject} ${context.marker}`
494
474
  },
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}`
500
- },
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
- where: where(),
641
- notes: 'pull from context',
642
- // match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
643
- match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
644
- apply: ({callId, context, s, kms, e, log, retry}) => {
645
- if (true) {
646
- /*
647
- {
648
- "marker": "unknown",
649
- "range": {
650
- "start": 65,
651
- "end": 73
652
- },
653
- "word": "worth",
654
- "text": "the worth",
655
- "value": "worth",
656
- "unknown": true,
657
- "types": [
658
- "unknown"
659
- ],
660
- "pullFromContext": true,
661
- "concept": true,
662
- "wantsValue": true,
663
- "determiner": "the",
664
- "modifiers": [
665
- "determiner"
666
- ],
667
- "evaluate": true
668
- }
669
-
670
- */
671
- context.value = kms.stm.api.mentions(context)
672
- if (!context.value) {
673
- // retry()
674
- context.value = { marker: 'answerNotKnown' }
675
- return
676
- }
677
-
678
- const instance = e(context.value)
679
- if (instance.evalue && !instance.edefault) {
680
- context.value = instance.evalue
681
- }
682
- if (context.evaluate) {
683
- context.evalue = context.value
684
- }
685
- } else {
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,59 +897,56 @@ const getAsk = (config) => (uuid) => {
1018
897
  }
1019
898
 
1020
899
 
1021
- const createConfig = () => {
1022
- const config = new Config(configStruct, module)
1023
- config.stop_auto_rebuild()
1024
- config.api = api
1025
- config.add(gdefaults(), sdefaults(), pos(), stm(), meta(), punctuation())
1026
- config.initializer( ({objects, config, isModule}) => {
1027
- /* TODO add this beck in. some stuff from config needs to be here
1028
- config.addArgs((args) => ({
1029
- e: (context) => config.api.getEvaluator(args.s, args.log, context),
1030
- }))
1031
- */
1032
- config.addArgs(({config, api, isA}) => ({
1033
- isAListable: (context, type) => {
1034
- if (context.marker == 'list' || context.listable) {
1035
- return context.value.every( (element) => isA(element.marker, type) )
1036
- } else {
1037
- return isA(context.marker, type)
1038
- }
1039
- },
1040
- toContext: (v) => {
1041
- if (Array.isArray(v)) {
1042
- return { marker: 'list', level: 1, value: v }
1043
- }
1044
- if (v.marker == 'list') {
1045
- return v
1046
- }
900
+ const initializer = ({objects, config, isModule}) => {
901
+ /* TODO add this beck in. some stuff from config needs to be here
902
+ config.addArgs((args) => ({
903
+ e: (context) => config.api.getEvaluator(args.s, args.log, context),
904
+ }))
905
+ */
906
+ config.addArgs(({config, api, isA}) => ({
907
+ isAListable: (context, type) => {
908
+ if (context.marker == 'list' || context.listable) {
909
+ return context.value.every( (element) => isA(element.marker, type) )
910
+ } else {
911
+ return isA(context.marker, type)
912
+ }
913
+ },
914
+ toContext: (v) => {
915
+ if (Array.isArray(v)) {
916
+ return { marker: 'list', level: 1, value: v }
917
+ }
918
+ if (v.marker == 'list') {
1047
919
  return v
1048
- },
1049
- getUUIDScoped: (uuid) => { return {
1050
- ask: getAsk(config)(uuid),
1051
- }
1052
- },
1053
- toScopedId: (context) => {
1054
- return api('dialogues').toScopedId(context)
1055
- },
1056
- }))
1057
- objects.mentioned = []
1058
- objects.variables = {
1059
- }
1060
- if (isModule) {
1061
- } else {
1062
- config.addWord("canbedoquestion", { id: "canBeDoQuestion", "initial": "{}" })
1063
- config.addWord("doesable", { id: "doesAble", "initial": "{}" })
1064
- }
1065
- })
1066
- config.restart_auto_rebuild()
1067
- return config
920
+ }
921
+ return v
922
+ },
923
+ getUUIDScoped: (uuid) => { return {
924
+ ask: getAsk(config)(uuid),
925
+ }
926
+ },
927
+ toScopedId: (context) => {
928
+ return api('dialogues').toScopedId(context)
929
+ },
930
+ }))
931
+ objects.mentioned = []
932
+ objects.variables = {
933
+ }
934
+ if (isModule) {
935
+ } else {
936
+ config.addWord("canbedoquestion", { id: "canBeDoQuestion", "initial": "{}" })
937
+ config.addWord("doesable", { id: "doesAble", "initial": "{}" })
938
+ }
1068
939
  }
1069
940
 
1070
941
  knowledgeModule( {
942
+ config,
943
+ includes: [articles, gdefaults, sdefaults, pos, negation, stm, meta, punctuation],
944
+ initializer,
945
+ api: () => new API(),
946
+
1071
947
  module,
1072
948
  description: 'framework for dialogues',
1073
- createConfig, newWay: true,
949
+ newWay: true,
1074
950
  test: {
1075
951
  name: './dialogues.test.json',
1076
952
  contents: dialogues_tests,