ekms 9.8.0-beta.8 → 9.9.0-beta.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 (78) hide show
  1. package/common/actions.instance.json +6 -6
  2. package/common/actions.js +10 -10
  3. package/common/angle.instance.json +12 -0
  4. package/common/askfor.instance.json +12 -184
  5. package/common/askfor.js +19 -11
  6. package/common/asking.js +13 -5
  7. package/common/can.instance.json +2 -18
  8. package/common/can.js +2 -2
  9. package/common/comparable.instance.json +6 -12
  10. package/common/compass.js +1 -1
  11. package/common/concept.instance.json +8 -4
  12. package/common/concept.js +2 -0
  13. package/common/conjunction.js +9 -7
  14. package/common/control.js +5 -5
  15. package/common/countable.js +1 -0
  16. package/common/dateTimeSelectors.instance.json +1 -1
  17. package/common/dateTimeSelectors.js +1 -1
  18. package/common/dates.instance.json +11 -1
  19. package/common/dates.js +6 -1
  20. package/common/debug.instance.json +9 -1
  21. package/common/debug.js +4 -0
  22. package/common/dialogues.js +37 -35
  23. package/common/dimension.instance.json +198 -477
  24. package/common/dimension.js +48 -24
  25. package/common/drone.instance.json +89 -19
  26. package/common/drone.js +43 -41
  27. package/common/drone_v1.instance.json +13 -3
  28. package/common/drone_v1.js +20 -15
  29. package/common/evaluate.js +3 -3
  30. package/common/fastfood.instance.json +12 -4
  31. package/common/fastfood.js +27 -12
  32. package/common/formulas.instance.json +138 -12
  33. package/common/formulas.js +15 -6
  34. package/common/gdefaults.js +2 -71
  35. package/common/helpers/dialogues.js +1 -10
  36. package/common/helpers/properties.js +10 -7
  37. package/common/helpers.js +5 -2
  38. package/common/hierarchy.js +11 -7
  39. package/common/latin.instance.json +4 -4
  40. package/common/latin.js +2 -2
  41. package/common/length.instance.json +84 -0
  42. package/common/linear_orderings.instance.json +1 -0
  43. package/common/linear_orderings.js +90 -0
  44. package/common/linear_orderings.test.json +1 -0
  45. package/common/math.instance.json +141 -4
  46. package/common/math.js +18 -7
  47. package/common/menus.instance.json +6 -2
  48. package/common/menus.js +5 -2
  49. package/common/meta.js +12 -12
  50. package/common/nameable.js +6 -2
  51. package/common/numbers.instance.json +3 -0
  52. package/common/numbers.js +56 -32
  53. package/common/ordering.instance.json +1 -2
  54. package/common/percentages.js +4 -2
  55. package/common/pipboy.instance.json +38 -27
  56. package/common/pipboy.js +21 -14
  57. package/common/pressure.instance.json +6 -0
  58. package/common/properties.instance.json +2575 -528
  59. package/common/properties.js +211 -41
  60. package/common/punctuation.js +1 -0
  61. package/common/rates.instance.json +1 -1
  62. package/common/rates.js +2 -2
  63. package/common/reminders.instance.json +16 -0
  64. package/common/reminders.js +23 -19
  65. package/common/reports.instance.json +4 -6
  66. package/common/reports.js +12 -12
  67. package/common/sdefaults.js +11 -9
  68. package/common/stm.js +11 -14
  69. package/common/temperature.instance.json +21 -0
  70. package/common/testing.js +2 -2
  71. package/common/time.instance.json +87 -15
  72. package/common/time.js +7 -6
  73. package/common/ui.js +5 -5
  74. package/common/weight.instance.json +27 -0
  75. package/common/words.js +106 -1
  76. package/common/wp.instance.json +10 -3
  77. package/common/wp.js +5 -1
  78. package/package.json +5 -2
@@ -128,7 +128,7 @@
128
128
  "id": "list",
129
129
  "level": 0,
