tpmkms 9.8.0 → 9.9.0

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.
Files changed (95) hide show
  1. package/common/actions.instance.json +10 -8
  2. package/common/actions.js +13 -11
  3. package/common/angle.instance.json +25 -17
  4. package/common/animals.instance.json +54 -28
  5. package/common/askfor.instance.json +89 -192
  6. package/common/askfor.js +49 -12
  7. package/common/asking.js +13 -5
  8. package/common/avatar.js +3 -3
  9. package/common/can.instance.json +32 -20
  10. package/common/can.js +2 -2
  11. package/common/colors.instance.json +44 -16
  12. package/common/colors.js +1 -1
  13. package/common/comparable.instance.json +25 -22
  14. package/common/compass.instance.json +9 -3
  15. package/common/concept.instance.json +14 -6
  16. package/common/concept.js +2 -0
  17. package/common/conjunction.js +17 -9
  18. package/common/control.js +10 -18
  19. package/common/countable.js +4 -3
  20. package/common/crew.instance.json +95 -27
  21. package/common/dateTimeSelectors.instance.json +4 -4
  22. package/common/dateTimeSelectors.js +4 -7
  23. package/common/dates.instance.json +52 -28
  24. package/common/dates.js +16 -11
  25. package/common/debug.instance.json +48 -0
  26. package/common/debug.js +50 -0
  27. package/common/debug.test.json +1 -0
  28. package/common/dialogues.js +126 -70
  29. package/common/dimension.instance.json +239 -495
  30. package/common/dimension.js +51 -9
  31. package/common/drone.instance.json +395 -84
  32. package/common/drone.js +43 -50
  33. package/common/drone_v1.instance.json +36 -12
  34. package/common/drone_v1.js +14 -9
  35. package/common/edible.instance.json +96 -32
  36. package/common/emotions.instance.json +15 -1
  37. package/common/evaluate.js +10 -13
  38. package/common/fastfood.instance.json +282 -100
  39. package/common/fastfood.js +30 -15
  40. package/common/formulas.instance.json +162 -24
  41. package/common/formulas.js +18 -9
  42. package/common/gdefaults.js +20 -96
  43. package/common/helpers/concept.js +2 -9
  44. package/common/helpers/conjunction.js +11 -1
  45. package/common/helpers/dialogues.js +48 -24
  46. package/common/helpers/gdefaults.js +15 -5
  47. package/common/helpers/properties.js +125 -326
  48. package/common/helpers.js +28 -58
  49. package/common/hierarchy.js +71 -41
  50. package/common/kirk.instance.json +3 -1
  51. package/common/latin.instance.json +10 -10
  52. package/common/latin.js +5 -5
  53. package/common/length.instance.json +247 -61
  54. package/common/math.instance.json +144 -5
  55. package/common/math.js +18 -5
  56. package/common/menus.instance.json +29 -11
  57. package/common/menus.js +8 -5
  58. package/common/meta.js +14 -13
  59. package/common/nameable.js +9 -5
  60. package/common/numbers.instance.json +5 -3
  61. package/common/numbers.js +28 -28
  62. package/common/ordering.instance.json +53 -4
  63. package/common/ordinals.js +25 -25
  64. package/common/people.instance.json +66 -12
  65. package/common/percentages.js +4 -2
  66. package/common/pipboy.instance.json +89 -44
  67. package/common/pipboy.js +21 -14
  68. package/common/pokemon.instance.json +39 -13
  69. package/common/pressure.instance.json +14 -6
  70. package/common/properties.instance.json +2370 -511
  71. package/common/properties.js +496 -78
  72. package/common/punctuation.js +1 -0
  73. package/common/rates.instance.json +2 -2
  74. package/common/rates.js +3 -3
  75. package/common/reminders.instance.json +16 -0
  76. package/common/reminders.js +24 -20
  77. package/common/reports.instance.json +11 -12
  78. package/common/reports.js +12 -12
  79. package/common/scorekeeper.js +20 -10
  80. package/common/sdefaults.js +30 -9
  81. package/common/spock.instance.json +3 -1
  82. package/common/stm.js +16 -21
  83. package/common/temperature.instance.json +19 -11
  84. package/common/testing.js +2 -2
  85. package/common/time.instance.json +104 -47
  86. package/common/time.js +9 -8
  87. package/common/ui.instance.json +4 -2
  88. package/common/ui.js +5 -5
  89. package/common/weight.instance.json +86 -21
  90. package/common/weight.js +5 -1
  91. package/common/words.js +113 -2
  92. package/common/wp.instance.json +125 -18
  93. package/common/wp.js +6 -2
  94. package/main.js +2 -0
  95. package/package.json +7 -3
