ekms 8.0.0-beta.9 → 8.0.0-beta.90
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 +2915 -1553
- 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 -29
- package/common/colors.instance.json +7487 -4114
- package/common/colors.js +5 -9
- package/common/colors.test.json +345 -780
- 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 +13553 -7026
- package/common/crew.js +37 -42
- package/common/crew.test.json +714 -452
- package/common/currency.js +28 -46
- package/common/dialogues.js +150 -426
- package/common/dialogues.test.json +0 -786
- package/common/dimension.instance.json +491 -262
- package/common/dimension.js +22 -24
- package/common/dimension.test.json +508 -1702
- package/common/edible.instance.json +20446 -10806
- package/common/edible.js +4 -9
- package/common/emotions.instance.json +192 -124
- 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 +222642 -113618
- package/common/fastfood.js +76 -86
- package/common/fastfood.test.json +268 -90
- package/common/formulas.instance.json +443 -247
- package/common/formulas.js +20 -27
- package/common/gdefaults.js +40 -27
- package/common/help.js +9 -14
- package/common/help.test.json +65 -16
- package/common/helpers/concept.js +10 -7
- package/common/helpers/dialogues.js +5 -3
- package/common/helpers/properties.js +67 -64
- package/common/helpers.js +35 -24
- package/common/hierarchy.js +17 -25
- package/common/javascript.js +12 -19
- package/common/kirk.instance.json +583 -299
- package/common/kirk.js +6 -9
- package/common/length.instance.json +9005 -5001
- package/common/length.js +5 -9
- package/common/listener.js +48 -0
- package/common/listener.test.json +104 -0
- package/common/math.instance.json +406 -1178
- package/common/math.js +17 -21
- package/common/meta.js +24 -48
- package/common/nameable.instance.json +2 -0
- package/common/nameable.js +144 -0
- package/common/nameable.test.json +3191 -0
- package/common/negation.js +11 -7
- package/common/numbers.js +28 -32
- package/common/ordering.instance.json +443 -343
- 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 +2210 -1150
- 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 +11845 -6590
- package/common/pipboy.js +51 -62
- package/common/pokemon.instance.json +4300 -2285
- package/common/pokemon.js +8 -21
- package/common/pos.js +16 -14
- package/common/pressure.instance.json +2325 -1340
- package/common/pressure.js +5 -9
- package/common/properties.instance.json +148 -88
- package/common/properties.js +149 -160
- package/common/punctuation.js +16 -8
- package/common/reports.instance.json +1019 -551
- package/common/reports.js +77 -101
- package/common/reports.test.json +15623 -10458
- package/common/scorekeeper.js +19 -31
- package/common/sdefaults.js +17 -8
- package/common/sizeable.js +7 -11
- package/common/spock.instance.json +582 -298
- package/common/spock.js +6 -9
- package/common/stgame.js +20 -20
- package/common/stm.js +173 -31
- package/common/stm.test.json +1734 -1
- package/common/tell.js +15 -19
- package/common/temperature.instance.json +2430 -1429
- package/common/temperature.js +5 -9
- package/common/tester.js +15 -4
- package/common/testing.js +8 -12
- package/common/time.js +21 -26
- package/common/tokenize.js +6 -7
- package/common/ui.instance.json +150 -463
- package/common/ui.js +22 -33
- package/common/ui.test.json +641 -5357
- package/common/weight.instance.json +8034 -4503
- package/common/weight.js +5 -9
- package/common/yesno.js +6 -6
- package/main.js +20 -4
- package/package.json +37 -6
@@ -45,6 +45,10 @@ class API {
|
|
45
45
|
}
|
46
46
|
|
47
47
|
if (km('concept')) {
|
48
|
+
if (!km('concept').api) {
|
49
|
+
debugger
|
50
|
+
debugger
|
51
|
+
}
|
48
52
|
km('concept').api.addDefaultTypesForObjectHierarchy([
|
49
53
|
'theAble',
|
50
54
|
'queryable',
|
@@ -136,7 +140,7 @@ class API {
|
|
136
140
|
notes: 'semantic for setting value with constraint',
|
137
141
|
match: ({context, isA}) => isA(context.marker, after[0].tag) && context.evaluate && context.constraints,
|
138
142
|
// match: ({context, isA}) => context.marker == after[0].tag && context.evaluate,
|
139
|
-
apply: ({km, context, e, log, isA
|
143
|
+
apply: async ({km, context, e, log, isA}) => {
|
140
144
|
const constraint = context.constraints[0];
|
141
145
|
const value = constraint.constraint;
|
142
146
|
let property = constraint.property;
|
@@ -151,7 +155,7 @@ class API {
|
|
151
155
|
// value.greg = true
|
152
156
|
// value.ownee.query = true
|
153
157
|
value.query = true
|
154
|
-
let instance = e(value)
|
158
|
+
let instance = await e(value)
|
155
159
|
if (instance.verbatim) {
|
156
160
|
context.evalue = { verbatim: instance.verbatim }
|
157
161
|
return
|
@@ -168,13 +172,13 @@ class API {
|
|
168
172
|
config.addGenerator({
|
169
173
|
notes: 'generator for constraint',
|
170
174
|
match: ({context}) => context.marker == edAble.operator && context.paraphrase && context.constrained,
|
171
|
-
apply: ({context, g}) => {
|
175
|
+
apply: async ({context, g}) => {
|
172
176
|
if (context[before[0].tag].marker == 'by') {
|
173
177
|
// the cat wendy owned
|
174
|
-
return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${g({...context[before[0].tag], paraphrase: true})}`
|
178
|
+
return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${await g({...context[before[0].tag], paraphrase: true})}`
|
175
179
|
} else {
|
176
180
|
// the cat owned by wendy
|
177
|
-
return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
|
181
|
+
return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', await g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
|
178
182
|
}
|
179
183
|
},
|
180
184
|
})
|
@@ -194,19 +198,19 @@ class API {
|
|
194
198
|
|
195
199
|
return false;
|
196
200
|
},
|
197
|
-
apply: ({context, g}) => {
|
201
|
+
apply: async ({context, g}) => {
|
198
202
|
const chosen = chooseNumber(context, word.singular, word.plural)
|
199
|
-
return `${g(context[before[0].tag])} ${chosen} ${g(context[after[0].tag])}`
|
203
|
+
return `${await g(context[before[0].tag])} ${chosen} ${await g(context[after[0].tag])}`
|
200
204
|
}
|
201
205
|
})
|
202
206
|
config.addGenerator({
|
203
207
|
match: ({context}) => context.marker == edAble.operator && context.isEd,
|
204
|
-
apply: ({context, g}) => {
|
208
|
+
apply: async ({context, g}) => {
|
205
209
|
const chosen = chooseNumber(context[after[0].tag], 'is', 'are')
|
206
210
|
if (context[before[0].tag].evalue && context[before[0].tag].evalue.marker == 'answerNotKnown') {
|
207
|
-
return g(context[before[0].tag])
|
211
|
+
return await g(context[before[0].tag])
|
208
212
|
}
|
209
|
-
return `${g(context[after[0].tag])} ${chosen} ${edAble.word} by ${g(context[before[0].tag])}`
|
213
|
+
return `${await g(context[after[0].tag])} ${chosen} ${edAble.word} by ${await g(context[before[0].tag])}`
|
210
214
|
}
|
211
215
|
})
|
212
216
|
/*
|
@@ -250,12 +254,10 @@ class API {
|
|
250
254
|
notes: `generator for who/what is X owned by`,
|
251
255
|
// match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == 'ownee' && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == 'owned' && context.one.constraints[0].constraint.owner.implicit,
|
252
256
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == after[0].tag && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == edAble.operator && context.one.constraints[0].constraint[before[0].tag].implicit,
|
253
|
-
apply: ({context, g, gs, callId}) => {
|
257
|
+
apply: async ({context, fragments, g, gs, callId}) => {
|
254
258
|
const isToFromM = [{"from":["one"],"to":["two"]},{"from":["two"],"to":["one"]}]
|
255
|
-
const fromF =
|
256
|
-
|
257
|
-
// const toF = config.fragment("owneeVar is owned by ownerVar")
|
258
|
-
const toF = config.fragment(thisIsVerbedByThat)
|
259
|
+
const fromF = fragments(whoIsWhatVerbedBy).contexts()[0]
|
260
|
+
const toF = fragments(thisIsVerbedByThat)
|
259
261
|
const to = toF.contexts()[0]
|
260
262
|
const tm = translationMapping(fromF, to)
|
261
263
|
/*
|
@@ -269,11 +271,11 @@ class API {
|
|
269
271
|
// const from = context.one.constraints[0].constraint
|
270
272
|
const from = context
|
271
273
|
const im = translationMappingToInstantiatorMappings(tmPrime, from, to)
|
272
|
-
const translation = toF.instantiate(im)
|
274
|
+
const translation = await toF.instantiate(im)
|
273
275
|
if (Array.isArray(translation)) {
|
274
|
-
return gs(translation)
|
276
|
+
return await gs(translation)
|
275
277
|
} else {
|
276
|
-
return g(translation)
|
278
|
+
return await g(translation)
|
277
279
|
}
|
278
280
|
}
|
279
281
|
}
|
@@ -314,7 +316,12 @@ class API {
|
|
314
316
|
allowDups: true,
|
315
317
|
})
|
316
318
|
// config.addOperator({ id: operator, level: 1, words: [operator] })
|
317
|
-
config.addBridge({
|
319
|
+
config.addBridge({
|
320
|
+
id: operator,
|
321
|
+
level: 1,
|
322
|
+
bridge: '{ ...next(operator) }',
|
323
|
+
allowDups: true,
|
324
|
+
})
|
318
325
|
config.addPriority({ "context": [['does', 0], [operator, 1], ], "choose": [0] })
|
319
326
|
config.addPriority({ "context": [['doesnt', 0], [operator, 1], ], "choose": [0] })
|
320
327
|
config.addPriority({ "context": [[operator, 0], ['does', 0], ], "choose": [0] })
|
@@ -353,7 +360,13 @@ class API {
|
|
353
360
|
|
354
361
|
const unflattenArgs = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
355
362
|
const focusable = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
356
|
-
config.addBridge({
|
363
|
+
config.addBridge({
|
364
|
+
id: operator,
|
365
|
+
level: 0,
|
366
|
+
localHierarchy: [...localHierarchy, ['object', 'unknown']],
|
367
|
+
bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)} }`,
|
368
|
+
allowDups: true
|
369
|
+
})
|
357
370
|
if (words.length > 0) {
|
358
371
|
for (const word of words) {
|
359
372
|
config.addWord(word, { id: operator, initial: `{ value: "${operator}" }` })
|
@@ -383,11 +396,16 @@ class API {
|
|
383
396
|
config.addGenerator({
|
384
397
|
notes: 'ordering generator for paraphrase',
|
385
398
|
match: ({context}) => context.marker == operator && context.paraphrase && !context.query,
|
386
|
-
apply: ({context, gp, g}) => {
|
387
|
-
const beforeGenerator =
|
388
|
-
|
399
|
+
apply: async ({context, gp, g}) => {
|
400
|
+
const beforeGenerator = []
|
401
|
+
for (const arg of before) {
|
402
|
+
beforeGenerator.push(await g(context[arg.tag]))
|
403
|
+
}
|
404
|
+
const afterGenerator = []
|
405
|
+
for (const arg of after) {
|
406
|
+
afterGenerator.push(await gp(context[arg.tag]))
|
407
|
+
}
|
389
408
|
const word = context.word
|
390
|
-
// return beforeGenerator.concat([`${context.word}`]).concat(afterGenerator).join(' ')
|
391
409
|
const sub = []
|
392
410
|
if (context.subphrase) {
|
393
411
|
sub.push(['that'])
|
@@ -399,7 +417,7 @@ class API {
|
|
399
417
|
config.addGenerator({
|
400
418
|
notes: 'ordering generator for response',
|
401
419
|
match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
|
402
|
-
apply: ({context, g, km}) => {
|
420
|
+
apply: async ({context, g, km}) => {
|
403
421
|
const brief = km("dialogues").api.getBrief()
|
404
422
|
|
405
423
|
const { evalue } = context
|
@@ -414,7 +432,7 @@ class API {
|
|
414
432
|
if (evalue.truthValueOnly || brief) {
|
415
433
|
return `${yesno}`
|
416
434
|
} else {
|
417
|
-
return `${yesno} ${g(Object.assign({}, evalue, { paraphrase: true }))}`
|
435
|
+
return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
|
418
436
|
}
|
419
437
|
}
|
420
438
|
})
|
@@ -628,8 +646,8 @@ class API {
|
|
628
646
|
setValue: ([object, property], value, has) => {
|
629
647
|
return this.setProperty(object, property, value, has, true)
|
630
648
|
},
|
631
|
-
getValue: ([object, property]) => {
|
632
|
-
return this.getPropertyDirectly(object, property)
|
649
|
+
getValue: async ([object, property]) => {
|
650
|
+
return await this.getPropertyDirectly(object, property)
|
633
651
|
},
|
634
652
|
})
|
635
653
|
}
|
@@ -645,16 +663,18 @@ class API {
|
|
645
663
|
error.code = 'ReadOnly'
|
646
664
|
throw error
|
647
665
|
},
|
648
|
-
getValue: ([object, property]) => {
|
649
|
-
return this.getPropertyDirectly(object, property)
|
666
|
+
getValue: async ([object, property]) => {
|
667
|
+
return await this.getPropertyDirectly(object, property)
|
650
668
|
},
|
651
669
|
})
|
652
670
|
this.propertiesFH.setHandler(path, handler)
|
653
671
|
}
|
654
672
|
|
655
|
-
|
673
|
+
/*
|
674
|
+
async getObject(object) {
|
656
675
|
return this.propertiesFH.getValue([object])
|
657
676
|
}
|
677
|
+
*/
|
658
678
|
|
659
679
|
getHandler(object, property) {
|
660
680
|
return this.propertiesFH.getHandler([object, property])
|
@@ -671,34 +691,33 @@ class API {
|
|
671
691
|
// return context.value
|
672
692
|
}
|
673
693
|
|
674
|
-
getProperty(object, property, g) {
|
694
|
+
async getProperty(object, property, g) {
|
675
695
|
object = this.toValue(object)
|
676
696
|
property = this.toValue(property)
|
677
697
|
const handler = this.propertiesFH.getHandler([object, property])
|
678
698
|
if (handler) {
|
679
|
-
return handler.getValue([object, property])
|
699
|
+
return await handler.getValue([object, property])
|
680
700
|
}
|
681
|
-
return this.getPropertyDirectly(object, property, g)
|
701
|
+
return await this.getPropertyDirectly(object, property, g)
|
682
702
|
}
|
683
703
|
|
684
|
-
getPropertyDirectly(object, property, g) {
|
704
|
+
async getPropertyDirectly(object, property, g) {
|
685
705
|
if (property == 'property') {
|
686
|
-
const objectProps = this.propertiesFH.getValue([object])
|
706
|
+
const objectProps = await this.propertiesFH.getValue([object])
|
687
707
|
const values = []
|
688
708
|
for (let key of Object.keys(objectProps)) {
|
689
709
|
if (objectProps[key].has) {
|
690
|
-
|
691
|
-
values.push(`${g(key)}: ${g({ ...objectProps[key].value, paraphrase: true })}`)
|
710
|
+
values.push(`${await g(key)}: ${await g({ ...objectProps[key].value, paraphrase: true })}`)
|
692
711
|
}
|
693
712
|
}
|
694
713
|
return { marker: 'list', value: values }
|
695
714
|
} else {
|
696
|
-
return this.propertiesFH.getValue([object, property]).value
|
715
|
+
return (await this.propertiesFH.getValue([object, property])).value
|
697
716
|
}
|
698
717
|
}
|
699
718
|
|
700
|
-
hasProperty(object, property, has) {
|
701
|
-
return this.propertiesFH.getValue([object, property]).has
|
719
|
+
async hasProperty(object, property, has) {
|
720
|
+
return (await this.propertiesFH.getValue([object, property])).has
|
702
721
|
}
|
703
722
|
|
704
723
|
setProperty(object, property, value, has, skipHandler) {
|
@@ -726,7 +745,7 @@ class API {
|
|
726
745
|
}
|
727
746
|
}
|
728
747
|
|
729
|
-
knownObject(object) {
|
748
|
+
async knownObject(object) {
|
730
749
|
if (object == 'property') {
|
731
750
|
return object
|
732
751
|
}
|
@@ -735,10 +754,10 @@ class API {
|
|
735
754
|
}
|
736
755
|
const path = [object]
|
737
756
|
// return this.knownPropertyNew(path)
|
738
|
-
return this.propertiesFH.knownProperty(path)
|
757
|
+
return await this.propertiesFH.knownProperty(path)
|
739
758
|
}
|
740
759
|
|
741
|
-
hasProperty(object, property) {
|
760
|
+
async hasProperty(object, property) {
|
742
761
|
if (property == 'property') {
|
743
762
|
return true;
|
744
763
|
}
|
@@ -748,7 +767,7 @@ class API {
|
|
748
767
|
const seen = [object];
|
749
768
|
while (todo.length > 0) {
|
750
769
|
const next = todo.pop();
|
751
|
-
if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
|
770
|
+
if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
|
752
771
|
return true
|
753
772
|
}
|
754
773
|
const parents = this._objects.parents[next] || [];
|
@@ -763,11 +782,11 @@ class API {
|
|
763
782
|
}
|
764
783
|
|
765
784
|
// NOT DONE
|
766
|
-
knownProperty(object, property) {
|
785
|
+
async knownProperty(object, property) {
|
767
786
|
object = this.toValue(object)
|
768
787
|
property = this.toValue(property)
|
769
788
|
if (property == 'property') {
|
770
|
-
const objectProps = this.propertiesFH.getValue([object])
|
789
|
+
const objectProps = await this.propertiesFH.getValue([object])
|
771
790
|
return !_.isEmpty(objectProps)
|
772
791
|
}
|
773
792
|
|
@@ -776,7 +795,7 @@ class API {
|
|
776
795
|
const seen = [object];
|
777
796
|
while (todo.length > 0) {
|
778
797
|
const next = todo.pop();
|
779
|
-
if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
|
798
|
+
if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
|
780
799
|
return true
|
781
800
|
}
|
782
801
|
const parents = this._objects.parents[next] || [];
|
@@ -911,22 +930,6 @@ class API {
|
|
911
930
|
|
912
931
|
set config(config) {
|
913
932
|
this._config = config
|
914
|
-
/*
|
915
|
-
const toJSON = (h) => {
|
916
|
-
if (h.child && h.parent) {
|
917
|
-
return h
|
918
|
-
} else {
|
919
|
-
return { child: h[0], parent: h[1] }
|
920
|
-
}
|
921
|
-
}
|
922
|
-
for (const tuple of [...config().config.hierarchy]) {
|
923
|
-
const h = toJSON(tuple);
|
924
|
-
// TODO should this notice development flag?
|
925
|
-
if (this.isOperator(h.child) && this.isOperator(h.parent)) {
|
926
|
-
this.rememberIsA(h.child, h.parent)
|
927
|
-
}
|
928
|
-
}
|
929
|
-
*/
|
930
933
|
}
|
931
934
|
|
932
935
|
get config() {
|
package/common/helpers.js
CHANGED
@@ -33,8 +33,8 @@ const getCount = (context) => {
|
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
|
-
const words = (
|
37
|
-
return [{ word: pluralize.singular(
|
36
|
+
const words = (word, additional = {}) => {
|
37
|
+
return [{ word: pluralize.singular(word), number: 'one', ...additional }, { word: pluralize.plural(word), number: 'many', ...additional }]
|
38
38
|
}
|
39
39
|
|
40
40
|
const isMany = (context) => {
|
@@ -63,6 +63,12 @@ const isMany = (context) => {
|
|
63
63
|
return false
|
64
64
|
}
|
65
65
|
|
66
|
+
const requiredArgument = (value, name) => {
|
67
|
+
if (!value) {
|
68
|
+
throw new Error(`${name} is a required argument`)
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
66
72
|
const chooseNumber = (context, one, many) => {
|
67
73
|
if (isMany(context)) {
|
68
74
|
return many;
|
@@ -131,31 +137,35 @@ const toEValue = (context) => {
|
|
131
137
|
return context;
|
132
138
|
}
|
133
139
|
|
134
|
-
const
|
135
|
-
const defaultContextCheck = [
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
140
|
+
const defaultContextCheckProperties = ['marker', 'text', 'verbatim', 'isResponse', { property: 'response', filter: ['marker', 'text', 'verbatim'] }]
|
141
|
+
const defaultContextCheck = (properties = []) => {
|
142
|
+
return [
|
143
|
+
...defaultContextCheckProperties,
|
144
|
+
...properties.map((property) => { return { property, filter: defaultContextCheckProperties } }),
|
145
|
+
(object) => {
|
146
|
+
if (typeof object.value == 'object') {
|
147
|
+
return { property: 'value', filter: defaultContextCheckProperties }
|
148
|
+
} else {
|
149
|
+
return 'value'
|
150
|
+
}
|
151
|
+
},
|
152
|
+
(object) => {
|
153
|
+
if (!Array.isArray(object.modifiers)) {
|
154
|
+
return
|
155
|
+
}
|
156
|
+
if (typeof object.modifiers[0] == 'object') {
|
157
|
+
return { property: 'modifiers', filter: defaultContextCheckProperties }
|
158
|
+
} else {
|
159
|
+
return 'modifiers'
|
160
|
+
}
|
161
|
+
},
|
162
|
+
{ property: 'modifiers', isPropertyList: true, filter: defaultContextCheckProperties }
|
163
|
+
]
|
164
|
+
}
|
156
165
|
|
157
166
|
module.exports = {
|
158
167
|
defaultContextCheck,
|
168
|
+
defaultContextCheckProperties,
|
159
169
|
toEValue,
|
160
170
|
millisecondsUntilHourOfDay,
|
161
171
|
indent,
|
@@ -167,4 +177,5 @@ module.exports = {
|
|
167
177
|
words,
|
168
178
|
propertyToArray,
|
169
179
|
wordNumber,
|
180
|
+
requiredArgument,
|
170
181
|
}
|
package/common/hierarchy.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const properties = require('./properties')
|
4
4
|
const hierarchy_tests = require('./hierarchy.test.json')
|
@@ -32,7 +32,7 @@ const getTypes = ( km, concept, instance ) => {
|
|
32
32
|
|
33
33
|
// TODO the types of rank are x y z ....
|
34
34
|
// TODO x is a kind of y
|
35
|
-
let
|
35
|
+
let config = {
|
36
36
|
name: 'hierarchy',
|
37
37
|
operators: [
|
38
38
|
// "([hierarchyAble|])",
|
@@ -61,7 +61,7 @@ let configStruct = {
|
|
61
61
|
notes: 'what type is pikachu',
|
62
62
|
where: where(),
|
63
63
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query && !['what'].includes(context.one.marker) && !['what'].includes(context.two.marker) && (context.one.query || context.two.query),
|
64
|
-
apply: ({context, hierarchy, km, log, e
|
64
|
+
apply: async ({context, hierarchy, km, log, e}) => {
|
65
65
|
const one = context.one;
|
66
66
|
const two = context.two;
|
67
67
|
let concept, value;
|
@@ -72,7 +72,7 @@ let configStruct = {
|
|
72
72
|
concept = two;
|
73
73
|
value = one;
|
74
74
|
}
|
75
|
-
let instance = e(value)
|
75
|
+
let instance = await e(value)
|
76
76
|
if (instance.verbatim) {
|
77
77
|
context.evalue = { verbatim: instance.verbatim }
|
78
78
|
context.isResponse = true
|
@@ -80,9 +80,6 @@ let configStruct = {
|
|
80
80
|
}
|
81
81
|
instance = getTypes(km, concept, instance)
|
82
82
|
|
83
|
-
// instance.focusable = ['one', 'two']
|
84
|
-
// concept = JSON.parse(JSON.stringify(value))
|
85
|
-
// greg
|
86
83
|
concept = _.cloneDeep(value)
|
87
84
|
concept.isQuery = undefined
|
88
85
|
|
@@ -106,10 +103,10 @@ let configStruct = {
|
|
106
103
|
notes: 'type of pikachu', // the types of type is the next one
|
107
104
|
where: where(),
|
108
105
|
match: ({context}) => context.marker == 'type' && context.evaluate && context.object && context.objects[context.objects.length-1].number == 'one' && pluralize.isSingular(context.objects[0].word),
|
109
|
-
apply: ({context, objects, e, gs, km, log
|
106
|
+
apply: async ({context, objects, e, gs, km, log}) => {
|
110
107
|
const concept = context.objects[0];
|
111
108
|
const value = context.objects[1];
|
112
|
-
let instance = e(value)
|
109
|
+
let instance = await e(value)
|
113
110
|
if (instance.verbatim) {
|
114
111
|
context.evalue = { verbatim: instance.verbatim }
|
115
112
|
return
|
@@ -135,14 +132,14 @@ let configStruct = {
|
|
135
132
|
}
|
136
133
|
return hierarchy.isA(context.marker, 'is') && context.query && args( { types: ['hierarchyAble', 'hierarchyAble'], properties: ['one', 'two'] } )
|
137
134
|
},
|
138
|
-
apply: ({context, km, objects, g}) => {
|
135
|
+
apply: async ({context, km, objects, g}) => {
|
139
136
|
const api = km('properties').api
|
140
137
|
const one = context.one
|
141
138
|
const two = context.two
|
142
139
|
const oneId = pluralize.singular(one.value);
|
143
140
|
if (!api.conceptExists(oneId)) {
|
144
141
|
context.evalue = {
|
145
|
-
verbatim: `I don't know about ${g({ ...one, paraphrase: true})}`
|
142
|
+
verbatim: `I don't know about ${await g({ ...one, paraphrase: true})}`
|
146
143
|
}
|
147
144
|
context.isResponse = true
|
148
145
|
return
|
@@ -150,7 +147,7 @@ let configStruct = {
|
|
150
147
|
const twoId = pluralize.singular(two.value);
|
151
148
|
if (!api.conceptExists(twoId)) {
|
152
149
|
context.evalue = {
|
153
|
-
verbatim: `I don't know about ${g({ ...two, paraphrase: true})}`
|
150
|
+
verbatim: `I don't know about ${await g({ ...two, paraphrase: true})}`
|
154
151
|
}
|
155
152
|
context.isResponse = true
|
156
153
|
return
|
@@ -201,7 +198,6 @@ let configStruct = {
|
|
201
198
|
},
|
202
199
|
{
|
203
200
|
notes: 'humans are mammels',
|
204
|
-
// match: ({context, listable}) => listable(context, 'unknown') && context.same,
|
205
201
|
where: where(),
|
206
202
|
match: ({context, listable, hierarchy, isA, callId}) => {
|
207
203
|
if (!context.same) {
|
@@ -270,7 +266,7 @@ let configStruct = {
|
|
270
266
|
notes: 'types of type', // what are the types of animals
|
271
267
|
where: where(),
|
272
268
|
match: ({context}) => context.marker == 'type' && context.evaluate && context.object,
|
273
|
-
apply: ({context, objects,
|
269
|
+
apply: ({context, objects, km, isA}) => {
|
274
270
|
const api = km('properties').api
|
275
271
|
const conceptApi = km('concept').api
|
276
272
|
const type = pluralize.singular(context.object.value);
|
@@ -288,23 +284,19 @@ let configStruct = {
|
|
288
284
|
]
|
289
285
|
};
|
290
286
|
|
291
|
-
const
|
292
|
-
const config = new Config(configStruct, module)
|
293
|
-
config.stop_auto_rebuild()
|
294
|
-
config.add(properties())
|
295
|
-
config.initializer( ({apis, hierarchy}) => {
|
287
|
+
const initializer = ({apis, hierarchy}) => {
|
296
288
|
apis('stm').addIsA( (child, parent) => {
|
297
289
|
return hierarchy.isA(child, parent)
|
298
290
|
})
|
299
|
-
}
|
300
|
-
config.restart_auto_rebuild()
|
301
|
-
return config
|
302
|
-
}
|
291
|
+
}
|
303
292
|
|
304
293
|
knowledgeModule( {
|
294
|
+
config,
|
295
|
+
includes: [properties],
|
296
|
+
initializer,
|
297
|
+
|
305
298
|
module,
|
306
299
|
description: 'hierarchy of objects',
|
307
|
-
createConfig,
|
308
300
|
test: {
|
309
301
|
name: './hierarchy.test.json',
|
310
302
|
contents: hierarchy_tests,
|
@@ -312,7 +304,7 @@ knowledgeModule( {
|
|
312
304
|
checks: {
|
313
305
|
objects: ['children', 'concept', 'parents', 'properties'],
|
314
306
|
checks: {
|
315
|
-
context: defaultContextCheck,
|
307
|
+
context: defaultContextCheck(),
|
316
308
|
},
|
317
309
|
|
318
310
|
},
|
package/common/javascript.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const dialogues = require('./dialogues')
|
4
4
|
const javascript_tests = require('./javascript.test.json')
|
5
5
|
|
6
|
-
let
|
6
|
+
let config = {
|
7
7
|
name: 'javascript',
|
8
8
|
operators: [
|
9
9
|
"((<let> ([variable|])) [assignment|] (value))",
|
@@ -36,14 +36,14 @@ let configStruct = {
|
|
36
36
|
{
|
37
37
|
where: where(),
|
38
38
|
match: ({context}) => context.marker == 'assignment' && context.paraphrase,
|
39
|
-
apply: ({context, g}) => `let ${g(context.variable)} = ${g(context.value)}`
|
39
|
+
apply: async ({context, g}) => `let ${await g(context.variable)} = ${await g(context.value)}`
|
40
40
|
},
|
41
41
|
{
|
42
42
|
where: where(),
|
43
43
|
match: ({context}) => context.marker == 'assignment' && context.isResponse,
|
44
|
-
apply: ({context, g}) => {
|
45
|
-
const value = g(context.variable)
|
46
|
-
return `${g(context.variable)} == ${g(context.value)}`
|
44
|
+
apply: async ({context, g}) => {
|
45
|
+
// const value = await g(context.variable)
|
46
|
+
return `${await g(context.variable)} == ${await g(context.value)}`
|
47
47
|
}
|
48
48
|
},
|
49
49
|
],
|
@@ -60,27 +60,20 @@ let configStruct = {
|
|
60
60
|
],
|
61
61
|
};
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
config.initializer( ({objects, uuid}) => {
|
63
|
+
knowledgeModule( {
|
64
|
+
config,
|
65
|
+
includes: [dialogues],
|
66
|
+
initializer: ({objects, uuid}) => {
|
69
67
|
objects.variables = {}
|
70
|
-
}
|
71
|
-
config.restart_auto_rebuild()
|
72
|
-
return config
|
73
|
-
}
|
68
|
+
},
|
74
69
|
|
75
|
-
knowledgeModule( {
|
76
70
|
module,
|
77
71
|
description: 'javascript interpreter',
|
78
|
-
createConfig,
|
79
72
|
test: {
|
80
73
|
name: './javascript.test.json',
|
81
74
|
contents: javascript_tests,
|
82
75
|
checks: {
|
83
|
-
context: defaultContextCheck,
|
76
|
+
context: defaultContextCheck(),
|
84
77
|
},
|
85
78
|
|
86
79
|
},
|