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/properties.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 meta = require('./meta')
|
@@ -79,7 +79,7 @@ const template = {
|
|
79
79
|
|
80
80
|
const api = new API();
|
81
81
|
|
82
|
-
let
|
82
|
+
let config = {
|
83
83
|
name: 'properties',
|
84
84
|
operators: [
|
85
85
|
"([hierarchyAble|])",
|
@@ -112,22 +112,29 @@ let configStruct = {
|
|
112
112
|
// ['concept', 'theAble'],
|
113
113
|
// ['concept', 'queryable'],
|
114
114
|
['unknown', 'hierarchyAble'],
|
115
|
-
['unknown', 'object'],
|
115
|
+
// ['unknown', 'object'],
|
116
116
|
['what', 'object'],
|
117
|
-
['hierarchyAble', 'queryable'],
|
118
|
-
['readonly', 'queryable'],
|
119
|
-
['
|
120
|
-
['
|
121
|
-
|
122
|
-
['property', '
|
123
|
-
['property', '
|
124
|
-
['
|
125
|
-
|
126
|
-
['
|
127
|
-
['
|
117
|
+
// ['hierarchyAble', 'queryable'],
|
118
|
+
// ['readonly', 'queryable'],
|
119
|
+
// ['object', 'queryable'],
|
120
|
+
// ['xfx', 'queryable'],
|
121
|
+
|
122
|
+
// ['property', 'queryable'],
|
123
|
+
// ['property', 'theAble'],
|
124
|
+
// ['property', 'unknown'],
|
125
|
+
|
126
|
+
// ['object', 'theAble'],
|
127
|
+
// ['whose', 'object'],
|
128
|
+
// ['have', 'canBeDoQuestion'],
|
129
|
+
// ['have', 'canBeQuestion'],
|
128
130
|
],
|
129
131
|
bridges: [
|
130
|
-
{
|
132
|
+
{
|
133
|
+
id: 'xfx',
|
134
|
+
level: 0,
|
135
|
+
isA: ['queryable'],
|
136
|
+
bridge: "{ ...next(operator) }"
|
137
|
+
},
|
131
138
|
{
|
132
139
|
id: 'between',
|
133
140
|
isA: ['preposition'],
|
@@ -136,7 +143,12 @@ let configStruct = {
|
|
136
143
|
},
|
137
144
|
{ id: 'between', level: 1, bridge: "{ ...before[0], arguments: operator.arguments }" },
|
138
145
|
|
139
|
-
{
|
146
|
+
{
|
147
|
+
id: 'hierarchyAble',
|
148
|
+
level: 0,
|
149
|
+
isA: ['queryable'],
|
150
|
+
bridge: "{ ...next(operator) }"
|
151
|
+
},
|
140
152
|
/*
|
141
153
|
{
|
142
154
|
id: "modifies",
|
@@ -144,32 +156,91 @@ let configStruct = {
|
|
144
156
|
bridge: "{ ...next(operator), modifier: before[0], concept: after[0] }"
|
145
157
|
},
|
146
158
|
*/
|
147
|
-
{
|
159
|
+
{
|
160
|
+
id: "readonly",
|
161
|
+
level: 0,
|
162
|
+
isA: ['queryable'],
|
163
|
+
bridge: "{ ...next(operator) }"
|
164
|
+
},
|
148
165
|
// { id: "concept", level: 0, bridge: "{ ...next(operator) }" },
|
149
166
|
// the cars dont have wings
|
150
167
|
// greg doesnt have wings
|
151
168
|
// { id: "doesnt", level: 0, bridge: "{ ...context, number: operator.number, negation: true }*" },
|
152
169
|
// { id: "doesnt", level: 0, bridge: "{ ...context, number: 'one', negation: true }*" },
|
153
170
|
{ id: "doesnt", level: 0, bridge: "{ ...context, number: operator.number, object.number: operator.number, negation: true }*" },
|
154
|
-
{
|
155
|
-
|
156
|
-
|
157
|
-
|
171
|
+
{
|
172
|
+
id: "have",
|
173
|
+
level: 0,
|
174
|
+
isA: ['canBeDoQuestion', 'canBeQuestion'],
|
175
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
|
176
|
+
bridge: "{ ...next(operator), object: { number: operator.number, ...before }, property: after[0], do: { left: 'object', right: 'property' } }"
|
177
|
+
},
|
178
|
+
{
|
179
|
+
id: "have",
|
180
|
+
level: 1,
|
181
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
|
182
|
+
bridge: "{ ...next(operator) }"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
id: "property",
|
186
|
+
words: ['properties'],
|
187
|
+
isA: ['queryable', 'theAble'],
|
188
|
+
level: 0,
|
189
|
+
bridge: "{ ...next(operator) }"
|
190
|
+
},
|
191
|
+
{
|
192
|
+
id: "object",
|
193
|
+
isA: ['queryable', 'theAble'],
|
194
|
+
level: 0,
|
195
|
+
bridge: "{ ...next(operator) }"
|
196
|
+
},
|
158
197
|
|
159
198
|
// old
|
160
199
|
// { id: "possession", level: 0, bridge: "{ ...next(operator), object: before[0] }" },
|
161
200
|
// { id: "possession", level: 1, bridge: "{ ...after[0], object: operator.object, marker: operator('property', 0) }" },
|
162
201
|
|
163
|
-
{
|
202
|
+
{
|
203
|
+
id: "possession",
|
204
|
+
level: 0,
|
205
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
|
206
|
+
inverted: true,
|
207
|
+
bridge: "{ ...next(operator), possession: true, object: before[0], objects: before }"
|
208
|
+
},
|
164
209
|
// greg44 { id: "possession", level: 1, inverted: true, bridge: "{ ...after[0], object: operator.object, possession: true, objects: append(default(after[0].objects, after), operator.objects), marker: operator('property', 0) }" },
|
165
|
-
{
|
210
|
+
{
|
211
|
+
id: "possession",
|
212
|
+
level: 1,
|
213
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
|
214
|
+
inverted: true,
|
215
|
+
bridge: "{ ...after[0], object: operator.object, possession: true, objects: append(default(after[0].objects, after), operator.objects), marker: after.marker, types: append(after[0].types, ['property']) }"
|
216
|
+
},
|
166
217
|
// TODO make object be after[0] that makes more sense
|
167
218
|
// { id: "possession", level: 1, inverted: true, bridge: "{ ...after[0], object: after[0], objects: append(default(after[0].objects, after), operator.objects), marker: operator('property', 0) }" },
|
168
219
|
|
169
|
-
{
|
170
|
-
|
171
|
-
|
172
|
-
|
220
|
+
{
|
221
|
+
id: "propertyOf",
|
222
|
+
level: 0,
|
223
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
|
224
|
+
bridge: "{ ...next(operator), object: after[0], objects: after }"
|
225
|
+
},
|
226
|
+
{
|
227
|
+
id: "propertyOf",
|
228
|
+
level: 1,
|
229
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
|
230
|
+
bridge: "{ ...before[0], object: operator.object, objects: append(default(before[0].objects, before), operator.objects) }"
|
231
|
+
},
|
232
|
+
{
|
233
|
+
id: "whose",
|
234
|
+
level: 0,
|
235
|
+
isA: ['object'],
|
236
|
+
bridge: '{ ...after[0], query: true, whose: "whose", modifiers: append(["whose"], after[0].modifiers)}'
|
237
|
+
},
|
238
|
+
{
|
239
|
+
id: "objectPrefix",
|
240
|
+
level: 0,
|
241
|
+
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
|
242
|
+
bridge: '{ ...after[0], object: operator, objects: [after[0], operator] }'
|
243
|
+
},
|
173
244
|
],
|
174
245
|
words: {
|
175
246
|
literals: {
|
@@ -216,7 +287,7 @@ let configStruct = {
|
|
216
287
|
notes: 'expression with constraints',
|
217
288
|
where: where(),
|
218
289
|
match: ({context}) => context.constraints && context.paraphrase,
|
219
|
-
apply: ({context, g}) => {
|
290
|
+
apply: async ({context, g}) => {
|
220
291
|
// TODO assume one constaints deal with more in the future
|
221
292
|
const constraint = context.constraints[0]
|
222
293
|
const constrained = Object.assign({}, constraint.constraint)
|
@@ -229,87 +300,25 @@ let configStruct = {
|
|
229
300
|
paraphrase.paraphrase = true;
|
230
301
|
paraphrase[constraint.property] = property
|
231
302
|
if (false && context.isResponse) {
|
232
|
-
return g({...constraint.paraphrase, paraphrase: true})
|
303
|
+
return await g({...constraint.paraphrase, paraphrase: true})
|
233
304
|
} else {
|
234
|
-
return g(constrained)
|
305
|
+
return await g(constrained)
|
235
306
|
}
|
236
307
|
},
|
237
308
|
},
|
238
309
|
{
|
239
310
|
where: where(),
|
240
311
|
match: ({context}) => context.marker == 'xfx',
|
241
|
-
apply: ({context, g}) => `${context.word} between ${g(context.arguments)}`
|
242
|
-
},
|
243
|
-
// {
|
244
|
-
// notes: '"fire type, water type and earth type" to "fire water and earth type"',
|
245
|
-
// tests: [
|
246
|
-
// 'chicken modifies strips',
|
247
|
-
// ],
|
248
|
-
// /*
|
249
|
-
// {
|
250
|
-
// "water": {
|
251
|
-
// "marker": "water",
|
252
|
-
// "value": "water",
|
253
|
-
// "word": "water"
|
254
|
-
// },
|
255
|
-
// "marker": "water_type",
|
256
|
-
// "modifiers": [
|
257
|
-
// "water"
|
258
|
-
// ],
|
259
|
-
// "types": [
|
260
|
-
// "water_type"
|
261
|
-
// ],
|
262
|
-
// "value": "water_type",
|
263
|
-
// "word": "type",
|
264
|
-
// "paraphrase": true
|
265
|
-
// },
|
266
|
-
// */
|
267
|
-
// where: where(),
|
268
|
-
// match: ({context}) => {
|
269
|
-
// // debugger;
|
270
|
-
// if (!context.paraphrase) {
|
271
|
-
// return
|
272
|
-
// }
|
273
|
-
// if (context.marker !== 'list') {
|
274
|
-
// return
|
275
|
-
// }
|
276
|
-
// if ((context.value || []).length < 2) {
|
277
|
-
// return
|
278
|
-
// }
|
279
|
-
// if (!context.value[0].word) {
|
280
|
-
// return
|
281
|
-
// }
|
282
|
-
// const word = context.value[0].word
|
283
|
-
|
284
|
-
// for (let value of context.value) {
|
285
|
-
// if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
|
286
|
-
// return
|
287
|
-
// }
|
288
|
-
// }
|
289
|
-
// return true
|
290
|
-
// },
|
291
|
-
// apply: ({g, context}) => {
|
292
|
-
// const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
|
293
|
-
// context.word = context.value[0].word
|
294
|
-
// context.value = null
|
295
|
-
// context.modifiers = ['modifier']
|
296
|
-
// context.modifier = {
|
297
|
-
// marker: 'list',
|
298
|
-
// paraphrase: true,
|
299
|
-
// value: modifiers
|
300
|
-
// }
|
301
|
-
// context.paraphrase = true
|
302
|
-
// return g(context)
|
303
|
-
// }
|
304
|
-
// },
|
312
|
+
apply: async ({context, g}) => `${context.word} between ${await g(context.arguments)}`
|
313
|
+
},
|
305
314
|
{
|
306
315
|
notes: 'add possession ending',
|
307
316
|
priority: -1,
|
308
317
|
where: where(),
|
309
318
|
match: ({context}) => context.paraphrase && context.possessive,
|
310
|
-
apply: ({context, g}) => {
|
319
|
+
apply: async ({context, g}) => {
|
311
320
|
context.possessive = false
|
312
|
-
const phrase = g(context)
|
321
|
+
const phrase = await g(context)
|
313
322
|
context.possessive = true
|
314
323
|
if (phrase.endsWith('s')) {
|
315
324
|
return `${phrase}'`
|
@@ -318,13 +327,6 @@ let configStruct = {
|
|
318
327
|
}
|
319
328
|
}
|
320
329
|
},
|
321
|
-
/*
|
322
|
-
{
|
323
|
-
where: where(),
|
324
|
-
match: ({context}) => context.marker == 'modifies' && context.paraphrase,
|
325
|
-
apply: ({context}) => `${context.modifier.word} modifies ${context.concept.word}`,
|
326
|
-
},
|
327
|
-
*/
|
328
330
|
{
|
329
331
|
where: where(),
|
330
332
|
match: ({context}) => context.marker == 'objectPrefix' && context.value == 'other' && context.paraphrase,
|
@@ -349,15 +351,8 @@ let configStruct = {
|
|
349
351
|
notes: 'negative do questions',
|
350
352
|
where: where(),
|
351
353
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.negation,
|
352
|
-
apply: ({context, g}) => {
|
353
|
-
|
354
|
-
let query = ''
|
355
|
-
if (context.query) {
|
356
|
-
query = "?"
|
357
|
-
}
|
358
|
-
return `${g(context.object)} ${context.word} ${g(context.property)}${query}`
|
359
|
-
*/
|
360
|
-
return `${g(context[context.do.left])} doesnt ${pluralize.plural(context.word)} ${g(context[context.do.right])}`
|
354
|
+
apply: async ({context, g}) => {
|
355
|
+
return `${await g(context[context.do.left])} doesnt ${pluralize.plural(context.word)} ${await g(context[context.do.right])}`
|
361
356
|
},
|
362
357
|
},
|
363
358
|
{
|
@@ -365,23 +360,22 @@ let configStruct = {
|
|
365
360
|
// debug: 'call9',
|
366
361
|
where: where(),
|
367
362
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.query && context.do,
|
368
|
-
apply: ({context, g}) => {
|
363
|
+
apply: async ({context, g}) => {
|
369
364
|
const right = context['do'].right
|
370
365
|
if (context[right].query) {
|
371
366
|
const left = context['do'].left
|
372
|
-
return `${g(context[right])} ${chooseNumber(context[right], "does", "do")} ${g(context[left])} ${context.word}`
|
367
|
+
return `${await g(context[right])} ${chooseNumber(context[right], "does", "do")} ${await g(context[left])} ${context.word}`
|
373
368
|
} else {
|
374
|
-
// return `does ${g(context[context.do.left])} ${pluralize.singular(context.word)} ${g(context[context.do.right])}`
|
375
369
|
// the marker is the infinite form
|
376
|
-
return `${chooseNumber(context[context.do.left], "does", "do")} ${g(context[context.do.left])} ${context.marker} ${g(context[context.do.right])}`
|
370
|
+
return `${chooseNumber(context[context.do.left], "does", "do")} ${await g(context[context.do.left])} ${context.marker} ${await g(context[context.do.right])}`
|
377
371
|
}
|
378
372
|
},
|
379
373
|
},
|
380
374
|
{
|
381
375
|
where: where(),
|
382
376
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && !context.query,
|
383
|
-
apply: ({context, g}) => {
|
384
|
-
return `${g(context.object)} ${context.word} ${g(context.property)}`
|
377
|
+
apply: async ({context, g}) => {
|
378
|
+
return `${await g(context.object)} ${context.word} ${await g(context.property)}`
|
385
379
|
}
|
386
380
|
},
|
387
381
|
{
|
@@ -389,17 +383,21 @@ let configStruct = {
|
|
389
383
|
where: where(),
|
390
384
|
// match: ({context}) => context.paraphrase && context.modifiers && context.object,
|
391
385
|
match: ({context}) => context.paraphrase && !context.possession && context.object,
|
392
|
-
apply: ({context, g, gs}) => {
|
386
|
+
apply: async ({context, g, gs}) => {
|
393
387
|
const base = { ...context }
|
394
388
|
base.object = undefined;
|
395
389
|
if (context.object.marker == 'objectPrefix') {
|
396
|
-
return `${g(context.object)} ${g(base)}`
|
390
|
+
return `${await g(context.object)} ${await g(base)}`
|
397
391
|
} else {
|
398
392
|
if (context.objects) {
|
399
|
-
|
393
|
+
const gObjects = []
|
394
|
+
for (const object of context.objects) {
|
395
|
+
gObjects.push(await g({...object, paraphrase: true}))
|
396
|
+
}
|
397
|
+
return await gs(gObjects, ' of ')
|
400
398
|
} else {
|
401
399
|
// TODO make paraphrase be a default when paraphrasing?
|
402
|
-
return `${g(base)} of ${g({...context.object, paraphrase: true})}`
|
400
|
+
return `${await g(base)} of ${await g({...context.object, paraphrase: true})}`
|
403
401
|
}
|
404
402
|
}
|
405
403
|
},
|
@@ -408,9 +406,9 @@ let configStruct = {
|
|
408
406
|
// ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
|
409
407
|
where: where(),
|
410
408
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && !context.evaluate && !context.object.marker == 'objectPrefix',
|
411
|
-
apply: ({context, g}) => {
|
409
|
+
apply: async ({context, g}) => {
|
412
410
|
const property = Object.assign({}, context, { object: undefined })
|
413
|
-
return `${g(property)} of ${g({ ...context.object, paraphrase: true })}`
|
411
|
+
return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
|
414
412
|
}
|
415
413
|
},
|
416
414
|
{
|
@@ -418,25 +416,25 @@ let configStruct = {
|
|
418
416
|
where: where(),
|
419
417
|
// match: ({context}) => context.paraphrase && !context.modifiers && context.object,
|
420
418
|
match: ({context}) => !context.modifiers && context.object,
|
421
|
-
apply: ({context, g, gs}) => {
|
419
|
+
apply: async ({context, g, gs}) => {
|
422
420
|
if (context.objects) {
|
423
421
|
const objects = [ ...context.objects ]
|
424
422
|
objects.reverse()
|
425
423
|
let phrase = ''
|
426
424
|
let separator = ''
|
427
425
|
for (let i = 0; i < objects.length-1; ++i) {
|
428
|
-
phrase = phrase + separator + g({...objects[i], paraphrase: context.paraphrase, possessive: true})
|
426
|
+
phrase = phrase + separator + await g({...objects[i], paraphrase: context.paraphrase, possessive: true})
|
429
427
|
separator = ' '
|
430
428
|
}
|
431
|
-
phrase = phrase + separator + g({...objects[objects.length-1], paraphrase: context.paraphrase})
|
429
|
+
phrase = phrase + separator + await g({...objects[objects.length-1], paraphrase: context.paraphrase})
|
432
430
|
return phrase
|
433
431
|
} else {
|
434
432
|
const base = { ...context }
|
435
433
|
base.object = undefined; // TODO make paraphrase be a default when paraphrasing?
|
436
434
|
if (context.object.marker == 'objectPrefix') {
|
437
|
-
return `${g(context.object)} ${g(base)}`
|
435
|
+
return `${await g(context.object)} ${await g(base)}`
|
438
436
|
} else {
|
439
|
-
return `${g({...context.object, paraphrase: context.paraphrase})}'s ${g(base)}`
|
437
|
+
return `${await g({...context.object, paraphrase: context.paraphrase})}'s ${await g(base)}`
|
440
438
|
}
|
441
439
|
}
|
442
440
|
},
|
@@ -530,15 +528,15 @@ let configStruct = {
|
|
530
528
|
notes: 'greg has eyes?',
|
531
529
|
where: where(),
|
532
530
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
|
533
|
-
apply: ({context, g, api, objects}) => {
|
531
|
+
apply: async ({context, g, api, objects}) => {
|
534
532
|
const object = pluralize.singular(context.object.value);
|
535
533
|
const property = pluralize.singular(context.property.value);
|
536
534
|
context.isResponse = true
|
537
|
-
if (!api.knownObject(object)) {
|
538
|
-
context.verbatim = `There is no object named ${g({...context.object, paraphrase: true})}`
|
535
|
+
if (!await api.knownObject(object)) {
|
536
|
+
context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
|
539
537
|
return
|
540
538
|
}
|
541
|
-
if (!api.hasProperty(object, property)) {
|
539
|
+
if (!await api.hasProperty(object, property)) {
|
542
540
|
context.evalue = {
|
543
541
|
marker: 'yesno',
|
544
542
|
value: false,
|
@@ -557,7 +555,7 @@ let configStruct = {
|
|
557
555
|
where: where(),
|
558
556
|
// match: ({context}) => context.marker == 'property' && context.same && context.object,
|
559
557
|
match: ({context, hierarchy, uuid}) => hierarchy.isA(context.marker, 'property') && context.same && context.objects && !context[`disable${uuid}`],
|
560
|
-
apply: ({context, objects, km, api, log, s, uuid}) => {
|
558
|
+
apply: async ({context, fragments, objects, km, api, log, s, uuid}) => {
|
561
559
|
const objectContext = context.object;
|
562
560
|
const propertyContext = context;
|
563
561
|
const objectId = context.object.value
|
@@ -565,17 +563,14 @@ let configStruct = {
|
|
565
563
|
/*
|
566
564
|
const propertyId = context.marker
|
567
565
|
if (context.marker != context.value) {
|
568
|
-
debugger
|
569
|
-
debugger // target
|
570
566
|
}
|
571
567
|
*/
|
572
568
|
// const propertyId = context.marker
|
573
569
|
/*
|
574
570
|
// greg HERE
|
575
571
|
*/
|
576
|
-
// debugger;
|
577
572
|
propertyContext[`disable${uuid}`] = true
|
578
|
-
const propertyId = km("dialogues").api.evaluateToConcept(propertyContext, context, log, s).evalue;
|
573
|
+
const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
|
579
574
|
try{
|
580
575
|
// greg
|
581
576
|
// api.makeObject({config, context: objectContext, doPluralize: false})
|
@@ -587,8 +582,8 @@ let configStruct = {
|
|
587
582
|
} catch (e) {
|
588
583
|
log(`Error processing set property of an object: ${e}`)
|
589
584
|
const config = km('properties')
|
590
|
-
const fragment =
|
591
|
-
const value = api.getProperty(objectId, propertyId)
|
585
|
+
const fragment = fragments("the property1 of object1 is value1")
|
586
|
+
const value = await api.getProperty(objectId, propertyId)
|
592
587
|
if (value.value == context.same.value) {
|
593
588
|
context.evalue = [
|
594
589
|
{ marker: 'yesno', value: true, paraphrase: true },
|
@@ -619,7 +614,7 @@ let configStruct = {
|
|
619
614
|
context.evalue = [
|
620
615
|
{ marker: 'yesno', value: false, paraphrase: true },
|
621
616
|
]
|
622
|
-
context.evalue = context.evalue.concat(fragment.instantiate(mappings))
|
617
|
+
context.evalue = context.evalue.concat(await fragment.instantiate(mappings))
|
623
618
|
context.evalue.forEach( (r) => r.paraphrase = true )
|
624
619
|
context.isResponse = true
|
625
620
|
context.sameWasProcessed = true
|
@@ -637,49 +632,47 @@ let configStruct = {
|
|
637
632
|
!context.evaluate.toConcept, // && !context.value,
|
638
633
|
// greghere
|
639
634
|
// match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
|
640
|
-
apply: ({context, api, kms, objects, g, s, log}) => {
|
635
|
+
apply: async ({context, api, kms, objects, g, s, log}) => {
|
641
636
|
const toDo = [ ...context.objects ]
|
642
637
|
|
643
|
-
const toValue = (objectContext) => {
|
638
|
+
const toValue = async (objectContext) => {
|
644
639
|
if (!objectContext.value) {
|
645
640
|
return objectContext;
|
646
641
|
}
|
647
642
|
let objectValue = kms.stm.api.getVariable(objectContext.value);
|
648
|
-
if (!api.knownObject(objectValue)) {
|
649
|
-
context.verbatim = `There is no object named "${g({...objectContext, paraphrase: true})}"`
|
643
|
+
if (!await api.knownObject(objectValue)) {
|
644
|
+
context.verbatim = `There is no object named "${await g({...objectContext, paraphrase: true})}"`
|
650
645
|
return
|
651
646
|
}
|
652
647
|
return objectValue
|
653
648
|
}
|
654
649
|
|
655
650
|
let currentContext = toDo.pop()
|
656
|
-
let currentValue = toValue(currentContext)
|
651
|
+
let currentValue = await toValue(currentContext)
|
657
652
|
while (toDo.length > 0) {
|
658
653
|
const nextContext = toDo.pop()
|
659
|
-
const nextValue = toValue(nextContext)
|
654
|
+
const nextValue = await toValue(nextContext)
|
660
655
|
if (!nextValue) {
|
661
656
|
// TODO maybe this I aware so it can say "I don't know about blah..." and below
|
662
657
|
// if (currentContext.unknown || !currentContext.value) {
|
663
658
|
if (!api.conceptExists(currentContext.value)) {
|
664
|
-
// debugger;
|
665
659
|
// api.conceptExists(currentContext)
|
666
|
-
const objectPhrase = g({...currentContext, paraphrase: true})
|
660
|
+
const objectPhrase = await g({...currentContext, paraphrase: true})
|
667
661
|
context.verbatim = `What "${objectPhrase}" means is unknown`
|
668
662
|
return
|
669
663
|
}
|
670
664
|
|
671
|
-
const propertyPhrase = g({...nextContext, paraphrase: true})
|
672
|
-
const objectPhrase = g({...currentContext, paraphrase: true})
|
665
|
+
const propertyPhrase = await g({...nextContext, paraphrase: true})
|
666
|
+
const objectPhrase = await g({...currentContext, paraphrase: true})
|
673
667
|
context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
|
674
668
|
return
|
675
669
|
}
|
676
670
|
|
677
|
-
if (!api.knownProperty(currentContext, nextContext)) {
|
678
|
-
|
679
|
-
context.verbatim = `There is no property ${g({...nextContext, paraphrase: true})} of ${g({...currentContext, paraphrase: true})}`
|
671
|
+
if (!await api.knownProperty(currentContext, nextContext)) {
|
672
|
+
context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
|
680
673
|
return
|
681
674
|
}
|
682
|
-
currentContext = api.getProperty(currentValue, nextValue, g)
|
675
|
+
currentContext = await api.getProperty(currentValue, nextValue, g)
|
683
676
|
currentValue = currentContext.value
|
684
677
|
}
|
685
678
|
context.focusable = ['object[0]']
|
@@ -690,30 +683,26 @@ let configStruct = {
|
|
690
683
|
]
|
691
684
|
};
|
692
685
|
|
693
|
-
const createConfig = () => {
|
694
|
-
const config = new Config(configStruct, module)
|
695
|
-
config.stop_auto_rebuild()
|
696
|
-
config.api = api
|
697
|
-
config.add(concept(), meta(), dialogues())
|
698
|
-
config.restart_auto_rebuild()
|
699
|
-
return config
|
700
|
-
}
|
701
|
-
|
702
686
|
knowledgeModule( {
|
687
|
+
config,
|
688
|
+
api: () => new API(),
|
689
|
+
includes: [concept, meta, dialogues],
|
690
|
+
|
703
691
|
module,
|
704
692
|
description: 'properties of objects',
|
705
|
-
createConfig,
|
706
693
|
test: {
|
707
694
|
name: './properties.test.json',
|
708
695
|
contents: properties_tests,
|
709
696
|
checks: {
|
710
|
-
context: defaultContextCheck,
|
711
|
-
|
697
|
+
context: defaultContextCheck(),
|
698
|
+
/*
|
699
|
+
objects: [
|
712
700
|
'children',
|
713
701
|
'concept',
|
714
702
|
'parents',
|
715
703
|
'properties'
|
716
704
|
]
|
705
|
+
*/
|
717
706
|
},
|
718
707
|
include: {
|
719
708
|
words: true,
|