ekms 9.8.0-beta.16 → 9.8.0-beta.17

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.
@@ -44,14 +44,46 @@
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
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
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
  },
@@ -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
  [
@@ -91,9 +138,25 @@
91
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
  ],
@@ -440,13 +503,45 @@
440
503
  "queryable"
441
504
  ],
442
505
  "convolution": true,
443
- "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
+ ]
444
523
  },
445
524
  {
446
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:100",
525
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:101",
447
526
  "id": "solve",
448
527
  "enhanced_associations": false,
449
- "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
+ ]
450
545
  },
451
546
  {
452
547
  "id": "forVariable",
@@ -468,12 +563,27 @@
468
563
  ]
469
564
  },
470
565
  {
471
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:131",
566
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:133",
472
567
  "id": "calculate",
473
568
  "isA": [
474
569
  "verb"
475
570
  ],
476
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
+ ],
477
587
  "localHierarchy": [
478
588
  [
479
589
  "unknown",
@@ -482,9 +592,25 @@
482
592
  ]
483
593
  },
484
594
  {
485
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:143",
595
+ "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:146",
486
596
  "id": "equals",
487
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
+ ],
488
614
  "words": [
489
615
  "="
490
616
  ],
@@ -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')
@@ -86,6 +86,7 @@ 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
91
  semantic: ({context, api, objects, verbatim}) => {
91
92
  const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })
