ekms 9.6.1 → 9.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/actions.instance.json +99 -0
- package/common/actions.js +67 -0
- package/common/actions.test.json +656 -0
- package/common/angle.instance.json +20 -0
- package/common/colors.instance.json +0 -28
- package/common/compass.instance.json +15 -0
- package/common/dates.instance.json +0 -84
- package/common/dialogues.js +1 -1
- package/common/dimension.instance.json +96 -12
- package/common/dimension.js +12 -3
- package/common/drone.instance.json +10130 -1641
- package/common/drone.js +217 -71
- package/common/drone.test.json +192134 -3455
- package/common/drone_v1.instance.json +38 -31
- package/common/drone_v1.js +20 -15
- package/common/drone_v1.test.json +659 -389
- package/common/edible.instance.json +0 -128
- package/common/fastfood.instance.json +72 -392
- package/common/gdefaults.js +5 -1
- package/common/helpers/conjunction.js +9 -5
- package/common/helpers/drone.js +13 -1
- package/common/length.instance.json +135 -0
- package/common/nameable.js +63 -24
- package/common/nameable.test.json +3270 -3912
- package/common/ordinals.js +13 -0
- package/common/pipboy.instance.json +0 -56
- package/common/pressure.instance.json +20 -0
- package/common/properties.js +16 -6
- package/common/reports.instance.json +1 -1
- package/common/stm.js +119 -25
- package/common/temperature.instance.json +20 -0
- package/common/time.instance.json +45 -0
- package/common/time.test.json +3403 -0
- package/common/weight.instance.json +60 -0
- package/common/wp.instance.json +0 -56
- package/main.js +2 -0
- package/package.json +6 -2
package/common/stm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
|
1
|
+
const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const helpers = require('./helpers')
|
|
4
|
+
const helpers_conjunction = require('./helpers/conjunction')
|
|
4
5
|
const articles = require('./articles')
|
|
5
6
|
const evaluate = require('./evaluate')
|
|
6
7
|
const stm_tests = require('./stm.test.json')
|
|
@@ -68,37 +69,66 @@ class API {
|
|
|
68
69
|
concept.value = value
|
|
69
70
|
}
|
|
70
71
|
concept.fromSTM = true
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
concept.stm.id = this.getId()
|
|
76
|
-
}
|
|
77
|
-
frameOfReference.mentioned = (frameOfReference.mentioned || []).filter( (context) => context.stm && context.stm.id != concept.stm.id )
|
|
72
|
+
concept.namespaced ??= {}
|
|
73
|
+
concept.namespaced.stm ??= {}
|
|
74
|
+
concept.namespaced.stm.id ??= this.getId()
|
|
75
|
+
frameOfReference.mentioned = (frameOfReference.mentioned || []).filter( (context) => context.namespaced?.stm && context.namespaced.stm.id != concept.namespaced.stm.id )
|
|
78
76
|
helpers.unshiftL(frameOfReference.mentioned, concept, this.maximumMentioned)
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
mentions({ context, frameOfReference, useHierarchy=true, all, condition = (() => true) } = {}) {
|
|
82
|
-
|
|
79
|
+
mentions({ context, frameOfReference, useHierarchy=true, all, lastN, condition = (() => true) } = {}) {
|
|
80
|
+
let mentioned = this._objects.mentioned
|
|
81
|
+
let reversed = false
|
|
82
|
+
if (frameOfReference) {
|
|
83
|
+
if (frameOfReference.namespaced?.stm?.mentioned) {
|
|
84
|
+
mentioned = [...frameOfReference[frameOfReference.namespaced.stm.mentioned]]
|
|
85
|
+
if (frameOfReference.namespaced.stm.reversed) {
|
|
86
|
+
mentioned.reverse()
|
|
87
|
+
reversed = true
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (typeof frameOfReference?.mentioned == 'string') {
|
|
91
|
+
mentioned = frameOfReference[frameOfReference.mentioned]
|
|
92
|
+
} else {
|
|
93
|
+
mentioned = frameOfReference.mentioned
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!mentioned) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
83
100
|
const findPrevious = !!context.stm_previous
|
|
84
101
|
const forAll = []
|
|
85
102
|
function addForAll(context) {
|
|
86
|
-
if (!forAll.find( (c) => c.stm.id == context.stm.id)) {
|
|
87
|
-
|
|
103
|
+
if (!forAll.find( (c) => c.namespaced.stm.id == context.namespaced.stm.id)) {
|
|
104
|
+
if (reversed) {
|
|
105
|
+
forAll.unshift(context)
|
|
106
|
+
} else {
|
|
107
|
+
forAll.push(context)
|
|
108
|
+
}
|
|
88
109
|
}
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
// care about value first
|
|
92
113
|
let findCounter = 0
|
|
93
114
|
for (const m of mentioned) {
|
|
115
|
+
if (lastN === 0) {
|
|
116
|
+
break
|
|
117
|
+
}
|
|
94
118
|
if (context.value && (context.value == m.marker || context.value == m.value)) {
|
|
95
119
|
findCounter += 1
|
|
96
120
|
if (findPrevious && findCounter < 2) {
|
|
97
121
|
continue
|
|
98
122
|
}
|
|
123
|
+
if (context.nameable_named && m.nameable_named) {
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
99
126
|
if (condition(m)) {
|
|
100
|
-
if (all) {
|
|
101
|
-
|
|
127
|
+
if (all || lastN) {
|
|
128
|
+
addForAll(m)
|
|
129
|
+
if (lastN) {
|
|
130
|
+
lastN -= 1
|
|
131
|
+
}
|
|
102
132
|
} else {
|
|
103
133
|
return m
|
|
104
134
|
}
|
|
@@ -106,6 +136,10 @@ class API {
|
|
|
106
136
|
}
|
|
107
137
|
}
|
|
108
138
|
|
|
139
|
+
if (lastN === 0) {
|
|
140
|
+
return forAll
|
|
141
|
+
}
|
|
142
|
+
|
|
109
143
|
if (!useHierarchy) {
|
|
110
144
|
return
|
|
111
145
|
}
|
|
@@ -113,14 +147,23 @@ class API {
|
|
|
113
147
|
// care about marker second
|
|
114
148
|
findCounter = 0
|
|
115
149
|
for (const m of mentioned) {
|
|
150
|
+
if (lastN === 0) {
|
|
151
|
+
break
|
|
152
|
+
}
|
|
116
153
|
if (context.marker != 'unknown' && this.isA(m.marker, context.marker)) {
|
|
117
154
|
findCounter += 1
|
|
118
155
|
if (findPrevious && findCounter < 2) {
|
|
119
156
|
continue
|
|
120
157
|
}
|
|
158
|
+
if (context.nameable_named && m.nameable_named) {
|
|
159
|
+
continue
|
|
160
|
+
}
|
|
121
161
|
if (condition(m)) {
|
|
122
|
-
if (all) {
|
|
162
|
+
if (all || lastN) {
|
|
123
163
|
addForAll(m)
|
|
164
|
+
if (lastN) {
|
|
165
|
+
lastN -= 1
|
|
166
|
+
}
|
|
124
167
|
} else {
|
|
125
168
|
return m
|
|
126
169
|
}
|
|
@@ -134,8 +177,14 @@ class API {
|
|
|
134
177
|
if (findPrevious && findCounter < 2) {
|
|
135
178
|
continue
|
|
136
179
|
}
|
|
180
|
+
if (context.nameable_named && m.nameable_named) {
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
137
183
|
if (condition(m)) {
|
|
138
|
-
if (all) {
|
|
184
|
+
if (all || lastN) {
|
|
185
|
+
if (lastN) {
|
|
186
|
+
lastN -= 1
|
|
187
|
+
}
|
|
139
188
|
addForAll(m)
|
|
140
189
|
} else {
|
|
141
190
|
return m
|
|
@@ -146,17 +195,27 @@ class API {
|
|
|
146
195
|
}
|
|
147
196
|
}
|
|
148
197
|
|
|
198
|
+
if (lastN === 0) {
|
|
199
|
+
return forAll
|
|
200
|
+
}
|
|
201
|
+
|
|
149
202
|
findCounter = 0
|
|
150
203
|
if (context.types && context.types.length == 1) {
|
|
151
204
|
for (const m of mentioned) {
|
|
205
|
+
if (lastN === 0) {
|
|
206
|
+
break
|
|
207
|
+
}
|
|
152
208
|
if (context.unknown) {
|
|
153
209
|
findCounter += 1
|
|
154
210
|
if (findPrevious && findCounter < 2) {
|
|
155
211
|
continue
|
|
156
212
|
}
|
|
157
213
|
if (condition(m)) {
|
|
158
|
-
if (all) {
|
|
214
|
+
if (all || lastN) {
|
|
159
215
|
addForAll(m)
|
|
216
|
+
if (lastN) {
|
|
217
|
+
lastN -= 1
|
|
218
|
+
}
|
|
160
219
|
} else {
|
|
161
220
|
return m
|
|
162
221
|
}
|
|
@@ -165,13 +224,13 @@ class API {
|
|
|
165
224
|
}
|
|
166
225
|
}
|
|
167
226
|
|
|
168
|
-
if (all) {
|
|
227
|
+
if (all || lastN) {
|
|
169
228
|
return forAll
|
|
170
229
|
}
|
|
171
230
|
}
|
|
172
231
|
|
|
173
232
|
getVariable(context) {
|
|
174
|
-
if (!context) {
|
|
233
|
+
if (!context || context.marker == 'mentions') {
|
|
175
234
|
return
|
|
176
235
|
}
|
|
177
236
|
let valueNew = this.mentions({ context, useHierarchy: false, condition: (context) => context.isVariable })
|
|
@@ -237,19 +296,30 @@ const config = {
|
|
|
237
296
|
},
|
|
238
297
|
],
|
|
239
298
|
semantics: [
|
|
299
|
+
{
|
|
300
|
+
where: where(),
|
|
301
|
+
match: ({context}) => context.marker == 'mentions' && context.evaluate,
|
|
302
|
+
apply: ({context, kms, toList, resolveEvaluate}) => {
|
|
303
|
+
resolveEvaluate(context, kms.stm.api.mentions(context.args))
|
|
304
|
+
}
|
|
305
|
+
},
|
|
240
306
|
{
|
|
241
307
|
where: where(),
|
|
242
308
|
notes: 'pull from context',
|
|
243
309
|
// match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
|
|
244
310
|
match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
|
|
245
|
-
apply: async ({callId, context, kms, e, log, retry}) => {
|
|
246
|
-
context.value =
|
|
311
|
+
apply: async ({callId, mentions, toList, context, kms, e, log, retry}) => {
|
|
312
|
+
context.value = (await mentions({ context }))
|
|
313
|
+
if (Array.isArray(context.value)) {
|
|
314
|
+
context.value = toList(context.value)
|
|
315
|
+
}
|
|
316
|
+
|
|
247
317
|
if (!context.value) {
|
|
248
318
|
// retry()
|
|
249
319
|
context.evalue = { marker: 'answerNotKnown' }
|
|
250
320
|
return
|
|
251
321
|
}
|
|
252
|
-
|
|
322
|
+
|
|
253
323
|
const instance = await e(context.value)
|
|
254
324
|
if (instance.evalue && !instance.edefault) {
|
|
255
325
|
context.value = instance.evalue
|
|
@@ -263,12 +333,36 @@ const config = {
|
|
|
263
333
|
}
|
|
264
334
|
|
|
265
335
|
function initializer({config}) {
|
|
266
|
-
config.addArgs(({kms}) => ({
|
|
336
|
+
config.addArgs(({kms, e, toList}) => ({
|
|
267
337
|
mentioned: (args) => {
|
|
268
338
|
kms.stm.api.mentioned(args)
|
|
269
339
|
},
|
|
270
|
-
|
|
271
|
-
|
|
340
|
+
|
|
341
|
+
frameOfReference: (context, { mentioned, reversed } = {}) => {
|
|
342
|
+
context.namespaced ??= {}
|
|
343
|
+
context.namespaced.stm ??= {}
|
|
344
|
+
if (mentioned !== null) {
|
|
345
|
+
context.namespaced.stm.mentioned = mentioned // name of property that has the mentioned objects
|
|
346
|
+
}
|
|
347
|
+
if (reversed !== null) {
|
|
348
|
+
context.namespaced.stm.reversed = reversed // true iff the list is oldest first rather than newest first
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
mentions: async (args) => {
|
|
353
|
+
if (args.frameOfReference?.nameable_named) {
|
|
354
|
+
const result = await e(args.frameOfReference)
|
|
355
|
+
if (result.evalue) {
|
|
356
|
+
args.frameOfReference = result.evalue
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const result = await e({ marker: 'mentions', args })
|
|
361
|
+
// evalue will return the argument if there is no evalue. dont want that for this case
|
|
362
|
+
if (!result.evalue) {
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
return helpers_conjunction.asList(helpers.toEValue(result), true)
|
|
272
366
|
},
|
|
273
367
|
}))
|
|
274
368
|
}
|
|
@@ -343,6 +343,11 @@
|
|
|
343
343
|
"expression",
|
|
344
344
|
false
|
|
345
345
|
],
|
|
346
|
+
[
|
|
347
|
+
"forQuantity",
|
|
348
|
+
"preposition",
|
|
349
|
+
false
|
|
350
|
+
],
|
|
346
351
|
[
|
|
347
352
|
"forVariable",
|
|
348
353
|
"preposition",
|
|
@@ -2535,6 +2540,11 @@
|
|
|
2535
2540
|
"expression",
|
|
2536
2541
|
false
|
|
2537
2542
|
],
|
|
2543
|
+
[
|
|
2544
|
+
"forQuantity",
|
|
2545
|
+
"preposition",
|
|
2546
|
+
false
|
|
2547
|
+
],
|
|
2538
2548
|
[
|
|
2539
2549
|
"forVariable",
|
|
2540
2550
|
"preposition",
|
|
@@ -5657,6 +5667,11 @@
|
|
|
5657
5667
|
"unit_temperature",
|
|
5658
5668
|
false
|
|
5659
5669
|
],
|
|
5670
|
+
[
|
|
5671
|
+
"forQuantity",
|
|
5672
|
+
"preposition",
|
|
5673
|
+
false
|
|
5674
|
+
],
|
|
5660
5675
|
[
|
|
5661
5676
|
"forVariable",
|
|
5662
5677
|
"preposition",
|
|
@@ -9086,6 +9101,11 @@
|
|
|
9086
9101
|
"unit_temperature",
|
|
9087
9102
|
false
|
|
9088
9103
|
],
|
|
9104
|
+
[
|
|
9105
|
+
"forQuantity",
|
|
9106
|
+
"preposition",
|
|
9107
|
+
false
|
|
9108
|
+
],
|
|
9089
9109
|
[
|
|
9090
9110
|
"forVariable",
|
|
9091
9111
|
"preposition",
|
|
@@ -494,6 +494,11 @@
|
|
|
494
494
|
"expression",
|
|
495
495
|
false
|
|
496
496
|
],
|
|
497
|
+
[
|
|
498
|
+
"forQuantity",
|
|
499
|
+
"preposition",
|
|
500
|
+
false
|
|
501
|
+
],
|
|
497
502
|
[
|
|
498
503
|
"forVariable",
|
|
499
504
|
"preposition",
|
|
@@ -3785,6 +3790,11 @@
|
|
|
3785
3790
|
"expression",
|
|
3786
3791
|
false
|
|
3787
3792
|
],
|
|
3793
|
+
[
|
|
3794
|
+
"forQuantity",
|
|
3795
|
+
"preposition",
|
|
3796
|
+
false
|
|
3797
|
+
],
|
|
3788
3798
|
[
|
|
3789
3799
|
"forVariable",
|
|
3790
3800
|
"preposition",
|
|
@@ -6426,6 +6436,11 @@
|
|
|
6426
6436
|
"expression",
|
|
6427
6437
|
false
|
|
6428
6438
|
],
|
|
6439
|
+
[
|
|
6440
|
+
"forQuantity",
|
|
6441
|
+
"preposition",
|
|
6442
|
+
false
|
|
6443
|
+
],
|
|
6429
6444
|
[
|
|
6430
6445
|
"forVariable",
|
|
6431
6446
|
"preposition",
|
|
@@ -9067,6 +9082,11 @@
|
|
|
9067
9082
|
"expression",
|
|
9068
9083
|
false
|
|
9069
9084
|
],
|
|
9085
|
+
[
|
|
9086
|
+
"forQuantity",
|
|
9087
|
+
"preposition",
|
|
9088
|
+
false
|
|
9089
|
+
],
|
|
9070
9090
|
[
|
|
9071
9091
|
"forVariable",
|
|
9072
9092
|
"preposition",
|
|
@@ -11708,6 +11728,11 @@
|
|
|
11708
11728
|
"expression",
|
|
11709
11729
|
false
|
|
11710
11730
|
],
|
|
11731
|
+
[
|
|
11732
|
+
"forQuantity",
|
|
11733
|
+
"preposition",
|
|
11734
|
+
false
|
|
11735
|
+
],
|
|
11711
11736
|
[
|
|
11712
11737
|
"forVariable",
|
|
11713
11738
|
"preposition",
|
|
@@ -14349,6 +14374,11 @@
|
|
|
14349
14374
|
"expression",
|
|
14350
14375
|
false
|
|
14351
14376
|
],
|
|
14377
|
+
[
|
|
14378
|
+
"forQuantity",
|
|
14379
|
+
"preposition",
|
|
14380
|
+
false
|
|
14381
|
+
],
|
|
14352
14382
|
[
|
|
14353
14383
|
"forVariable",
|
|
14354
14384
|
"preposition",
|
|
@@ -16990,6 +17020,11 @@
|
|
|
16990
17020
|
"expression",
|
|
16991
17021
|
false
|
|
16992
17022
|
],
|
|
17023
|
+
[
|
|
17024
|
+
"forQuantity",
|
|
17025
|
+
"preposition",
|
|
17026
|
+
false
|
|
17027
|
+
],
|
|
16993
17028
|
[
|
|
16994
17029
|
"forVariable",
|
|
16995
17030
|
"preposition",
|
|
@@ -19631,6 +19666,11 @@
|
|
|
19631
19666
|
"expression",
|
|
19632
19667
|
false
|
|
19633
19668
|
],
|
|
19669
|
+
[
|
|
19670
|
+
"forQuantity",
|
|
19671
|
+
"preposition",
|
|
19672
|
+
false
|
|
19673
|
+
],
|
|
19634
19674
|
[
|
|
19635
19675
|
"forVariable",
|
|
19636
19676
|
"preposition",
|
|
@@ -22272,6 +22312,11 @@
|
|
|
22272
22312
|
"expression",
|
|
22273
22313
|
false
|
|
22274
22314
|
],
|
|
22315
|
+
[
|
|
22316
|
+
"forQuantity",
|
|
22317
|
+
"preposition",
|
|
22318
|
+
false
|
|
22319
|
+
],
|
|
22275
22320
|
[
|
|
22276
22321
|
"forVariable",
|
|
22277
22322
|
"preposition",
|