130
130
  "selector": {
131
- "match": "same",
131
+ "match": "applicable",
132
132
  "left": [
133
133
  {
134
134
  "pattern": "($type && context.isInstance == variables.isInstance)"
@@ -147,7 +147,7 @@
147
147
  "id": "list",
148
148
  "level": 1,
149
149
  "selector": {
150
- "match": "same",
150
+ "match": "applicable",
151
151
  "left": [
152
152
  {
153
153
  "pattern": "($type && context.isInstance == variables.isInstance)"
@@ -363,7 +363,7 @@
363
363
  "id": "list",
364
364
  "level": 0,
365
365
  "selector": {
366
- "match": "same",
366
+ "match": "applicable",
367
367
  "left": [
368
368
  {
369
369
  "pattern": "($type && context.isInstance == variables.isInstance)"
@@ -382,7 +382,7 @@
382
382
  "id": "list",
383
383
  "level": 1,
384
384
  "selector": {
385
- "match": "same",
385
+ "match": "applicable",
386
386
  "left": [
387
387
  {
388
388
  "pattern": "($type && context.isInstance == variables.isInstance)"
package/common/latin.js CHANGED
@@ -85,7 +85,7 @@ const config = {
85
85
  id: "list",
86
86
  level: 0,
87
87
  selector: {
88
- match: "same",
88
+ match: "applicable",
89
89
  left: [ { pattern: '($type && context.isInstance == variables.isInstance)' } ],
90
90
  right: [ { pattern: '($type && context.isInstance == variables.isInstance)' } ],
91
91
  passthrough: true
@@ -96,7 +96,7 @@ const config = {
96
96
  id: "list",
97
97
  level: 1,
98
98
  selector: {
99
- match: "same",
99
+ match: "applicable",
100
100
  left: [ { pattern: '($type && context.isInstance == variables.isInstance)' } ],
101
101
  passthrough: true
102
102
  },
@@ -3923,6 +3923,9 @@
3923
3923
  "y": {
3924
3924
  "value": 100,
3925
3925
  "isInstance": true,
3926
+ "rangeableWith": [
3927
+ "number"
3928
+ ],
3926
3929
  "text": "100",
3927
3930
  "marker": "integer",
3928
3931
  "word": "100",
@@ -4372,6 +4375,9 @@
4372
4375
  "y": {
4373
4376
  "value": 100,
4374
4377
  "isInstance": true,
4378
+ "rangeableWith": [
4379
+ "number"
4380
+ ],
4375
4381
  "text": "100",
4376
4382
  "marker": "integer",
4377
4383
  "word": "100",
@@ -4821,6 +4827,9 @@
4821
4827
  "y": {
4822
4828
  "value": 10,
4823
4829
  "isInstance": true,
4830
+ "rangeableWith": [
4831
+ "number"
4832
+ ],
4824
4833
  "text": "10",
4825
4834
  "marker": "integer",
4826
4835
  "word": "10",
@@ -5270,6 +5279,9 @@
5270
5279
  "y": {
5271
5280
  "value": 10,
5272
5281
  "isInstance": true,
5282
+ "rangeableWith": [
5283
+ "number"
5284
+ ],
5273
5285
  "text": "10",
5274
5286
  "marker": "integer",
5275
5287
  "word": "10",
@@ -5719,6 +5731,9 @@
5719
5731
  "y": {
5720
5732
  "value": 1000,
5721
5733
  "isInstance": true,
5734
+ "rangeableWith": [
5735
+ "number"
5736
+ ],
5722
5737
  "text": "1000",
5723
5738
  "marker": "integer",
5724
5739
  "word": "1000",
@@ -6168,6 +6183,9 @@
6168
6183
  "y": {
6169
6184
  "value": 1000,
6170
6185
  "isInstance": true,
6186
+ "rangeableWith": [
6187
+ "number"
6188
+ ],
6171
6189
  "text": "1000",
6172
6190
  "marker": "integer",
6173
6191
  "word": "1000",
@@ -6617,6 +6635,9 @@
6617
6635
  "y": {
6618
6636
  "value": 12,
6619
6637
  "isInstance": true,
6638
+ "rangeableWith": [
6639
+ "number"
6640
+ ],
6620
6641
  "text": "12",
6621
6642
  "marker": "integer",
6622
6643
  "word": "12",
@@ -7066,6 +7087,9 @@
7066
7087
  "y": {
7067
7088
  "value": 12,
7068
7089
  "isInstance": true,
7090
+ "rangeableWith": [
7091
+ "number"
7092
+ ],
7069
7093
  "text": "12",
7070
7094
  "marker": "integer",
7071
7095
  "word": "12",
@@ -7515,6 +7539,9 @@
7515
7539
  "y": {
7516
7540
  "value": 3.28,
7517
7541
  "isInstance": true,
7542
+ "rangeableWith": [
7543
+ "number"
7544
+ ],
7518
7545
  "text": "3.28",
7519
7546
  "marker": "number",
7520
7547
  "word": "3.28",
@@ -7964,6 +7991,9 @@
7964
7991
  "y": {
7965
7992
  "value": 0.0328,
7966
7993
  "isInstance": true,
7994
+ "rangeableWith": [
7995
+ "number"
7996
+ ],
7967
7997
  "text": "0.0328",
7968
7998
  "marker": "number",
7969
7999
  "word": "0.0328",
@@ -8413,6 +8443,9 @@
8413
8443
  "y": {
8414
8444
  "value": 3.28,
8415
8445
  "isInstance": true,
8446
+ "rangeableWith": [
8447
+ "number"
8448
+ ],
8416
8449
  "text": "3.28",
8417
8450
  "marker": "number",
8418
8451
  "word": "3.28",
@@ -8862,6 +8895,9 @@
8862
8895
  "y": {
8863
8896
  "value": 0.0328,
8864
8897
  "isInstance": true,
8898
+ "rangeableWith": [
8899
+ "number"
8900
+ ],
8865
8901
  "text": "0.0328",
8866
8902
  "marker": "number",
8867
8903
  "word": "0.0328",
@@ -9380,6 +9416,9 @@
9380
9416
  "y": {
9381
9417
  "value": 0.0328,
9382
9418
  "isInstance": true,
9419
+ "rangeableWith": [
9420
+ "number"
9421
+ ],
9383
9422
  "text": "0.0328",
9384
9423
  "marker": "number",
9385
9424
  "word": "0.0328",
@@ -9411,6 +9450,9 @@
9411
9450
  "y": {
9412
9451
  "value": 12,
9413
9452
  "isInstance": true,
9453
+ "rangeableWith": [
9454
+ "number"
9455
+ ],
9414
9456
  "text": "12",
9415
9457
  "marker": "integer",
9416
9458
  "word": "12",
@@ -10044,6 +10086,9 @@
10044
10086
  "y": {
10045
10087
  "value": 3.28,
10046
10088
  "isInstance": true,
10089
+ "rangeableWith": [
10090
+ "number"
10091
+ ],
10047
10092
  "text": "3.28",
10048
10093
  "marker": "number",
10049
10094
  "word": "3.28",
@@ -10075,6 +10120,9 @@
10075
10120
  "y": {
10076
10121
  "value": 12,
10077
10122
  "isInstance": true,
10123
+ "rangeableWith": [
10124
+ "number"
10125
+ ],
10078
10126
  "text": "12",
10079
10127
  "marker": "integer",
10080
10128
  "word": "12",
@@ -10708,6 +10756,9 @@
10708
10756
  "y": {
10709
10757
  "value": 3.28,
10710
10758
  "isInstance": true,
10759
+ "rangeableWith": [
10760
+ "number"
10761
+ ],
10711
10762
  "text": "3.28",
10712
10763
  "marker": "number",
10713
10764
  "word": "3.28",
@@ -10739,6 +10790,9 @@
10739
10790
  "y": {
10740
10791
  "value": 12,
10741
10792
  "isInstance": true,
10793
+ "rangeableWith": [
10794
+ "number"
10795
+ ],
10742
10796
  "text": "12",
10743
10797
  "marker": "integer",
10744
10798
  "word": "12",
@@ -11286,6 +11340,9 @@
11286
11340
  "x": {
11287
11341
  "value": 5280,
11288
11342
  "isInstance": true,
11343
+ "rangeableWith": [
11344
+ "number"
11345
+ ],
11289
11346
  "text": "5280",
11290
11347
  "marker": "integer",
11291
11348
  "word": "5280",
@@ -11775,6 +11832,9 @@
11775
11832
  "x": {
11776
11833
  "value": 5280,
11777
11834
  "isInstance": true,
11835
+ "rangeableWith": [
11836
+ "number"
11837
+ ],
11778
11838
  "text": "5280",
11779
11839
  "marker": "integer",
11780
11840
  "word": "5280",
@@ -11790,6 +11850,9 @@
11790
11850
  "y": {
11791
11851
  "value": 12,
11792
11852
  "isInstance": true,
11853
+ "rangeableWith": [
11854
+ "number"
11855
+ ],
11793
11856
  "text": "12",
11794
11857
  "marker": "integer",
11795
11858
  "word": "12",
@@ -12380,6 +12443,9 @@
12380
12443
  "y": {
12381
12444
  "value": 5280,
12382
12445
  "isInstance": true,
12446
+ "rangeableWith": [
12447
+ "number"
12448
+ ],
12383
12449
  "text": "5280",
12384
12450
  "marker": "integer",
12385
12451
  "word": "5280",
@@ -12411,6 +12477,9 @@
12411
12477
  "y": {
12412
12478
  "value": 12,
12413
12479
  "isInstance": true,
12480
+ "rangeableWith": [
12481
+ "number"
12482
+ ],
12414
12483
  "text": "12",
12415
12484
  "marker": "integer",
12416
12485
  "word": "12",
@@ -12975,6 +13044,9 @@
12975
13044
  "y": {
12976
13045
  "value": 1909.34,
12977
13046
  "isInstance": true,
13047
+ "rangeableWith": [
13048
+ "number"
13049
+ ],
12978
13050
  "text": "1909.34",
12979
13051
  "marker": "number",
12980
13052
  "word": "1909.34",
@@ -13424,6 +13496,9 @@
13424
13496
  "y": {
13425
13497
  "value": 1909.34,
13426
13498
  "isInstance": true,
13499
+ "rangeableWith": [
13500
+ "number"
13501
+ ],
13427
13502
  "text": "1909.34",
13428
13503
  "marker": "number",
13429
13504
  "word": "1909.34",
@@ -13873,6 +13948,9 @@
13873
13948
  "y": {
13874
13949
  "value": 5280,
13875
13950
  "isInstance": true,
13951
+ "rangeableWith": [
13952
+ "number"
13953
+ ],
13876
13954
  "text": "5280",
13877
13955
  "marker": "integer",
13878
13956
  "word": "5280",
@@ -14322,6 +14400,9 @@
14322
14400
  "y": {
14323
14401
  "value": 1000,
14324
14402
  "isInstance": true,
14403
+ "rangeableWith": [
14404
+ "number"
14405
+ ],
14325
14406
  "text": "1000",
14326
14407
  "marker": "integer",
14327
14408
  "word": "1000",
@@ -14771,6 +14852,9 @@
14771
14852
  "y": {
14772
14853
  "value": 1000,
14773
14854
  "isInstance": true,
14855
+ "rangeableWith": [
14856
+ "number"
14857
+ ],
14774
14858
  "text": "1000",
14775
14859
  "marker": "integer",
14776
14860
  "word": "1000",
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,90 @@
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheckProperties } = require('./helpers')
3
+ const tests = require('./linear_orderings.test.json')
4
+ const instance = require('./linear_orderings.instance.json')
5
+ const pos = require('./pos')
6
+ const gdefaults = require('./gdefaults')
7
+ const sdefaults = require('./sdefaults')
8
+
9
+ const config = {
10
+ name: 'linear_orderings',
11
+ operators: [
12
+ "([linearlyOrdered])",
13
+ "(value [linearOrderedRange|to] value)",
14
+ // "([fromLO|from] (linearlyOrdered/*) (to/*) (linearlyOrdered/*))",
15
+ // "at least (linearlyOrdered/*)",
16
+ // "at most (linearlyOrdered/*)",
17
+ ],
18
+ bridges: [
19
+ {
20
+ id: "linearlyOrdered",
21
+ initial: { rangeableWith: ['linearlyOrdered'] },
22
+ },
23
+ {
24
+ id: "linearOrderedRange",
25
+ // isA: ['number'],
26
+ before: ['preposition'],
27
+ selector: {
28
+ match: "applicable",
29
+ left: [ { pattern: '(@<= linearlyOrdered && @<=contexts[1].rangeableWith)' } ],
30
+ right: [ { pattern: '(@<= linearlyOrdered && @<=contexts[-1].rangeableWith)' } ],
31
+ passthrough: true
32
+ },
33
+ enhanced_associations: false,
34
+ bridge: `{
35
+ ...next(operator),
36
+ localHierarchy: [before[0].marker.id],
37
+ operator: operator,
38
+ ...project(before[0], default(before[0].floaters, [])),
39
+ instance: or(before[0].instance, after[0].instance),
40
+ from: before[0],
41
+ to: after[0],
42
+ interpolate: [{ property: 'from' }, { property: 'operator' }, { property: 'to' }]
43
+ }`,
44
+ check: defaultContextCheckProperties(['to', 'from', 'types'])
45
+ },
46
+ ],
47
+ semantics: [
48
+ {
49
+ where: where(),
50
+ match: ({context, debug}) => context.marker == 'unify' && context.terms[0].marker == 'linearOrderedRange',
51
+ apply: async ({context, resolveEvaluate, compare, callId}) => {
52
+ const { from, to } = context.terms[0]
53
+ const value = context.terms[1]
54
+ const f = await compare(from, value)
55
+ const t = await compare(value, to)
56
+ if (f && t && f !== '>' && t !== '>') {
57
+ resolveEvaluate(context, value)
58
+ } else {
59
+ resolveEvaluate(context, false)
60
+ }
61
+ }
62
+ },
63
+ ],
64
+ };
65
+
66
+ function initializer({objects, config, isModule}) {
67
+ config.addArgs(
68
+ ({e, toEValue}) => ({
69
+ compare: async (left, right) => {
70
+ const v = await e({ marker: 'linearlyOrderedCompare', left, right })
71
+ if (v.evalue?.marker !== 'undefined') {
72
+ return v.evalue
73
+ }
74
+ }
75
+ })
76
+ )
77
+ }
78
+
79
+ knowledgeModule( {
80
+ config,
81
+ includes: [pos, gdefaults, sdefaults],
82
+ initializer,
83
+ instance,
84
+ module,
85
+ description: 'talking about linear orderings',
86
+ test: {
87
+ name: './linear_orderings.test.json',
88
+ contents: tests,
89
+ },
90
+ })
@@ -0,0 +1 @@
1
+ []
@@ -87,7 +87,23 @@
87
87
  "isA": [
88
88
  "mathematicalExpression"
89
89
  ],
90
- "evaluator": "async ({e, context}) => {\n const x = toValue(await e(context.x)) \n const y = toValue(await e(context.y))\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 }"
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
+ ],
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
  {
93
109
  "where": "/home/dev/code/theprogrammablemind/kms/common/math.js:33",
@@ -118,7 +134,23 @@
118
134
  "isA": [
119
135
  "mathematicalExpression"
120
136
  ],
121
- "evaluator": "async ({e, context}) => {\n const x = toValue(await e(context.x)) \n const y = toValue(await e(context.y))\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 }"
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
+ ],
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
  {
124
156
  "where": "/home/dev/code/theprogrammablemind/kms/common/math.js:33",
@@ -158,7 +190,23 @@
158
190
  "isA": [
159
191
  "mathematicalExpression"
160
192
  ],
161
- "evaluator": "async ({e, context}) => {\n const x = toValue(await e(context.x)) \n const y = toValue(await e(context.y))\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 }"
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
+ ],
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
  {
164
212
  "where": "/home/dev/code/theprogrammablemind/kms/common/math.js:33",
@@ -197,7 +245,29 @@
197
245
  "isA": [
198
246
  "mathematicalExpression"
199
247
  ],
200
- "evaluator": "async ({e, context}) => {\n const x = toValue(await e(context.x)) \n const y = toValue(await e(context.y))\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 }"
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
+ ],
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 }"
265
+ }
266
+ ],
267
+ "semantics": [
268
+ {
269
+ "match": "({context, isA, callId, isMany}) => {\n return context.marker == 'same' && isA(context.two, 'mathematicalExpression') && !isMany(context.one)\n }",
270
+ "apply": "({context}) => {\n // dont so the other one for is\n }"
201
271
  }
202
272
  ]
203
273
  }
@@ -541,6 +611,22 @@
541
611
  "bridge": "{ ...next(operator) }",
542
612
  "isA": [
543
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"
544
630
  ]
545
631
  },
546
632
  {
@@ -570,6 +656,22 @@
570
656
  "bridge": "{ ...next(operator) }",
571
657
  "isA": [
572
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"
573
675
  ]
574
676
  },
575
677
  {
@@ -608,6 +710,22 @@
608
710
  "bridge": "{ ...next(operator) }",
609
711
  "isA": [
610
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"
611
729
  ]
612
730
  },
613
731
  {
@@ -645,8 +763,27 @@
645
763
  "bridge": "{ ...next(operator) }",
646
764
  "isA": [
647
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"
648
782
  ]
649
783
  }
784
+ ],
785
+ "semantics": [
786
+ {}
650
787
  ]
651
788
  }
652
789
  ],
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,9 +47,10 @@ 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
- evaluator: async ({e, context}) => {
51
- const x = toValue(await e(context.x))
52
- const y = toValue(await e(context.y))
50
+ check: defaultContextCheckProperties(['x', 'y']),
51
+ semantic: async ({e, context}) => {
52
+ const x = toValue(await e(context.x, where()))
53
+ const y = toValue(await e(context.y, where()))
53
54
  if (!x || !y) {
54
55
  // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }
55
56
  context.isResponse = false
@@ -90,8 +91,6 @@ const config = {
90
91
  bridges: [
91
92
  {
92
93
  id: "mathematicalExpression",
93
- // isA: ['queryable', 'theAble'],
94
- //isA: ['concept', 'number'],
95
94
  isA: ['concept'],
96
95
  },
97
96
  {
@@ -107,6 +106,16 @@ const config = {
107
106
  ...mathematicalOperator('times', ['times', '*'], (x, y) => x * y, [['plusOperator', 0], ['minusOperator', 0]]),
108
107
  ...mathematicalOperator('divideBy', ['/'], (x, y) => x / y, [['plusOperator', 0], ['minusOperator', 0]]),
109
108
  ],
109
+ semantics: [
110
+ {
111
+ match: ({context, isA, callId, isMany}) => {
112
+ return context.marker == 'same' && isA(context.two, 'mathematicalExpression') && !isMany(context.one)
113
+ },
114
+ apply: ({context}) => {
115
+ // dont so the other one for is
116
+ }
117
+ },
118
+ ],
110
119
  };
111
120
 
112
121
  const template = {
@@ -129,7 +138,9 @@ knowledgeModule( {
129
138
  name: './math.test.json',
130
139
  contents: tests,
131
140
  checks: {
132
- context: [defaultContextCheck()],
141
+ context: [
142
+ defaultContextCheck()
143
+ ],
133
144
  }
134
145
  },
135
146
  })