@@ -101,6 +102,7 @@ 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 {
@@ -132,6 +134,7 @@ 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}) => {
@@ -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(),
package/common/helpers.js CHANGED
@@ -283,7 +283,6 @@ function defaultContextCheck({marker, extra = [], exported = false} = {}) {
283
283
  if (marker) {
284
284
  match = ({context}) => context.marker == marker
285
285
  } else {
286
- match = () => true
287
286
  }
288
287
  return {
289
288
  marker,
@@ -343,7 +343,10 @@ knowledgeModule( {
343
343
  contents: hierarchy_tests,
344
344
  // TODO doesnt this need the KM
345
345
  checks: {
346
- objects: ['children', 'concept', 'parents', 'properties'],
346
+ objects: [
347
+ 'children', 'concept', 'parents', 'properties',
348
+ { km: 'properties' },
349
+ ],
347
350
  context: [
348
351
  defaultContextCheck(),
349
352
  ],
@@ -87,6 +87,22 @@
87
87
  "isA": [
88
88
  "mathematicalExpression"
89
89
  ],
90
+ "check": [
91
+ "marker",
92
+ "text",
93
+ "verbatim",
94
+ "value",
95
+ "evalue",
96
+ "isResponse",
97
+ {
98
+ "properties": "modifiers"
99
+ },
100
+ {
101
+ "properties": "postModifiers"
102
+ },
103
+ "x",
104
+ "y"
105
+ ],
90
106
  "semantic": "async ({e, context}) => {\n const x = toValue(await e(context.x, where())) \n const y = toValue(await e(context.y, where()))\n if (!x || !y) {\n // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }\n context.isResponse = false\n } else {\n context.evalue = { marker: 'number', value: apply(x, y) }\n // context.evalue = apply(x, y)\n context.evalue.isResponse = true\n context.evalue.paraphrase = false\n // context.paraphrase = false\n // context.isResponse = true\n }\n /*\n if (!context.value) {\n context.isResponse = false\n context.paraphrase = true\n }\n */\n }"
91
107
  },
92
108
  {
@@ -118,6 +134,22 @@
118
134
  "isA": [
119
135
  "mathematicalExpression"
120
136
  ],
137
+ "check": [
138
+ "marker",
139
+ "text",
140
+ "verbatim",
141
+ "value",
142
+ "evalue",
143
+ "isResponse",
144
+ {
145
+ "properties": "modifiers"
146
+ },
147
+ {
148
+ "properties": "postModifiers"
149
+ },
150
+ "x",
151
+ "y"
152
+ ],
121
153
  "semantic": "async ({e, context}) => {\n const x = toValue(await e(context.x, where())) \n const y = toValue(await e(context.y, where()))\n if (!x || !y) {\n // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }\n context.isResponse = false\n } else {\n context.evalue = { marker: 'number', value: apply(x, y) }\n // context.evalue = apply(x, y)\n context.evalue.isResponse = true\n context.evalue.paraphrase = false\n // context.paraphrase = false\n // context.isResponse = true\n }\n /*\n if (!context.value) {\n context.isResponse = false\n context.paraphrase = true\n }\n */\n }"
122
154
  },
123
155
  {
@@ -158,6 +190,22 @@
158
190
  "isA": [
159
191
  "mathematicalExpression"
160
192
  ],
193
+ "check": [
194
+ "marker",
195
+ "text",
196
+ "verbatim",
197
+ "value",
198
+ "evalue",
199
+ "isResponse",
200
+ {
201
+ "properties": "modifiers"
202
+ },
203
+ {
204
+ "properties": "postModifiers"
205
+ },
206
+ "x",
207
+ "y"
208
+ ],
161
209
  "semantic": "async ({e, context}) => {\n const x = toValue(await e(context.x, where())) \n const y = toValue(await e(context.y, where()))\n if (!x || !y) {\n // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }\n context.isResponse = false\n } else {\n context.evalue = { marker: 'number', value: apply(x, y) }\n // context.evalue = apply(x, y)\n context.evalue.isResponse = true\n context.evalue.paraphrase = false\n // context.paraphrase = false\n // context.isResponse = true\n }\n /*\n if (!context.value) {\n context.isResponse = false\n context.paraphrase = true\n }\n */\n }"
162
210
  },
163
211
  {
@@ -197,6 +245,22 @@
197
245
  "isA": [
198
246
  "mathematicalExpression"
199
247
  ],
248
+ "check": [
249
+ "marker",
250
+ "text",
251
+ "verbatim",
252
+ "value",
253
+ "evalue",
254
+ "isResponse",
255
+ {
256
+ "properties": "modifiers"
257
+ },
258
+ {
259
+ "properties": "postModifiers"
260
+ },
261
+ "x",
262
+ "y"
263
+ ],
200
264
  "semantic": "async ({e, context}) => {\n const x = toValue(await e(context.x, where())) \n const y = toValue(await e(context.y, where()))\n if (!x || !y) {\n // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }\n context.isResponse = false\n } else {\n context.evalue = { marker: 'number', value: apply(x, y) }\n // context.evalue = apply(x, y)\n context.evalue.isResponse = true\n context.evalue.paraphrase = false\n // context.paraphrase = false\n // context.isResponse = true\n }\n /*\n if (!context.value) {\n context.isResponse = false\n context.paraphrase = true\n }\n */\n }"
201
265
  }
202
266
  ],
@@ -547,6 +611,22 @@
547
611
  "bridge": "{ ...next(operator) }",
548
612
  "isA": [
549
613
  "mathematicalExpression"
614
+ ],
615
+ "check": [
616
+ "marker",
617
+ "text",
618
+ "verbatim",
619
+ "value",
620
+ "evalue",
621
+ "isResponse",
622
+ {
623
+ "properties": "modifiers"
624
+ },
625
+ {
626
+ "properties": "postModifiers"
627
+ },
628
+ "x",
629
+ "y"
550
630
  ]
551
631
  },
552
632
  {
@@ -576,6 +656,22 @@
576
656
  "bridge": "{ ...next(operator) }",
577
657
  "isA": [
578
658
  "mathematicalExpression"
659
+ ],
660
+ "check": [
661
+ "marker",
662
+ "text",
663
+ "verbatim",
664
+ "value",
665
+ "evalue",
666
+ "isResponse",
667
+ {
668
+ "properties": "modifiers"
669
+ },
670
+ {
671
+ "properties": "postModifiers"
672
+ },
673
+ "x",
674
+ "y"
579
675
  ]
580
676
  },
581
677
  {
@@ -614,6 +710,22 @@
614
710
  "bridge": "{ ...next(operator) }",
615
711
  "isA": [
616
712
  "mathematicalExpression"
713
+ ],
714
+ "check": [
715
+ "marker",
716
+ "text",
717
+ "verbatim",
718
+ "value",
719
+ "evalue",
720
+ "isResponse",
721
+ {
722
+ "properties": "modifiers"
723
+ },
724
+ {
725
+ "properties": "postModifiers"
726
+ },
727
+ "x",
728
+ "y"
617
729
  ]
618
730
  },
619
731
  {
@@ -651,6 +763,22 @@
651
763
  "bridge": "{ ...next(operator) }",
652
764
  "isA": [
653
765
  "mathematicalExpression"
766
+ ],
767
+ "check": [
768
+ "marker",
769
+ "text",
770
+ "verbatim",
771
+ "value",
772
+ "evalue",
773
+ "isResponse",
774
+ {
775
+ "properties": "modifiers"
776
+ },
777
+ {
778
+ "properties": "postModifiers"
779
+ },
780
+ "x",
781
+ "y"
654
782
  ]
655
783
  }
656
784
  ],
package/common/math.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
- const { defaultContextCheck } = require('./helpers')
2
+ const { defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
3
3
  const dialogues = require('./dialogues')
4
4
  const numbers = require('./numbers')
5
5
  const punctuation = require('./punctuation')
@@ -47,6 +47,7 @@ function mathematicalOperator(name, words, apply, before = []) {
47
47
  bridge: "{ ...next(operator) }",
48
48
  isA: ['mathematicalExpression'],
49
49
  // generatorp: async ({gp, context}) => `${await gp(context.x)} ${context.word} ${await gp(context.y)}`,
50
+ check: defaultContextCheckProperties(['x', 'y']),
50
51
  semantic: async ({e, context}) => {
51
52
  const x = toValue(await e(context.x, where()))
52
53
  const y = toValue(await e(context.y, where()))
@@ -139,7 +140,9 @@ knowledgeModule( {
139
140
  name: './math.test.json',
140
141
  contents: tests,
141
142
  checks: {
142
- context: [defaultContextCheck()],
143
+ context: [
144
+ defaultContextCheck()
145
+ ],
143
146
  }
144
147
  },
145
148
  })
@@ -190,7 +190,9 @@ knowledgeModule( {
190
190
  context: [
191
191
  defaultContextCheck({ extra: ['pullFromContext'] }),
192
192
  ],
193
- objects: ['mentioned', { km: 'stm' }],
193
+ objects: [
194
+ { km: 'stm' }
195
+ ],
194
196
  },
195
197
  include: {
196
198
  words: [ "peter james chunkington", "banana" ],
@@ -415,22 +415,22 @@ knowledgeModule( {
415
415
  name: './reminders.test.json',
416
416
  contents: reminders_tests,
417
417
  checks: {
418
- context: [defaultContextCheck({ extra: ['who', 'reminder'] })],
418
+ context: [
419
+ {
420
+ match: ({ path, pathEquals }) => pathEquals(path, ['reminders', '*']),
421
+ apply: () => ['dateTimeSelector', 'text', 'nextISODate', 'who', 'reminder'],
422
+ },
423
+ ],
419
424
  objects: [
420
425
  {
421
426
  property: 'reminders',
422
- check: [
423
- 'text',
424
- 'dateTimeSelectorText',
425
- 'nextISODate',
426
- 'who',
427
- 'stm',
428
- {
429
- property: 'dateTimeSelector',
430
- check: ['marker', 'text', 'value'],
431
- },
432
- ],
433
- }
427
+ check: [
428
+ {
429
+ property: (key) => typeof key == 'number',
430
+ check: ['text', 'who', 'dateTimeSelector', 'dateTimeSelectorText', 'nextISODate', 'id'],
431
+ }
432
+ ]
433
+ },
434
434
  ],
435
435
  },
436
436
  },