ekms 8.0.0 → 8.1.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.
- package/common/animals.instance.json +3003 -1651
- package/common/animals.js +17 -20
- package/common/articles.js +103 -0
- package/common/articles.test.json +310 -0
- package/common/asking.instance.json +2 -0
- package/common/asking.js +253 -0
- package/common/asking.test.json +2290 -0
- package/common/avatar.js +6 -10
- package/common/characters.js +23 -30
- package/common/colors.instance.json +25513 -0
- package/common/colors.js +67 -0
- package/common/colors.test.json +4425 -0
- package/common/comparable.instance.json +1750 -0
- package/common/comparable.js +36 -28
- package/common/comparable.test.json +1196 -2
- package/common/concept.js +121 -119
- package/common/conjunction.instance.json +2 -0
- package/common/conjunction.js +104 -0
- package/common/conjunction.test.json +322 -0
- package/common/countable.js +20 -14
- package/common/countable.test.json +1050 -0
- package/common/crew.instance.json +16855 -9731
- package/common/crew.js +39 -42
- package/common/crew.test.json +714 -452
- package/common/currency.js +28 -46
- package/common/dialogues.js +177 -426
- package/common/dialogues.test.json +684 -450
- package/common/dimension.instance.json +508 -289
- package/common/dimension.js +22 -24
- package/common/dimension.test.json +727 -1944
- package/common/edible.instance.json +20548 -10848
- package/common/edible.js +4 -9
- package/common/emotions.instance.json +255 -123
- package/common/emotions.js +36 -39
- package/common/evaluate.instance.json +2 -0
- package/common/evaluate.js +53 -0
- package/common/evaluate.test.json +574 -0
- package/common/events.js +11 -15
- package/common/fastfood.instance.json +223039 -113390
- package/common/fastfood.js +77 -87
- package/common/fastfood.test.json +8205 -3733
- package/common/formulas.instance.json +444 -244
- package/common/formulas.js +20 -27
- package/common/formulas.test.json +1027 -955
- package/common/gdefaults.js +40 -27
- package/common/help.js +9 -14
- package/common/help.test.json +71 -18
- package/common/helpers/concept.js +33 -10
- package/common/helpers/dialogues.js +22 -4
- package/common/helpers/formulas.js +0 -14
- package/common/helpers/meta.js +0 -1
- package/common/helpers/properties.js +72 -76
- package/common/helpers.js +35 -24
- package/common/hierarchy.js +17 -25
- package/common/javascript.js +12 -19
- package/common/kirk.instance.json +586 -298
- package/common/kirk.js +6 -9
- package/common/length.instance.json +9158 -5124
- package/common/length.js +5 -9
- package/common/listener.js +48 -0
- package/common/listener.test.json +104 -0
- package/common/math.instance.json +409 -1202
- package/common/math.js +17 -21
- package/common/meta.js +24 -50
- package/common/nameable.instance.json +2 -0
- package/common/nameable.js +144 -0
- package/common/nameable.test.json +3191 -0
- package/common/negation.instance.json +2 -0
- package/common/negation.js +38 -0
- package/common/negation.test.json +308 -0
- package/common/numbers.js +28 -32
- package/common/ordering.instance.json +449 -273
- package/common/ordering.js +81 -87
- package/common/ordinals.instance.json +2 -0
- package/common/ordinals.js +60 -0
- package/common/ordinals.test.json +306 -0
- package/common/people.instance.json +2176 -1141
- package/common/people.js +9 -14
- package/common/percentages.instance.json +2 -0
- package/common/percentages.js +53 -0
- package/common/percentages.test.json +751 -0
- package/common/pipboy.instance.json +12120 -6879
- package/common/pipboy.js +53 -62
- package/common/pipboy.test.json +2835 -0
- package/common/pokemon.instance.json +4415 -2351
- package/common/pokemon.js +8 -21
- package/common/pos.js +16 -14
- package/common/pressure.instance.json +2348 -1373
- package/common/pressure.js +5 -9
- package/common/properties.instance.json +151 -87
- package/common/properties.js +156 -167
- package/common/properties.test.json +17605 -4030
- package/common/punctuation.js +24 -8
- package/common/punctuation.test.json +233 -5
- package/common/reports.instance.json +1027 -551
- package/common/reports.js +77 -103
- package/common/reports.test.json +15623 -10458
- package/common/scorekeeper.js +19 -31
- package/common/sdefaults.js +17 -8
- package/common/sizeable.js +13 -12
- package/common/spock.instance.json +585 -297
- package/common/spock.js +6 -9
- package/common/stgame.js +20 -20
- package/common/stm.js +182 -29
- package/common/stm.test.json +1734 -1
- package/common/tell.js +15 -19
- package/common/temperature.instance.json +2480 -1493
- package/common/temperature.js +5 -9
- package/common/tester.js +15 -4
- package/common/testing.js +8 -13
- package/common/time.js +21 -26
- package/common/tokenize.js +8 -8
- package/common/tokenize.test.json +86 -1
- package/common/ui.instance.json +151 -460
- package/common/ui.js +22 -34
- package/common/ui.test.json +641 -5357
- package/common/weight.instance.json +8072 -4490
- package/common/weight.js +5 -9
- package/common/weight.test.json +242 -238
- package/common/yesno.js +6 -6
- package/main.js +68 -45
- package/package.json +44 -6
package/common/math.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const dialogues = require('./dialogues')
|
4
4
|
const numbers = require('./numbers')
|
@@ -33,22 +33,22 @@ const mathematicalOperator = (name, words, apply, before = []) => [
|
|
33
33
|
id: `${name}Operator`, level: 0,
|
34
34
|
bridge: `{ ...next(operator), marker: next(operator('${name}Expression')), types: lub(append(['mathematicalExpression'], operator.types, before[0].types, after[0].types)), value: null, x: before[0], y: after[0], number: 'one', isResponse: true, evaluate: true }` ,
|
35
35
|
// bridge: `{ ...next(operator), marker: next(operator('${name}Expression')), value: null, x: before[0], y: after[0], number: 'one', isResponse: true, evaluate: true }` ,
|
36
|
-
isA: ['
|
36
|
+
isA: ['mathematical_operator'],
|
37
37
|
before,
|
38
38
|
localHierarchy: [ ['unknown', 'number'] ],
|
39
39
|
// levelSpecificHierarchy: [[1, 'mathematicalExpression']],
|
40
40
|
words,
|
41
|
-
generatorp: ({
|
41
|
+
generatorp: ({context}) => context.word,
|
42
42
|
},
|
43
43
|
{
|
44
44
|
where: where(),
|
45
45
|
id: `${name}Expression`, level: 0,
|
46
46
|
bridge: "{ ...next(operator) }" ,
|
47
47
|
isA: ['mathematicalExpression'],
|
48
|
-
generatorp: ({gp, context}) => `${gp(context.x)} ${context.word} ${gp(context.y)}`,
|
49
|
-
evaluator: ({e, context}) => {
|
50
|
-
const x = toValue(e(context.x))
|
51
|
-
const y = toValue(e(context.y))
|
48
|
+
generatorp: async ({gp, context}) => `${await gp(context.x)} ${context.word} ${await gp(context.y)}`,
|
49
|
+
evaluator: async ({e, context}) => {
|
50
|
+
const x = toValue(await e(context.x))
|
51
|
+
const y = toValue(await e(context.y))
|
52
52
|
if (!x || !y) {
|
53
53
|
// context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }
|
54
54
|
context.isResponse = false
|
@@ -69,11 +69,11 @@ const mathematicalOperator = (name, words, apply, before = []) => [
|
|
69
69
|
}
|
70
70
|
]
|
71
71
|
|
72
|
-
let
|
72
|
+
let config = {
|
73
73
|
name: 'math',
|
74
74
|
operators: [
|
75
75
|
"([mathematicalExpression])",
|
76
|
-
"([
|
76
|
+
"([mathematical_operator])",
|
77
77
|
"(([number|]) [plusOperator] ([number|]))",
|
78
78
|
"(([number|]) [minusOperator] ([number|]))",
|
79
79
|
"(([number|]) [timesOperator] ([number|]))",
|
@@ -92,8 +92,8 @@ let configStruct = {
|
|
92
92
|
isA: ['concept', 'number'],
|
93
93
|
},
|
94
94
|
{
|
95
|
-
id: "
|
96
|
-
before: ['
|
95
|
+
id: "mathematical_operator",
|
96
|
+
before: ['verb'],
|
97
97
|
after: ['adjective'],
|
98
98
|
},
|
99
99
|
{ id: "x", isA: ['number'], level: 0, bridge: '{ ...next(operator) }', development: true},
|
@@ -108,27 +108,23 @@ let configStruct = {
|
|
108
108
|
const template = {
|
109
109
|
configs: [
|
110
110
|
"mathematical modifies operator",
|
111
|
-
|
112
|
-
|
111
|
+
config,
|
112
|
+
// "* + / and - are mathematical operators",
|
113
113
|
]
|
114
114
|
}
|
115
115
|
|
116
|
-
const createConfig = () => {
|
117
|
-
const config = new Config({ name: 'math' }, module)
|
118
|
-
config.add(numbers(), dialogues(), punctuation(), countable(), comparable())
|
119
|
-
return config
|
120
|
-
}
|
121
|
-
|
122
116
|
knowledgeModule( {
|
117
|
+
config: { name: 'math' },
|
118
|
+
includes: [numbers, dialogues, punctuation, countable, comparable],
|
119
|
+
|
123
120
|
module,
|
124
|
-
createConfig,
|
125
121
|
description: 'talking about math',
|
126
122
|
template: { template, instance },
|
127
123
|
test: {
|
128
124
|
name: './math.test.json',
|
129
125
|
contents: tests,
|
130
126
|
checks: {
|
131
|
-
context: defaultContextCheck,
|
127
|
+
context: defaultContextCheck(),
|
132
128
|
},
|
133
129
|
|
134
130
|
},
|
package/common/meta.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, ensureTestFile, where, unflatten, flattens } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const _ = require('lodash')
|
4
4
|
const gdefaults = require('./gdefaults.js')
|
@@ -17,7 +17,7 @@ const template = {
|
|
17
17
|
};
|
18
18
|
|
19
19
|
// TODO -> if a car's top speed is over 200 mph then the car is fast
|
20
|
-
let
|
20
|
+
let config = {
|
21
21
|
name: 'meta',
|
22
22
|
operators: [
|
23
23
|
"((phrase) [means] (phrase))",
|
@@ -72,8 +72,6 @@ let configStruct = {
|
|
72
72
|
operator: "((synonym/*) [synonymOfWord|of] (word))",
|
73
73
|
bridge: "{ ...next(operator), word: after[0] }",
|
74
74
|
evaluator: ({context}) => {
|
75
|
-
debugger
|
76
|
-
debugger
|
77
75
|
}
|
78
76
|
},
|
79
77
|
*/
|
@@ -132,8 +130,8 @@ let configStruct = {
|
|
132
130
|
{
|
133
131
|
where: where(),
|
134
132
|
match: ({context}) => context.marker == 'orList' && context.paraphrase,
|
135
|
-
apply: ({context, gs}) => {
|
136
|
-
return gs(context.value, ', ', ' or ')
|
133
|
+
apply: async ({context, gs}) => {
|
134
|
+
return await gs(context.value, ', ', ' or ')
|
137
135
|
},
|
138
136
|
priority: -1,
|
139
137
|
},
|
@@ -141,10 +139,8 @@ let configStruct = {
|
|
141
139
|
priority: -1,
|
142
140
|
where: where(),
|
143
141
|
match: ({context}) => context.marker == 'means' && context.paraphrase,
|
144
|
-
apply: ({context, g}) => {
|
145
|
-
|
146
|
-
const before = g({ ...context.from, paraphrase: true})
|
147
|
-
return `${g({ ...context.from, paraphrase: true})} means ${g(context.to)}`
|
142
|
+
apply: async ({context, g}) => {
|
143
|
+
return `${await g({ ...context.from, paraphrase: true})} means ${await g(context.to)}`
|
148
144
|
}
|
149
145
|
},
|
150
146
|
{
|
@@ -162,8 +158,8 @@ let configStruct = {
|
|
162
158
|
{
|
163
159
|
where: where(),
|
164
160
|
match: ({context}) => context.marker === 'if',
|
165
|
-
apply: ({context, g}) => {
|
166
|
-
return `if ${g(context.antecedant)} then ${g(context.consequence)}`
|
161
|
+
apply: async ({context, g}) => {
|
162
|
+
return `if ${await g(context.antecedant)} then ${await g(context.consequence)}`
|
167
163
|
},
|
168
164
|
priority: -1,
|
169
165
|
},
|
@@ -184,10 +180,10 @@ let configStruct = {
|
|
184
180
|
{
|
185
181
|
where: where(),
|
186
182
|
match: ({context}) => context.marker == 'orList',
|
187
|
-
apply: ({context, s}) => {
|
183
|
+
apply: async ({context, s}) => {
|
188
184
|
const response = []
|
189
185
|
for (const value of context.value) {
|
190
|
-
response.push(s(value))
|
186
|
+
response.push(await s(value))
|
191
187
|
}
|
192
188
|
context.evalue = {
|
193
189
|
marker: 'orList',
|
@@ -207,7 +203,7 @@ let configStruct = {
|
|
207
203
|
const apply = (DEFINITIONs, DERIVED) => {
|
208
204
|
const mappingss = translationMappings(DEFINITIONs, DERIVED)
|
209
205
|
const invertMappings = (mappings) => mappings.map( ({ from, to }) => { return { to: from, from: to } } )
|
210
|
-
return ({context, s,
|
206
|
+
return async ({context, s, config}) => {
|
211
207
|
DEFINITIONs = _.cloneDeep(DEFINITIONs)
|
212
208
|
//const mappings = mappingss[0]
|
213
209
|
let toPrimes = []
|
@@ -217,8 +213,7 @@ let configStruct = {
|
|
217
213
|
}
|
218
214
|
// next move add debug arg to s and g
|
219
215
|
TO.query = true
|
220
|
-
toPrimes.push([s(TO), mappings])
|
221
|
-
// toPrime = s(TO, { debug: { apply: true } })
|
216
|
+
toPrimes.push([await s(TO), mappings])
|
222
217
|
}
|
223
218
|
|
224
219
|
let hasResponse = false
|
@@ -273,7 +268,7 @@ let configStruct = {
|
|
273
268
|
// match: match(context),
|
274
269
|
where: where(),
|
275
270
|
match: match(context),
|
276
|
-
apply: apply(antecedants, _.cloneDeep(context.consequence))
|
271
|
+
apply: apply(antecedants, _.cloneDeep(context.consequence)),
|
277
272
|
}
|
278
273
|
config.addSemantic(semantic)
|
279
274
|
}
|
@@ -282,17 +277,14 @@ let configStruct = {
|
|
282
277
|
notes: 'from means to where from is unknown',
|
283
278
|
where: where(),
|
284
279
|
match: ({context}) => context.marker == 'means' && context.from.marker == 'unknown',
|
285
|
-
apply: ({config, context, kms, e, isTest}) => {
|
280
|
+
apply: async ({config, context, kms, e, isTest}) => {
|
286
281
|
if (false && isTest) {
|
287
282
|
return
|
288
283
|
} else if (kms.dialogues) {
|
289
284
|
if (context.to.value) {
|
290
285
|
kms.stm.api.setVariable(context.from.value, context.to.value)
|
291
286
|
} else {
|
292
|
-
// config.addWord(context.from.word,
|
293
287
|
kms.dialogues.api.makeObject({ context: context.from, types: context.to.types || [], config });
|
294
|
-
// kms.dialogues.api.makeObject({ context: context.from, types: [], config });
|
295
|
-
// const r = e(context.to)
|
296
288
|
kms.stm.api.setVariable(context.from.value, context.to)
|
297
289
|
}
|
298
290
|
}
|
@@ -302,17 +294,17 @@ let configStruct = {
|
|
302
294
|
notes: 'x means y where x and y have known markers',
|
303
295
|
where: where(),
|
304
296
|
match: ({context}) => context.marker == 'means',
|
305
|
-
apply: ({config, context, g}) => {
|
297
|
+
apply: async ({config, context, g}) => {
|
306
298
|
// setup the write semantic
|
307
299
|
{
|
308
300
|
const matchByMarker = (defContext) => ({context}) => context.marker == defContext.from.marker && !context.query && !context.objects
|
309
301
|
const matchByValue = (defContext) => ({context}) => context.evalue == defContext.from.value && !context.query && !context.objects
|
310
|
-
const apply = (mappings, TO) => ({context, s}) => {
|
302
|
+
const apply = (mappings, TO) => async ({context, s}) => {
|
311
303
|
TO = _.cloneDeep(TO)
|
312
304
|
for (let { from, to } of mappings) {
|
313
305
|
hashIndexesSet(TO, to, hashIndexesGet(context, from))
|
314
306
|
}
|
315
|
-
toPrime = s(TO)
|
307
|
+
toPrime = await s(TO)
|
316
308
|
context.result = toPrime.result
|
317
309
|
}
|
318
310
|
const mappings = translationMapping(context.from, context.to)
|
@@ -334,7 +326,7 @@ let configStruct = {
|
|
334
326
|
{
|
335
327
|
const matchByMarker = (defContext) => ({context, uuid}) => context.marker == defContext.from.marker && (context.query || context.evaluate) && !context[`disable${uuid}`]
|
336
328
|
const matchByValue = (defContext) => ({context, uuid}) => context.value == defContext.from.value && (context.query || context.evaluate) && !context[`disable${uuid}`]
|
337
|
-
const apply = (mappings, TO) => ({uuid, context, s, g, config}) => {
|
329
|
+
const apply = (mappings, TO) => async ({uuid, context, s, g, config}) => {
|
338
330
|
TO = _.cloneDeep(TO)
|
339
331
|
for (let { from, to } of mappings) {
|
340
332
|
hashIndexesSet(TO, to, hashIndexesGet(context, from))
|
@@ -347,8 +339,7 @@ let configStruct = {
|
|
347
339
|
TO.evaluate = context.evaluate
|
348
340
|
}
|
349
341
|
TO[`disable${uuid}`] = true
|
350
|
-
|
351
|
-
toPrime = s(TO)
|
342
|
+
toPrime = await s(TO)
|
352
343
|
if (context.query) {
|
353
344
|
if (toPrime.evalue) {
|
354
345
|
context.evalue = toPrime.evalue
|
@@ -361,7 +352,7 @@ let configStruct = {
|
|
361
352
|
}
|
362
353
|
const mappings = translationMapping(context.from, context.to)
|
363
354
|
let match = matchByMarker(context)
|
364
|
-
context.metaInfo = `The mapping from from the expression being defined "${g({...context.from, paraphrase: true})}" to the definition phrase "${g({...context.to, paraphrase: true})}" is ${JSON.stringify(mappings)}`
|
355
|
+
context.metaInfo = `The mapping from from the expression being defined "${await g({...context.from, paraphrase: true})}" to the definition phrase "${await g({...context.to, paraphrase: true})}" is ${JSON.stringify(mappings)}`
|
365
356
|
if (context.from.value) {
|
366
357
|
match = matchByValue(context)
|
367
358
|
}
|
@@ -380,29 +371,12 @@ let configStruct = {
|
|
380
371
|
],
|
381
372
|
};
|
382
373
|
|
383
|
-
const createConfig = () => {
|
384
|
-
const config = new Config(configStruct, module)
|
385
|
-
config.stop_auto_rebuild()
|
386
|
-
config.add(gdefaults())
|
387
|
-
|
388
|
-
config.initializer( ({config, addGenerator, isModule}) => {
|
389
|
-
if (!isModule) {
|
390
|
-
addGenerator({
|
391
|
-
where: where(),
|
392
|
-
match: ({context}) => context.marker == 'unknown',
|
393
|
-
apply: ({context}) => `${context.word}`
|
394
|
-
})
|
395
|
-
}
|
396
|
-
})
|
397
|
-
|
398
|
-
config.restart_auto_rebuild()
|
399
|
-
return config
|
400
|
-
}
|
401
|
-
|
402
374
|
knowledgeModule({
|
375
|
+
config,
|
376
|
+
includes: [gdefaults],
|
377
|
+
|
403
378
|
module,
|
404
379
|
description: 'Ways of defining new language elements',
|
405
|
-
createConfig,
|
406
380
|
test: {
|
407
381
|
name: './meta.test.json',
|
408
382
|
contents: meta_tests,
|
@@ -410,7 +384,7 @@ knowledgeModule({
|
|
410
384
|
words: true,
|
411
385
|
},
|
412
386
|
checks: {
|
413
|
-
context: defaultContextCheck,
|
387
|
+
context: defaultContextCheck(),
|
414
388
|
},
|
415
389
|
|
416
390
|
},
|
@@ -0,0 +1,144 @@
|
|
1
|
+
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
|
+
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const helpers = require('./helpers')
|
4
|
+
const stm = require('./stm')
|
5
|
+
const nameable_tests = require('./nameable.test.json')
|
6
|
+
|
7
|
+
// TODO but "remember the m1\n call the m1 banana" <- the on the first one
|
8
|
+
|
9
|
+
class API {
|
10
|
+
initialize({ objects, km, kms }) {
|
11
|
+
this.objects = objects
|
12
|
+
this.objects.named = {}
|
13
|
+
}
|
14
|
+
|
15
|
+
// report is a context
|
16
|
+
setName(context, name) {
|
17
|
+
if (!context.stm) {
|
18
|
+
context.stm = {}
|
19
|
+
}
|
20
|
+
if (!context.stm.names) {
|
21
|
+
context.stm.names = []
|
22
|
+
}
|
23
|
+
context.stm.names.push(name)
|
24
|
+
}
|
25
|
+
|
26
|
+
get(type, name) {
|
27
|
+
return this.args.kms.stm.api.mentions({
|
28
|
+
context: type,
|
29
|
+
condition: (context) => {
|
30
|
+
if (context.stm && context.stm.names) {
|
31
|
+
return context.stm.names.includes(name)
|
32
|
+
}
|
33
|
+
}
|
34
|
+
})
|
35
|
+
}
|
36
|
+
|
37
|
+
getNamesByType(type) {
|
38
|
+
const contexts = this.args.kms.stm.api.getByType(type)
|
39
|
+
const names = new Set()
|
40
|
+
for (const context of contexts) {
|
41
|
+
if (context.stm.names) {
|
42
|
+
for (const name of context.stm.names) {
|
43
|
+
names.add(name)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
return [...names]
|
48
|
+
}
|
49
|
+
|
50
|
+
getNames(nameable) {
|
51
|
+
return (nameable.stm && nameable.stm.names) || []
|
52
|
+
}
|
53
|
+
|
54
|
+
/*
|
55
|
+
getNames() {
|
56
|
+
const current = this.current()
|
57
|
+
console.log('getReportNames current', JSON.stringify(current, null, 2))
|
58
|
+
return Object.keys(this.objects.namedReports).map( (name) => {
|
59
|
+
const selected = (current.names || []).includes(name)
|
60
|
+
return { name, selected, id: name }
|
61
|
+
})
|
62
|
+
}
|
63
|
+
*/
|
64
|
+
|
65
|
+
setCurrent(name) {
|
66
|
+
const context = this.objects.named[name]
|
67
|
+
if (context) {
|
68
|
+
this.args.km('stm').api.mentioned({ context })
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
const api = new API()
|
74
|
+
|
75
|
+
const config = {
|
76
|
+
name: 'nameable',
|
77
|
+
operators: [
|
78
|
+
// "([call] ([nameable]) (name))",
|
79
|
+
"([call] ([nameable]) (!@<=endOfSentence)*)",
|
80
|
+
{ pattern: "([getNamesByType] (type))", development: true },
|
81
|
+
{ pattern: "([m1])", development: true },
|
82
|
+
// { pattern: "([testPullFromContext] ([memorable]))", development: true }
|
83
|
+
],
|
84
|
+
words: {
|
85
|
+
literals: {
|
86
|
+
// "m1": [{"id": "memorable", development: true, "initial": "{ value: 'm1' }" }],
|
87
|
+
// "m2": [{"id": "memorable", development: true, "initial": "{ value: 'm2' }" }],
|
88
|
+
},
|
89
|
+
},
|
90
|
+
bridges: [
|
91
|
+
{
|
92
|
+
id: 'm1',
|
93
|
+
isA: ['memorable', 'nameable'],
|
94
|
+
development: true,
|
95
|
+
},
|
96
|
+
{
|
97
|
+
id: 'getNamesByType',
|
98
|
+
development: true,
|
99
|
+
isA: ['verb'],
|
100
|
+
bridge: "{ ...next(operator), type: after[0] }",
|
101
|
+
semantic: async ({context, api}) => {
|
102
|
+
context.response = api.getNamesByType(context.type.value).join(" ")
|
103
|
+
context.isResponse = true
|
104
|
+
}
|
105
|
+
},
|
106
|
+
{
|
107
|
+
id: 'call',
|
108
|
+
isA: ['verb'],
|
109
|
+
bridge: "{ ...next(operator), nameable: after[0], name: after[1:] }",
|
110
|
+
// bridge: "{ ...next(operator), nameable: after[0], name: after[1] }",
|
111
|
+
// generatorp: async ({context, g}) => `call ${await g(context.nameable)} ${await g(context.name)}`,
|
112
|
+
generatorp: async ({context, g, gs}) => `call ${await g(context.nameable)} ${await gs(context.name)}`,
|
113
|
+
semantic: async ({config, context, api, e}) => {
|
114
|
+
// TODO find report being referred to
|
115
|
+
const nameable = (await e(context.nameable)).evalue
|
116
|
+
const name = context.name.map((n) => n.text).join(' ')
|
117
|
+
// const name = context.name.text
|
118
|
+
config.addWord(name, { id: nameable.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
|
119
|
+
api.setName(nameable, name)
|
120
|
+
}
|
121
|
+
},
|
122
|
+
{ id: 'nameable', words: helpers.words('nameable')},
|
123
|
+
]
|
124
|
+
}
|
125
|
+
|
126
|
+
knowledgeModule( {
|
127
|
+
config,
|
128
|
+
api: () => new API(),
|
129
|
+
includes: [stm],
|
130
|
+
|
131
|
+
module,
|
132
|
+
description: 'namable objects',
|
133
|
+
test: {
|
134
|
+
name: './nameable.test.json',
|
135
|
+
contents: nameable_tests,
|
136
|
+
checks: {
|
137
|
+
context: [...defaultContextCheck(), 'pullFromContext'],
|
138
|
+
objects: ['mentioned', { km: 'stm' }],
|
139
|
+
},
|
140
|
+
include: {
|
141
|
+
words: [ "peter james chunkington", "banana" ],
|
142
|
+
}
|
143
|
+
},
|
144
|
+
})
|