ekms 9.5.0 → 9.5.1-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.
- package/common/asking.js +4 -4
- package/common/characters.js +2 -2
- package/common/crew.instance.json +47 -61
- package/common/crew.test.json +4148 -3324
- package/common/dialogues.js +1 -1
- package/common/dimension.instance.json +8 -8
- package/common/dimension.js +4 -4
- package/common/edible.instance.json +72 -0
- package/common/emotions.instance.json +26 -0
- package/common/emotions.test.json +242 -174
- package/common/english_helpers.js +126 -0
- package/common/errors.js +3 -3
- package/common/evaluate.js +2 -2
- package/common/events.js +8 -8
- package/common/fastfood.instance.json +242 -18
- package/common/formulas.js +1 -1
- package/common/gdefaults.js +19 -2
- package/common/help.js +1 -1
- package/common/helpers/meta.js +1 -1
- package/common/helpers/properties.js +91 -49
- package/common/helpers.js +53 -0
- package/common/latin.instance.json +2 -2
- package/common/latin.js +4 -4
- package/common/listener.js +1 -1
- package/common/math.instance.json +8 -8
- package/common/math.js +4 -4
- package/common/meta.js +27 -27
- package/common/nameable.js +7 -7
- package/common/ordering.instance.json +78 -0
- package/common/ordering.test.json +663 -233
- package/common/people.instance.json +26 -12
- package/common/people.js +5 -3
- package/common/people.test.json +4071 -3813
- package/common/pipboy.js +2 -3
- package/common/properties.js +6 -1
- package/common/reminders.instance.json +4 -4
- package/common/reminders.js +2 -2
- package/common/reports.instance.json +2 -2
- package/common/scorekeeper.js +2 -2
- package/common/stm.js +2 -2
- package/common/tokenize.js +4 -1
- package/common/wp.instance.json +74 -2
- package/package.json +4 -2
|
@@ -2,7 +2,7 @@ const pluralize = require('pluralize')
|
|
|
2
2
|
const { unflatten, flattens, Digraph } = require('../runtime').theprogrammablemind
|
|
3
3
|
const _ = require('lodash')
|
|
4
4
|
const deepEqual = require('deep-equal')
|
|
5
|
-
const { chooseNumber } = require('../helpers.js')
|
|
5
|
+
const { chooseNumber, removeProp } = require('../helpers.js')
|
|
6
6
|
const { Frankenhash } = require('./frankenhash.js')
|
|
7
7
|
const { compose, translationMapping, translationMappingToInstantiatorMappings } = require('./meta.js')
|
|
8
8
|
|
|
@@ -263,12 +263,33 @@ class API {
|
|
|
263
263
|
// relation -> the semantics will be implements using relations
|
|
264
264
|
// edable: "y is owned by x" edable = { operator: 'owned' }
|
|
265
265
|
createActionPrefix(args, semanticApply) {
|
|
266
|
-
const {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
const {
|
|
267
|
+
operator,
|
|
268
|
+
before=[],
|
|
269
|
+
after=[],
|
|
270
|
+
create:createInit=[],
|
|
271
|
+
hierarchy=[],
|
|
272
|
+
config,
|
|
273
|
+
localHierarchy=[],
|
|
274
|
+
relation,
|
|
275
|
+
ordering,
|
|
276
|
+
doAble,
|
|
277
|
+
words = [],
|
|
278
|
+
unflatten:unflattenArgs = [],
|
|
279
|
+
focusable = [],
|
|
280
|
+
edAble } = args;
|
|
281
|
+
|
|
282
|
+
const createToCanonical = (concept) => {
|
|
283
|
+
if (typeof concept == 'string') {
|
|
284
|
+
return { id: concept, isA: [] }
|
|
285
|
+
} else {
|
|
286
|
+
return { isA: [], ...concept }
|
|
287
|
+
}
|
|
288
|
+
}
|
|
270
289
|
|
|
271
|
-
|
|
290
|
+
const create = createInit.map(createToCanonical)
|
|
291
|
+
|
|
292
|
+
if (doAble) {
|
|
272
293
|
if (before.length != 1) {
|
|
273
294
|
throw "Expected exactly one before argument"
|
|
274
295
|
}
|
|
@@ -323,7 +344,7 @@ class API {
|
|
|
323
344
|
}
|
|
324
345
|
}
|
|
325
346
|
|
|
326
|
-
create.map( (id) => {
|
|
347
|
+
create.map( ({ id, isA }) => {
|
|
327
348
|
if (id === operator) {
|
|
328
349
|
const tagsToProps = (where, args, suffix='') => {
|
|
329
350
|
const i = 0;
|
|
@@ -341,13 +362,21 @@ class API {
|
|
|
341
362
|
afterArgs = tagsToProps('after', after, '*')
|
|
342
363
|
}
|
|
343
364
|
|
|
365
|
+
// const subjectContext = before[0].tag
|
|
366
|
+
// const interpolate = "[" + before.map((arg) => `{ property: '${arg.tag}' }`).concat(`{ ...operator, evaluateWord: true, number: ${subjectContext}.number }`).concat(after.map((arg) => `{ property: '${arg.tag}' }`)).join(',') + "]"
|
|
367
|
+
const imperative = (before.length == 0) ? "true" : "false"
|
|
368
|
+
// const interpolate = "[" + before.map((arg) => `{ property: '${arg.tag}' }`).concat(`{ ...operator, evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' }`).concat(after.map((arg) => `{ property: '${arg.tag}' }`)).join(',') + "]"
|
|
369
|
+
// const interpolateVerb = `{ property: "operator", context: { evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' } }`
|
|
370
|
+
const interpolateVerb = `{ property: "operator" }`
|
|
371
|
+
const interpolate = "[" + before.map((arg) => `{ property: '${arg.tag}' }`).concat(interpolateVerb).concat(after.map((arg) => `{ property: '${arg.tag}' }`)).join(',') + "]"
|
|
372
|
+
|
|
344
373
|
const unflattenArgs = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
|
345
374
|
const focusable = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
|
346
375
|
config.addBridge({
|
|
347
376
|
id: operator,
|
|
348
377
|
level: 0,
|
|
349
378
|
localHierarchy: [...localHierarchy, ['object', 'unknown']],
|
|
350
|
-
bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)} }`,
|
|
379
|
+
bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, operator: { ...operator, evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' }, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)}, interpolate: ${interpolate} }`,
|
|
351
380
|
allowDups: true
|
|
352
381
|
})
|
|
353
382
|
if (words.length > 0) {
|
|
@@ -360,6 +389,10 @@ class API {
|
|
|
360
389
|
} else {
|
|
361
390
|
config.addBridge({ id: id, allowDups: true })
|
|
362
391
|
}
|
|
392
|
+
|
|
393
|
+
for (const parentId of isA) {
|
|
394
|
+
config.addHierarchy(id, parentId)
|
|
395
|
+
}
|
|
363
396
|
})
|
|
364
397
|
|
|
365
398
|
if (words.length == 0) {
|
|
@@ -369,6 +402,10 @@ class API {
|
|
|
369
402
|
config.addWord(operatorPlural, { id: operator, initial: `{ value: '${operator}', number: 'many' }`})
|
|
370
403
|
}
|
|
371
404
|
|
|
405
|
+
for (const { child, parent } of hierarchy) {
|
|
406
|
+
config.addHierarchy(child, parent)
|
|
407
|
+
}
|
|
408
|
+
|
|
372
409
|
if (doAble) {
|
|
373
410
|
config.addHierarchy(operator, 'canBeDoQuestion')
|
|
374
411
|
}
|
|
@@ -376,49 +413,53 @@ class API {
|
|
|
376
413
|
config.addPriority({ "context": [[operator, 0], ['means', 0], ], "choose": [0] })
|
|
377
414
|
config.addPriority({ "context": [['article', 0], [operator, 0], ], "choose": [0] })
|
|
378
415
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
416
|
+
if (false) {
|
|
417
|
+
config.addGenerator({
|
|
418
|
+
notes: 'ordering generator for paraphrase',
|
|
419
|
+
match: ({context}) => context.marker == operator && context.paraphrase && !context.query,
|
|
420
|
+
apply: async ({context, gp, g}) => {
|
|
421
|
+
const beforeGenerator = []
|
|
422
|
+
for (const arg of before) {
|
|
423
|
+
beforeGenerator.push(await g(context[arg.tag]))
|
|
424
|
+
}
|
|
425
|
+
const afterGenerator = []
|
|
426
|
+
for (const arg of after) {
|
|
427
|
+
afterGenerator.push(await gp(context[arg.tag]))
|
|
428
|
+
}
|
|
429
|
+
const word = context.word
|
|
430
|
+
const sub = []
|
|
431
|
+
if (context.subphrase) {
|
|
432
|
+
sub.push(['that'])
|
|
433
|
+
}
|
|
434
|
+
return beforeGenerator.concat(sub).concat([word]).concat(afterGenerator).join(' ')
|
|
395
435
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
})
|
|
436
|
+
})
|
|
437
|
+
}
|
|
399
438
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (evalue.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
439
|
+
if (true) {
|
|
440
|
+
config.addGenerator({
|
|
441
|
+
notes: 'ordering generator for response',
|
|
442
|
+
match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
|
|
443
|
+
apply: async ({context, g, km}) => {
|
|
444
|
+
const brief = km("dialogues").api.getBrief()
|
|
445
|
+
|
|
446
|
+
const { evalue } = context
|
|
447
|
+
let yesno = ''
|
|
448
|
+
if (!context.do.query || evalue.truthValueOnly || brief) {
|
|
449
|
+
if (evalue.truthValue) {
|
|
450
|
+
yesno = 'yes'
|
|
451
|
+
} else if (evalue.truthValue === false) {
|
|
452
|
+
yesno = 'no'
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (evalue.truthValueOnly || brief) {
|
|
456
|
+
return `${yesno}`
|
|
457
|
+
} else {
|
|
458
|
+
return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
|
|
413
459
|
}
|
|
414
460
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
} else {
|
|
418
|
-
return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
})
|
|
461
|
+
})
|
|
462
|
+
}
|
|
422
463
|
|
|
423
464
|
if (ordering) {
|
|
424
465
|
config.addSemantic({
|
|
@@ -515,7 +556,7 @@ class API {
|
|
|
515
556
|
config.addSemantic({
|
|
516
557
|
notes: `getter for ${operator}`,
|
|
517
558
|
match: ({context}) => context.marker == operator && context.query,
|
|
518
|
-
apply: ({context, km}) => {
|
|
559
|
+
apply: ({context, km, callId}) => {
|
|
519
560
|
const api = km('properties').api
|
|
520
561
|
|
|
521
562
|
context.evalue = {
|
|
@@ -552,6 +593,8 @@ class API {
|
|
|
552
593
|
}
|
|
553
594
|
|
|
554
595
|
relation_add (relations) {
|
|
596
|
+
removeProp(relations, (val, prop, obj) => prop === 'range')
|
|
597
|
+
|
|
555
598
|
if (!Array.isArray(relations)) {
|
|
556
599
|
relations = [relations]
|
|
557
600
|
}
|
|
@@ -703,7 +746,6 @@ class API {
|
|
|
703
746
|
}
|
|
704
747
|
|
|
705
748
|
setProperty(object, property, value, has, skipHandler) {
|
|
706
|
-
// debugger
|
|
707
749
|
if (!skipHandler) {
|
|
708
750
|
const handler = this.propertiesFH.getHandler([object, property])
|
|
709
751
|
if (handler) {
|
package/common/helpers.js
CHANGED
|
@@ -263,6 +263,58 @@ const processTemplateString = async (template, evaluate) => {
|
|
|
263
263
|
return await processTemplateString(template)
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
+
// removeProp.js
|
|
267
|
+
function removeProp(obj, testFn, { maxDepth = Infinity, seen = new WeakSet() } = {}) {
|
|
268
|
+
if (!obj || typeof obj !== 'object' || maxDepth <= 0) return obj;
|
|
269
|
+
if (seen.has(obj)) return obj;
|
|
270
|
+
seen.add(obj);
|
|
271
|
+
|
|
272
|
+
if (Array.isArray(obj)) {
|
|
273
|
+
// ---- ARRAY: process each element (but don't remove elements unless testFn says so)
|
|
274
|
+
let writeIdx = 0;
|
|
275
|
+
for (let i = 0; i < obj.length; i++) {
|
|
276
|
+
const element = obj[i];
|
|
277
|
+
const shouldRemoveElement = testFn(element, i, obj);
|
|
278
|
+
|
|
279
|
+
if (shouldRemoveElement) {
|
|
280
|
+
// Remove the whole array element
|
|
281
|
+
if (element && typeof element === 'object') {
|
|
282
|
+
// Still walk inside it in case testFn wants side effects
|
|
283
|
+
removeProp(element, testFn, { maxDepth: maxDepth - 1, seen });
|
|
284
|
+
}
|
|
285
|
+
// Skip writing it back
|
|
286
|
+
} else {
|
|
287
|
+
// Keep element, but walk into it to remove inner props
|
|
288
|
+
removeProp(element, testFn, { maxDepth: maxDepth - 1, seen });
|
|
289
|
+
if (writeIdx !== i) {
|
|
290
|
+
obj[writeIdx] = element;
|
|
291
|
+
}
|
|
292
|
+
writeIdx++;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
obj.length = writeIdx;
|
|
296
|
+
return obj;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ---- OBJECT: iterate over own keys
|
|
300
|
+
const keys = Reflect.ownKeys(obj);
|
|
301
|
+
for (const key of keys) {
|
|
302
|
+
const val = obj[key];
|
|
303
|
+
const shouldRemove = testFn(val, key, obj);
|
|
304
|
+
|
|
305
|
+
if (shouldRemove) {
|
|
306
|
+
delete obj[key];
|
|
307
|
+
if (val && typeof val === 'object') {
|
|
308
|
+
removeProp(val, testFn, { maxDepth: maxDepth - 1, seen });
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
removeProp(val, testFn, { maxDepth: maxDepth - 1, seen });
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return obj;
|
|
316
|
+
}
|
|
317
|
+
|
|
266
318
|
module.exports = {
|
|
267
319
|
processTemplateString,
|
|
268
320
|
unshiftL,
|
|
@@ -284,4 +336,5 @@ module.exports = {
|
|
|
284
336
|
wordNumber,
|
|
285
337
|
requiredArgument,
|
|
286
338
|
isA,
|
|
339
|
+
removeProp,
|
|
287
340
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"apply": "({config}) => {\n config.addArgs(({config, api, isA}) => ({\n addLatinNoun: ({ id, nominative, genetive, development }) => {\n config.addOperator({ pattern: `([${id}|])`, development: development })\n config.addBridge({ id, isA: ['hierarchiable'] })\n const declensions = getDeclensions(nominative, genetive)\n for (const declension of declensions) {\n config.addWord(declension.word, { id, initial: { ...declension, development } })\n }\n }\n }))\n }"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
|
-
"apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus',
|
|
7
|
+
"apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus', scope: \"testing\" })\n addLatinNoun({ id: 'titus_person', nominative: 'titus', scope: \"testing\" })\n addLatinNoun({ id: 'pear_food', nominative: 'pirum', scope: \"testing\" })\n addLatinNoun({ id: 'table_latin', nominative: 'mensa', scope: \"testing\" })\n }"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"operators": [
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
"apply": "({config}) => {\n config.addArgs(({config, api, isA}) => ({\n addLatinNoun: ({ id, nominative, genetive, development }) => {\n config.addOperator({ pattern: `([${id}|])`, development: development })\n config.addBridge({ id, isA: ['hierarchiable'] })\n const declensions = getDeclensions(nominative, genetive)\n for (const declension of declensions) {\n config.addWord(declension.word, { id, initial: { ...declension, development } })\n }\n }\n }))\n }"
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
|
-
"apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus',
|
|
241
|
+
"apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus', scope: \"testing\" })\n addLatinNoun({ id: 'titus_person', nominative: 'titus', scope: \"testing\" })\n addLatinNoun({ id: 'pear_food', nominative: 'pirum', scope: \"testing\" })\n addLatinNoun({ id: 'table_latin', nominative: 'mensa', scope: \"testing\" })\n }"
|
|
242
242
|
},
|
|
243
243
|
{
|
|
244
244
|
"extraConfig": true,
|
package/common/latin.js
CHANGED
|
@@ -159,10 +159,10 @@ const template = {
|
|
|
159
159
|
}))
|
|
160
160
|
},
|
|
161
161
|
({addLatinNoun}) => {
|
|
162
|
-
addLatinNoun({ id: 'davus_person', nominative: 'davus',
|
|
163
|
-
addLatinNoun({ id: 'titus_person', nominative: 'titus',
|
|
164
|
-
addLatinNoun({ id: 'pear_food', nominative: 'pirum',
|
|
165
|
-
addLatinNoun({ id: 'table_latin', nominative: 'mensa',
|
|
162
|
+
addLatinNoun({ id: 'davus_person', nominative: 'davus', scope: "testing" })
|
|
163
|
+
addLatinNoun({ id: 'titus_person', nominative: 'titus', scope: "testing" })
|
|
164
|
+
addLatinNoun({ id: 'pear_food', nominative: 'pirum', scope: "testing" })
|
|
165
|
+
addLatinNoun({ id: 'table_latin', nominative: 'mensa', scope: "testing" })
|
|
166
166
|
},
|
|
167
167
|
config,
|
|
168
168
|
({addSuffix}) => addSuffix('que'),
|
package/common/listener.js
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"([divideByExpression|])",
|
|
17
17
|
{
|
|
18
18
|
"pattern": "([x])",
|
|
19
|
-
"
|
|
19
|
+
"scope": "testing"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"pattern": "([y])",
|
|
23
|
-
"
|
|
23
|
+
"scope": "testing"
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"bridges": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"level": 0,
|
|
49
49
|
"bridge": "{ ...next(operator) }",
|
|
50
|
-
"
|
|
50
|
+
"scope": "testing"
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"id": "y",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"level": 0,
|
|
58
58
|
"bridge": "{ ...next(operator) }",
|
|
59
|
-
"
|
|
59
|
+
"scope": "testing"
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"where": "/home/dev/code/theprogrammablemind/kms/common/math.js:32",
|
|
@@ -1088,11 +1088,11 @@
|
|
|
1088
1088
|
"([divideByExpression|])",
|
|
1089
1089
|
{
|
|
1090
1090
|
"pattern": "([x])",
|
|
1091
|
-
"
|
|
1091
|
+
"scope": "testing"
|
|
1092
1092
|
},
|
|
1093
1093
|
{
|
|
1094
1094
|
"pattern": "([y])",
|
|
1095
|
-
"
|
|
1095
|
+
"scope": "testing"
|
|
1096
1096
|
}
|
|
1097
1097
|
],
|
|
1098
1098
|
"bridges": [
|
|
@@ -1119,7 +1119,7 @@
|
|
|
1119
1119
|
],
|
|
1120
1120
|
"level": 0,
|
|
1121
1121
|
"bridge": "{ ...next(operator) }",
|
|
1122
|
-
"
|
|
1122
|
+
"scope": "testing"
|
|
1123
1123
|
},
|
|
1124
1124
|
{
|
|
1125
1125
|
"id": "y",
|
|
@@ -1128,7 +1128,7 @@
|
|
|
1128
1128
|
],
|
|
1129
1129
|
"level": 0,
|
|
1130
1130
|
"bridge": "{ ...next(operator) }",
|
|
1131
|
-
"
|
|
1131
|
+
"scope": "testing"
|
|
1132
1132
|
},
|
|
1133
1133
|
{
|
|
1134
1134
|
"where": "/home/dev/code/theprogrammablemind/kms/common/math.js:32",
|
package/common/math.js
CHANGED
|
@@ -82,8 +82,8 @@ const config = {
|
|
|
82
82
|
"([minusExpression|])",
|
|
83
83
|
"([timesExpression|])",
|
|
84
84
|
"([divideByExpression|])",
|
|
85
|
-
{ pattern: "([x])",
|
|
86
|
-
{ pattern: "([y])",
|
|
85
|
+
{ pattern: "([x])", scope: "testing" },
|
|
86
|
+
{ pattern: "([y])", scope: "testing" },
|
|
87
87
|
],
|
|
88
88
|
bridges: [
|
|
89
89
|
{
|
|
@@ -96,8 +96,8 @@ const config = {
|
|
|
96
96
|
before: ['verb'],
|
|
97
97
|
after: ['adjective'],
|
|
98
98
|
},
|
|
99
|
-
{ id: "x", isA: ['number'], level: 0, bridge: '{ ...next(operator) }',
|
|
100
|
-
{ id: "y", isA: ['number'], level: 0, bridge: '{ ...next(operator) }',
|
|
99
|
+
{ id: "x", isA: ['number'], level: 0, bridge: '{ ...next(operator) }', scope: "testing"},
|
|
100
|
+
{ id: "y", isA: ['number'], level: 0, bridge: '{ ...next(operator) }', scope: "testing"},
|
|
101
101
|
...mathematicalOperator('plus', ['plus', '+'], (x, y) => x + y),
|
|
102
102
|
...mathematicalOperator('minus', ['minus', '-'], (x, y) => x - y),
|
|
103
103
|
...mathematicalOperator('times', ['times', '*'], (x, y) => x * y, [['plusOperator', 0], ['minusOperator', 0]]),
|
package/common/meta.js
CHANGED
|
@@ -26,13 +26,13 @@ const config = {
|
|
|
26
26
|
"(([orAble|]) [orList|or] ([orAble|]))",
|
|
27
27
|
// "cats is the plural of cat"
|
|
28
28
|
// "is cat the plural of cats"
|
|
29
|
-
{ pattern: "([x])",
|
|
29
|
+
{ pattern: "([x])", scope: "testing" },
|
|
30
30
|
// if f x then g x
|
|
31
|
-
{ pattern: "([e])",
|
|
32
|
-
{ pattern: "([f])",
|
|
33
|
-
{ pattern: "([g])",
|
|
34
|
-
{ pattern: "([undefined])",
|
|
35
|
-
{ pattern: "([defined])",
|
|
31
|
+
{ pattern: "([e])", scope: "testing" },
|
|
32
|
+
{ pattern: "([f])", scope: "testing" },
|
|
33
|
+
{ pattern: "([g])", scope: "testing" },
|
|
34
|
+
{ pattern: "([undefined])", scope: "testing" },
|
|
35
|
+
{ pattern: "([defined])", scope: "testing" },
|
|
36
36
|
|
|
37
37
|
/*
|
|
38
38
|
if creating a new word make a motivation to ask if word is plura or singlar of anohter wordA
|
|
@@ -61,9 +61,9 @@ const config = {
|
|
|
61
61
|
// [['means', 0], ['is', 0]],
|
|
62
62
|
],
|
|
63
63
|
hierarchy: [
|
|
64
|
-
{ child: 'e', parent: 'orAble',
|
|
65
|
-
{ child: 'f', parent: 'orAble',
|
|
66
|
-
{ child: 'g', parent: 'ifAble',
|
|
64
|
+
{ child: 'e', parent: 'orAble', scope: "testing" },
|
|
65
|
+
{ child: 'f', parent: 'orAble', scope: "testing" },
|
|
66
|
+
{ child: 'g', parent: 'ifAble', scope: "testing" },
|
|
67
67
|
{ child: 'orAble', parent: 'ifAble' },
|
|
68
68
|
],
|
|
69
69
|
bridges: [
|
|
@@ -94,12 +94,12 @@ const config = {
|
|
|
94
94
|
{ id: "then", level: 0, bridge: "{ ...next(operator), consequence: after[0] }" },
|
|
95
95
|
{ id: "ifAble" },
|
|
96
96
|
{ id: "orAble" },
|
|
97
|
-
{ id: "x",
|
|
98
|
-
{ id: "e",
|
|
99
|
-
{ id: "f",
|
|
100
|
-
{ id: "g",
|
|
101
|
-
{ id: "undefined",
|
|
102
|
-
{ id: "defined",
|
|
97
|
+
{ id: "x", scope: "testing" },
|
|
98
|
+
{ id: "e", scope: "testing" },
|
|
99
|
+
{ id: "f", scope: "testing" },
|
|
100
|
+
{ id: "g", scope: "testing" },
|
|
101
|
+
{ id: "undefined", scope: "testing" },
|
|
102
|
+
{ id: "defined", scope: "testing" },
|
|
103
103
|
// { id: "testWord2", level: 0, bridge: "{ ...next(operator) }" },
|
|
104
104
|
],
|
|
105
105
|
version: '3',
|
|
@@ -107,12 +107,12 @@ const config = {
|
|
|
107
107
|
"literals": {
|
|
108
108
|
// 'testWord2': [{"id": "testWord2", "initial": "{ value: 'testWord2Value' }" }],
|
|
109
109
|
// TODO make this development and select out for module
|
|
110
|
-
// 'x': [{id: "x", initial: "{ value: 'x' }",
|
|
111
|
-
// 'f': [{id: "ifAble", initial: "{ word: 'f' }",
|
|
112
|
-
// 'g': [{id: "ifAble", initial: "{ word: 'g' }",
|
|
113
|
-
'f': [{id: "f", initial: "{ value: 'f', word: 'f' }",
|
|
114
|
-
'x': [{id: "x", initial: "{ value: 'x', word: 'x' }",
|
|
115
|
-
'gq': [{id: "g", initial: "{ word: 'gq', query: true }",
|
|
110
|
+
// 'x': [{id: "x", initial: "{ value: 'x' }", scope: "testing" }],
|
|
111
|
+
// 'f': [{id: "ifAble", initial: "{ word: 'f' }", scope: "testing" }],
|
|
112
|
+
// 'g': [{id: "ifAble", initial: "{ word: 'g' }", scope: "testing" }],
|
|
113
|
+
'f': [{id: "f", initial: "{ value: 'f', word: 'f' }", scope: "testing" }],
|
|
114
|
+
'x': [{id: "x", initial: "{ value: 'x', word: 'x' }", scope: "testing" }],
|
|
115
|
+
'gq': [{id: "g", initial: "{ word: 'gq', query: true }", scope: "testing" }],
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
generators: [
|
|
@@ -120,19 +120,19 @@ const config = {
|
|
|
120
120
|
where: where(),
|
|
121
121
|
match: ({context}) => context.marker == 'undefined',
|
|
122
122
|
apply: ({context}) => 'undefined',
|
|
123
|
-
|
|
123
|
+
scope: "testing",
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
where: where(),
|
|
127
127
|
match: ({context}) => context.marker == 'defined',
|
|
128
128
|
apply: ({context}) => 'defined',
|
|
129
|
-
|
|
129
|
+
scope: "testing",
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
where: where(),
|
|
133
133
|
match: ({context}) => context.evalue && !context.paraphrase,
|
|
134
134
|
apply: ({context}) => context.evalue.verbatim,
|
|
135
|
-
|
|
135
|
+
scope: "testing",
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
where: where(),
|
|
@@ -154,13 +154,13 @@ const config = {
|
|
|
154
154
|
where: where(),
|
|
155
155
|
match: ({context}) => context.marker === 'ifAble',
|
|
156
156
|
apply: ({context}) => context.value,
|
|
157
|
-
|
|
157
|
+
scope: "testing",
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
where: where(),
|
|
161
161
|
match: ({context}) => ['x', 'g', 'f', 'e', 'ifAble'].includes(context.marker),
|
|
162
162
|
apply: ({context}) => `${context.word}`,
|
|
163
|
-
|
|
163
|
+
scope: "testing",
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
166
|
where: where(),
|
|
@@ -182,7 +182,7 @@ const config = {
|
|
|
182
182
|
}
|
|
183
183
|
context.isResponse = true
|
|
184
184
|
},
|
|
185
|
-
|
|
185
|
+
scope: "testing",
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
188
|
where: where(),
|
package/common/nameable.js
CHANGED
|
@@ -77,25 +77,25 @@ const config = {
|
|
|
77
77
|
operators: [
|
|
78
78
|
// "([call] ([nameable]) (name))",
|
|
79
79
|
"([call] ([nameable]) (!@<=endOfSentence)*)",
|
|
80
|
-
{ pattern: "([getNamesByType] (type))",
|
|
81
|
-
{ pattern: "([m1])",
|
|
82
|
-
// { pattern: "([testPullFromContext] ([memorable]))",
|
|
80
|
+
{ pattern: "([getNamesByType] (type))", scope: "testing" },
|
|
81
|
+
{ pattern: "([m1])", scope: "testing" },
|
|
82
|
+
// { pattern: "([testPullFromContext] ([memorable]))", scope: "testing" }
|
|
83
83
|
],
|
|
84
84
|
words: {
|
|
85
85
|
literals: {
|
|
86
|
-
// "m1": [{"id": "memorable",
|
|
87
|
-
// "m2": [{"id": "memorable",
|
|
86
|
+
// "m1": [{"id": "memorable", scope: "testing", "initial": "{ value: 'm1' }" }],
|
|
87
|
+
// "m2": [{"id": "memorable", scope: "testing", "initial": "{ value: 'm2' }" }],
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
90
|
bridges: [
|
|
91
91
|
{
|
|
92
92
|
id: 'm1',
|
|
93
93
|
isA: ['memorable', 'nameable'],
|
|
94
|
-
|
|
94
|
+
scope: "testing",
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
id: 'getNamesByType',
|
|
98
|
-
|
|
98
|
+
scope: "testing",
|
|
99
99
|
isA: ['verb'],
|
|
100
100
|
bridge: "{ ...next(operator), type: after[0] }",
|
|
101
101
|
semantic: async ({context, api}) => {
|