@@ -147,10 +147,10 @@ const template = {
147
147
  "((meal/* && context.comboNumber == undefined) [comboMeal] (combo/*))",
148
148
  "((combo/*) [comboNumber] (number/* || numberNumberCombo/*))",
149
149
  "((numberNumberCombo/1) [numberNumberCombo_combo|] (combo/0))",
150
- "((number/0,1 && context.instance == false) [numberNumberCombo] (number/0,1 && instance == true))",
150
+ "((number/0,1 && context.isInstance == false) [numberNumberCombo] (number/0,1 && isInstance == true))",
151
151
  "((combo/*) [([withModification|with] ([modification]))])",
152
152
  ],
153
- floaters: ['instance'],
153
+ floaters: ['isInstance'],
154
154
  priorities: [
155
155
  // { "context": [['counting', 0], ['strawberry_smoothie', 0], ], "choose": [0] },
156
156
  { "context": [['counting', 0], ['strawberry_smoothie', 0], ], "choose": [1] },
@@ -196,6 +196,7 @@ const template = {
196
196
  { id: 'modification' },
197
197
  {
198
198
  id: 'withModification',
199
+ where: where(),
199
200
  level: 0,
200
201
  before: ['preposition'],
201
202
  generatorp: async ({context, gp}) => `with ${await gp(context.modifications)}`,
@@ -225,7 +226,7 @@ const template = {
225
226
  convolution: true,
226
227
  before: ['combo', 'preposition'],
227
228
  // after: ['comma'],
228
- bridge: "{ ...next(before[0]), postModifiers: append(before[0].postModifiers, ['comboNumber']), comboNumber: after[0], instance: true, flatten: true }",
229
+ bridge: "{ ...next(before[0]), postModifiers: append(before[0].postModifiers, ['comboNumber']), comboNumber: after[0], isInstance: true, flatten: true }",
229
230
  },
230
231
  {
231
232
  id: 'numberNumberCombo',
@@ -260,7 +261,7 @@ const template = {
260
261
  {
261
262
  // split "sprite and fanta" into separate things so the ask will pick them up
262
263
  match: ({context}) => context.marker == 'list' && context.topLevel && !context.flatten,
263
- apply: async ({context, s}) => await s({...context, flatten: true}),
264
+ apply: async ({context, e}) => await e({...context, flatten: true}, where()),
264
265
  },
265
266
  {
266
267
  where: where(),
@@ -386,13 +387,14 @@ const template = {
386
387
  bridges: [
387
388
  {
388
389
  id: "change",
390
+ where: where(),
389
391
  isA: ['verb'],
390
392
  localHierarchy: [ ['thisitthat', 'meal'], ['thisitthat', 'drink'] ],
391
393
  generatorp: async ({context, gp}) => `change ${await gp(context.from)} to ${await gp(context.to)}`,
392
394
  bridge: "{ ...next(operator), from: after[0], to: after[1].toObject }",
393
- semantic: async ({context, api, e}) => {
395
+ semantic: async ({callId, context, api, e, toEValue}) => {
394
396
  const state = api.state
395
- const eFrom = (await e(context.from)).evalue
397
+ const eFrom = toEValue(await e(context.from, where()))
396
398
  const from = state.getIdCombo(eFrom.fromSTM ? eFrom : context.from)
397
399
  const to = state.getIdCombo(context.to)
398
400
  for (const item of api.items()) {
@@ -426,6 +428,7 @@ const template = {
426
428
  bridges: [
427
429
  {
428
430
  id: 'remove',
431
+ where: where(),
429
432
  isA: ['verb'],
430
433
  bridge: "{ ...next(operator), remove: after[0], postModifiers: ['remove'] }",
431
434
  semantic: ({context, api}) => {
@@ -439,6 +442,7 @@ const template = {
439
442
  },
440
443
  {
441
444
  id: 'reset',
445
+ where: where(),
442
446
  isA: ['verb'],
443
447
  bridge: "{ ...next(operator) }",
444
448
  semantic: ({context, api}) => {
@@ -885,9 +889,9 @@ class State {
885
889
  },
886
890
  {
887
891
  where: where(),
888
- match: ({context, isA}) => isA(context.marker, 'number') && !context.evaluate,
892
+ match: ({context, isA}) => isA(context.marker, 'number'),
889
893
  apply: async ({context, e}) => {
890
- food.comboNumber = { value: (await e(context)).value }
894
+ food.comboNumber = { value: (await e(context, where())).value }
891
895
  this.add(Object.assign(food, context))
892
896
  }
893
897
  },
@@ -947,15 +951,15 @@ const config = {
947
951
  where: where(),
948
952
  priority: -10,
949
953
  match: ({context}) => context.marker == 'compound_operator',
950
- apply: async ({context, s}) => {
954
+ apply: async ({context, e}) => {
951
955
  context.marker = 'list'
952
956
  context.flatten = true
953
- await s(context)
957
+ await e(context, where())
954
958
  }
955
959
  },
956
960
  {
957
961
  where: where(),
958
- match: ({context, isAListable}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !context.evaluate,
962
+ match: ({context, contextHierarchy, isAListable, stack}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !contextHierarchy.under('change'),
959
963
  apply: ({context, km, api, instance}) => {
960
964
  for (const element of propertyToArray(context)) {
961
965
  km('fastfood').api.state.add(element)
@@ -967,14 +971,16 @@ const config = {
967
971
  bridges: [
968
972
  {
969
973
  id: 'orderNoun',
974
+ where: where(),
970
975
  parents: ['noun', 'queryable'],
971
- evaluator: ({context, api}) => {
976
+ semantic: ({context, api}) => {
972
977
  context.evalue = { marker: 'list', value: api.objects.items }
973
978
  api.show()
974
979
  }
975
980
  },
976
981
  {
977
982
  id: 'showOrder',
983
+ where: where(),
978
984
  parents: ['verb'],
979
985
  bridge: "{ ...next(operator), order: after[0] }",
980
986
  generatorp: async ({context, g}) => `show ${await g(context.order)}`,
@@ -1001,7 +1007,9 @@ knowledgeModule( {
1001
1007
  'show',
1002
1008
  {
1003
1009
  property: 'items',
1004
- check: [
1010
+ check: [{
1011
+ property: (key) => typeof key == 'number',
1012
+ check: [
1005
1013
  'combo',
1006
1014
  'pieces',
1007
1015
  'size',
@@ -1009,8 +1017,9 @@ knowledgeModule( {
1009
1017
  'id',
1010
1018
  { property: 'food', check: [ 'marker', 'value', 'text' ] },
1011
1019
  { property: 'modifications', check: [ 'id', 'item_id', 'food' ] },
1012
- 'needsDrink'
1013
- ],
1020
+ 'needsDrink',
1021
+ ]
1022
+ }],
1014
1023
  },
1015
1024
  'changes',
1016
1025
  'response',
@@ -1021,6 +1030,12 @@ knowledgeModule( {
1021
1030
  ],
1022
1031
  context: [
1023
1032
  defaultContextCheck({ extra: ['comboNumber'] }),
1033
+ defaultContextCheck({ marker: 'combo', exported: true, extra: ['comboNumber'] }),
1034
+ {
1035
+ match: ({context}) => context.combo,
1036
+ apply: () => ['food', 'needsDrink'],
1037
+ },
1038
+
1024
1039
  ],
1025
1040
  },
1026
1041
  },
@@ -29,8 +29,8 @@
29
29
  ],
30
30
  "semantics": [
31
31
  {
32
- "match": "({context, api}) => context.evaluate && api.get(context)",
33
- "apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n context.evalue = await e(formula) \n }"
32
+ "match": "({context, api, stack}) => !context.topLevel && api.get(context)",
33
+ "apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n context.evalue = await e(formula, where()) \n }"
34
34
  }
35
35
  ],
36
36
  "bridges": [
@@ -44,16 +44,48 @@
44
44
  ],
45
45
  "convolution": true,
46
46
  "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
47
+ "check": [
48
+ "marker",
49
+ "text",
50
+ "verbatim",
51
+ "value",
52
+ "evalue",
53
+ "isResponse",
54
+ {
55
+ "properties": "modifiers"
56
+ },
57
+ {
58
+ "properties": "postModifiers"
59
+ },
60
+ "equality",
61
+ "variable"
62
+ ],
47
63
  "generatorp": "async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`",
48
- "evaluator": "({context, api, objects, verbatim}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n if (formulas.length > 0) {\n context.evalue = { marker: 'list', value: formulas }\n } else {\n context.evalue = { marker: 'answerNotKnown' }\n }\n }"
64
+ "semantic": "({context, api, objects, verbatim}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n if (formulas.length > 0) {\n context.evalue = { marker: 'list', value: formulas }\n } else {\n context.evalue = { marker: 'undefined' }\n }\n }"
49
65
  },
50
66
  {
51
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:100",
67
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:101",
52
68
  "id": "solve",
53
69
  "enhanced_associations": false,
54
70
  "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
71
+ "check": [
72
+ "marker",
73
+ "text",
74
+ "verbatim",
75
+ "value",
76
+ "evalue",
77
+ "isResponse",
78
+ {
79
+ "properties": "modifiers"
80
+ },
81
+ {
82
+ "properties": "postModifiers"
83
+ },
84
+ "equality",
85
+ "variable"
86
+ ],
55
87
  "generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`",
56
- "semantic": "async ({api, context, fragments}) => {\n try {\n context.response = await api.solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n } catch( e ) {\n }\n if (!context.response) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }"
88
+ "semantic": "async ({api, context, fragments}) => {\n try {\n context.evalue = await api.solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n } catch( e ) {\n }\n if (!context.evalue) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }"
57
89
  },
58
90
  {
59
91
  "id": "forVariable",
@@ -75,12 +107,27 @@
75
107
  ]
76
108
  },
77
109
  {
78
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:131",
110
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:133",
79
111
  "id": "calculate",
80
112
  "isA": [
81
113
  "verb"
82
114
  ],
83
115
  "bridge": "{ ...next(operator), expression: after[0] }",
116
+ "check": [
117
+ "marker",
118
+ "text",
119
+ "verbatim",
120
+ "value",
121
+ "evalue",
122
+ "isResponse",
123
+ {
124
+ "properties": "modifiers"
125
+ },
126
+ {
127
+ "properties": "postModifiers"
128
+ },
129
+ "expression"
130
+ ],
84
131
  "generatorp": "async ({context, g}) => `${context.word} ${await g(context.expression)}`",
85
132
  "localHierarchy": [
86
133
  [
@@ -88,12 +135,28 @@
88
135
  "expression"
89
136
  ]
90
137
  ],
91
- "semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression)\n context.isResponse = true\n }"
138
+ "semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression, where())\n context.isResponse = true\n }"
92
139
  },
93
140
  {
94
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:143",
141
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:146",
95
142
  "id": "equals",
96
143
  "bridge": "{ ...next(operator), left: before[0], right: after[0] }",
144
+ "check": [
145
+ "marker",
146
+ "text",
147
+ "verbatim",
148
+ "value",
149
+ "evalue",
150
+ "isResponse",
151
+ {
152
+ "properties": "modifiers"
153
+ },
154
+ {
155
+ "properties": "postModifiers"
156
+ },
157
+ "left",
158
+ "right"
159
+ ],
97
160
  "words": [
98
161
  "="
99
162
  ],
@@ -230,7 +293,6 @@
230
293
  "level": 2,
231
294
  "context_index": 1,
232
295
  "topLevel": true,
233
- "context_id": 2,
234
296
  "touchedBy": [
235
297
  "formulas#call2"
236
298
  ]
@@ -391,6 +453,9 @@
391
453
  }
392
454
  ],
393
455
  "learned_contextual_priorities": [],
456
+ "explain_associations_details": [
457
+ null
458
+ ],
394
459
  "query": "formulas are concepts",
395
460
  "key": {
396
461
  "query": "formulas are concepts"
@@ -438,13 +503,45 @@
438
503
  "queryable"
439
504
  ],
440
505
  "convolution": true,
441
- "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }"
506
+ "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
507
+ "check": [
508
+ "marker",
509
+ "text",
510
+ "verbatim",
511
+ "value",
512
+ "evalue",
513
+ "isResponse",
514
+ {
515
+ "properties": "modifiers"
516
+ },
517
+ {
518
+ "properties": "postModifiers"
519
+ },
520
+ "equality",
521
+ "variable"
522
+ ]
442
523
  },
443
524
  {
444
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:100",
525
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:101",
445
526
  "id": "solve",
446
527
  "enhanced_associations": false,
447
- "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }"
528
+ "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
529
+ "check": [
530
+ "marker",
531
+ "text",
532
+ "verbatim",
533
+ "value",
534
+ "evalue",
535
+ "isResponse",
536
+ {
537
+ "properties": "modifiers"
538
+ },
539
+ {
540
+ "properties": "postModifiers"
541
+ },
542
+ "equality",
543
+ "variable"
544
+ ]
448
545
  },
449
546
  {
450
547
  "id": "forVariable",
@@ -466,12 +563,27 @@
466
563
  ]
467
564
  },
468
565
  {
469
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:131",
566
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:133",
470
567
  "id": "calculate",
471
568
  "isA": [
472
569
  "verb"
473
570
  ],
474
571
  "bridge": "{ ...next(operator), expression: after[0] }",
572
+ "check": [
573
+ "marker",
574
+ "text",
575
+ "verbatim",
576
+ "value",
577
+ "evalue",
578
+ "isResponse",
579
+ {
580
+ "properties": "modifiers"
581
+ },
582
+ {
583
+ "properties": "postModifiers"
584
+ },
585
+ "expression"
586
+ ],
475
587
  "localHierarchy": [
476
588
  [
477
589
  "unknown",
@@ -480,9 +592,25 @@
480
592
  ]
481
593
  },
482
594
  {
483
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:143",
595
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:146",
484
596
  "id": "equals",
485
597
  "bridge": "{ ...next(operator), left: before[0], right: after[0] }",
598
+ "check": [
599
+ "marker",
600
+ "text",
601
+ "verbatim",
602
+ "value",
603
+ "evalue",
604
+ "isResponse",
605
+ {
606
+ "properties": "modifiers"
607
+ },
608
+ {
609
+ "properties": "postModifiers"
610
+ },
611
+ "left",
612
+ "right"
613
+ ],
486
614
  "words": [
487
615
  "="
488
616
  ],
@@ -602,8 +730,7 @@
602
730
  },
603
731
  "level": 1,
604
732
  "context_index": 1,
605
- "topLevel": true,
606
- "context_id": 2
733
+ "topLevel": true
607
734
  }
608
735
  ],
609
736
  "generated": [
@@ -746,6 +873,9 @@
746
873
  }
747
874
  ],
748
875
  "learned_contextual_priorities": [],
876
+ "explain_associations_details": [
877
+ null
878
+ ],
749
879
  "query": "x = y",
750
880
  "skipSemantics": true,
751
881
  "key": {
@@ -854,8 +984,7 @@
854
984
  ],
855
985
  "level": 1,
856
986
  "context_index": 1,
857
- "topLevel": true,
858
- "context_id": 2
987
+ "topLevel": true
859
988
  }
860
989
  ],
861
990
  "generated": [
@@ -928,6 +1057,9 @@
928
1057
  }
929
1058
  ],
930
1059
  "learned_contextual_priorities": [],
1060
+ "explain_associations_details": [
1061
+ null
1062
+ ],
931
1063
  "query": "x + y",
932
1064
  "skipSemantics": true,
933
1065
  "key": {
@@ -1036,8 +1168,7 @@
1036
1168
  ],
1037
1169
  "level": 1,
1038
1170
  "context_index": 1,
1039
- "topLevel": true,
1040
- "context_id": 2
1171
+ "topLevel": true
1041
1172
  }
1042
1173
  ],
1043
1174
  "generated": [
@@ -1110,6 +1241,9 @@
1110
1241
  }
1111
1242
  ],
1112
1243
  "learned_contextual_priorities": [],
1244
+ "explain_associations_details": [
1245
+ null
1246
+ ],
1113
1247
  "query": "x - y",
1114
1248
  "skipSemantics": true,
1115
1249
  "key": {
@@ -1218,8 +1352,7 @@
1218
1352
  ],
1219
1353
  "level": 1,
1220
1354
  "context_index": 1,
1221
- "topLevel": true,
1222
- "context_id": 2
1355
+ "topLevel": true
1223
1356
  }
1224
1357
  ],
1225
1358
  "generated": [
@@ -1292,6 +1425,9 @@
1292
1425
  }
1293
1426
  ],
1294
1427
  "learned_contextual_priorities": [],
1428
+ "explain_associations_details": [
1429
+ null
1430
+ ],
1295
1431
  "query": "x * y",
1296
1432
  "skipSemantics": true,
1297
1433
  "key": {
@@ -1400,8 +1536,7 @@
1400
1536
  ],
1401
1537
  "level": 1,
1402
1538
  "context_index": 1,
1403
- "topLevel": true,
1404
- "context_id": 2
1539
+ "topLevel": true
1405
1540
  }
1406
1541
  ],
1407
1542
  "generated": [
@@ -1474,6 +1609,9 @@
1474
1609
  }
1475
1610
  ],
1476
1611
  "learned_contextual_priorities": [],
1612
+ "explain_associations_details": [
1613
+ null
1614
+ ],
1477
1615
  "query": "x / y",
1478
1616
  "skipSemantics": true,
1479
1617
  "key": {
@@ -1,5 +1,5 @@
1
1
  const { knowledgeModule, where, Digraph, debug } = require('./runtime').theprogrammablemind
2
- const { defaultContextCheck } = require('./helpers')
2
+ const { defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
3
3
  const dialogues = require('./dialogues.js')
4
4
  const pos = require('./pos.js')
5
5
  const math = require('./math.js')
@@ -71,10 +71,10 @@ const config = {
71
71
  semantics: [
72
72
  {
73
73
  where: where(),
74
- match: ({context, api}) => context.evaluate && api.get(context),
74
+ match: ({context, api, stack}) => !context.topLevel && api.get(context),
75
75
  apply: async ({context, api, e}) => {
76
76
  const { formula } = api.get(context)
77
- context.evalue = await e(formula)
77
+ context.evalue = await e(formula, where())
78
78
  }
79
79
  },
80
80
  ],
@@ -86,13 +86,14 @@ const config = {
86
86
  isA: ['preposition', 'queryable'],
87
87
  convolution: true,
88
88
  bridge: "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
89
+ check: defaultContextCheckProperties(['equality', 'variable']),
89
90
  generatorp: async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`,
90
- evaluator: ({context, api, objects, verbatim}) => {
91
+ semantic: ({context, api, objects, verbatim}) => {
91
92
  const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })
92
93
  if (formulas.length > 0) {
93
94
  context.evalue = { marker: 'list', value: formulas }
94
95
  } else {
95
- context.evalue = { marker: 'answerNotKnown' }
96
+ context.evalue = { marker: 'undefined' }
96
97
  }
97
98
  }
98
99
  },
@@ -101,15 +102,16 @@ const config = {
101
102
  id: 'solve',
102
103
  enhanced_associations: false,
103
104
  bridge: "{ ...next(operator), equality: after[0], variable: after[2] }",
105
+ check: defaultContextCheckProperties(['equality', 'variable']),
104
106
  generatorp: async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`,
105
107
  semantic: async ({api, context, fragments}) => {
106
108
  try {
107
- context.response = await api.solveFor(context.equality, context.variable)
109
+ context.evalue = await api.solveFor(context.equality, context.variable)
108
110
  context.isResponse = true
109
111
  context.value = null
110
112
  } catch( e ) {
111
113
  }
112
- if (!context.response) {
114
+ if (!context.evalue) {
113
115
  // TODO some KM for talking to the user wrt brief+avatar
114
116
  context.verbatim = `Solving failed`
115
117
  }
@@ -132,10 +134,11 @@ const config = {
132
134
  id: 'calculate',
133
135
  isA: ['verb'],
134
136
  bridge: "{ ...next(operator), expression: after[0] }",
137
+ check: defaultContextCheckProperties(['expression']),
135
138
  generatorp: async ({context, g}) => `${context.word} ${await g(context.expression)}`,
136
139
  localHierarchy: [ ['unknown', 'expression'] ],
137
140
  semantic: async ({context, e}) => {
138
- context.evalue = await e(context.expression)
141
+ context.evalue = await e(context.expression, where())
139
142
  context.isResponse = true
140
143
  }
141
144
  },
@@ -143,6 +146,7 @@ const config = {
143
146
  where: where(),
144
147
  id: 'equals',
145
148
  bridge: "{ ...next(operator), left: before[0], right: after[0] }",
149
+ check: defaultContextCheckProperties(['left', 'right']),
146
150
  words: ['='],
147
151
  after: ['mathematical_operator'],
148
152
  // TODO have this be per argument then 'is' can map to equals where this only applied to before[0] and not after[0]
@@ -195,7 +199,12 @@ knowledgeModule({
195
199
  contents: tests,
196
200
  checks: {
197
201
  objects: [
198
- 'formulas',
202
+ {
203
+ property: 'formulas',
204
+ check: [
205
+ { property: () => true, check: ['name', 'formula', 'equality'] },
206
+ ],
207
+ },
199
208
  ],
200
209
  context: [
201
210
  defaultContextCheck(),