ekms 8.0.0 → 8.1.0-beta.1

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.
Files changed (124) hide show
  1. package/common/animals.instance.json +3055 -1651
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/asking.instance.json +2 -0
  6. package/common/asking.js +253 -0
  7. package/common/asking.test.json +2290 -0
  8. package/common/avatar.js +6 -10
  9. package/common/characters.js +23 -30
  10. package/common/colors.instance.json +25666 -0
  11. package/common/colors.js +67 -0
  12. package/common/colors.test.json +4425 -0
  13. package/common/comparable.instance.json +1750 -0
  14. package/common/comparable.js +36 -28
  15. package/common/comparable.test.json +1196 -2
  16. package/common/concept.js +121 -119
  17. package/common/concept.test.json +688 -0
  18. package/common/conjunction.instance.json +2 -0
  19. package/common/conjunction.js +104 -0
  20. package/common/conjunction.test.json +322 -0
  21. package/common/countable.js +20 -14
  22. package/common/countable.test.json +1050 -0
  23. package/common/crew.instance.json +16432 -9850
  24. package/common/crew.js +39 -42
  25. package/common/crew.test.json +714 -452
  26. package/common/currency.js +28 -46
  27. package/common/dialogues.js +187 -429
  28. package/common/dialogues.test.json +684 -450
  29. package/common/dimension.instance.json +517 -289
  30. package/common/dimension.js +22 -24
  31. package/common/dimension.test.json +727 -1944
  32. package/common/edible.instance.json +20506 -10664
  33. package/common/edible.js +4 -9
  34. package/common/emotions.instance.json +195 -123
  35. package/common/emotions.js +36 -39
  36. package/common/evaluate.instance.json +2 -0
  37. package/common/evaluate.js +53 -0
  38. package/common/evaluate.test.json +574 -0
  39. package/common/events.js +11 -15
  40. package/common/fastfood.instance.json +223185 -113172
  41. package/common/fastfood.js +77 -87
  42. package/common/fastfood.test.json +8205 -3733
  43. package/common/formulas.instance.json +444 -244
  44. package/common/formulas.js +20 -27
  45. package/common/formulas.test.json +1027 -955
  46. package/common/gdefaults.js +45 -32
  47. package/common/help.js +9 -14
  48. package/common/help.test.json +71 -18
  49. package/common/helpers/concept.js +37 -10
  50. package/common/helpers/dialogues.js +22 -4
  51. package/common/helpers/formulas.js +0 -14
  52. package/common/helpers/meta.js +0 -1
  53. package/common/helpers/properties.js +92 -84
  54. package/common/helpers.js +35 -24
  55. package/common/hierarchy.js +18 -25
  56. package/common/javascript.js +12 -19
  57. package/common/kirk.instance.json +583 -300
  58. package/common/kirk.js +6 -9
  59. package/common/length.instance.json +8995 -4964
  60. package/common/length.js +5 -9
  61. package/common/listener.js +48 -0
  62. package/common/listener.test.json +104 -0
  63. package/common/math.instance.json +409 -1202
  64. package/common/math.js +17 -21
  65. package/common/meta.js +24 -50
  66. package/common/nameable.instance.json +2 -0
  67. package/common/nameable.js +144 -0
  68. package/common/nameable.test.json +3191 -0
  69. package/common/negation.instance.json +2 -0
  70. package/common/negation.js +38 -0
  71. package/common/negation.test.json +308 -0
  72. package/common/numbers.js +28 -32
  73. package/common/ordering.instance.json +459 -274
  74. package/common/ordering.js +81 -87
  75. package/common/ordinals.instance.json +2 -0
  76. package/common/ordinals.js +61 -0
  77. package/common/ordinals.test.json +412 -0
  78. package/common/people.instance.json +2138 -1321
  79. package/common/people.js +9 -14
  80. package/common/people.test.json +1815 -1073
  81. package/common/percentages.instance.json +2 -0
  82. package/common/percentages.js +53 -0
  83. package/common/percentages.test.json +751 -0
  84. package/common/pipboy.instance.json +12261 -6898
  85. package/common/pipboy.js +53 -62
  86. package/common/pipboy.test.json +2835 -0
  87. package/common/pokemon.instance.json +4432 -2351
  88. package/common/pokemon.js +8 -21
  89. package/common/pos.js +16 -14
  90. package/common/pressure.instance.json +2311 -1303
  91. package/common/pressure.js +5 -9
  92. package/common/properties.instance.json +151 -87
  93. package/common/properties.js +164 -167
  94. package/common/properties.test.json +17605 -4030
  95. package/common/punctuation.js +24 -8
  96. package/common/punctuation.test.json +233 -5
  97. package/common/reports.instance.json +1037 -551
  98. package/common/reports.js +77 -103
  99. package/common/reports.test.json +15623 -10458
  100. package/common/scorekeeper.js +19 -31
  101. package/common/sdefaults.js +17 -8
  102. package/common/sizeable.js +13 -12
  103. package/common/spock.instance.json +582 -299
  104. package/common/spock.js +6 -9
  105. package/common/stgame.js +20 -20
  106. package/common/stm.js +182 -29
  107. package/common/stm.test.json +1734 -1
  108. package/common/tell.js +15 -19
  109. package/common/temperature.instance.json +2379 -1355
  110. package/common/temperature.js +5 -9
  111. package/common/tester.js +15 -4
  112. package/common/testing.js +8 -13
  113. package/common/time.js +21 -26
  114. package/common/tokenize.js +8 -8
  115. package/common/tokenize.test.json +86 -1
  116. package/common/ui.instance.json +151 -460
  117. package/common/ui.js +22 -34
  118. package/common/ui.test.json +641 -5357
  119. package/common/weight.instance.json +7957 -4350
  120. package/common/weight.js +5 -9
  121. package/common/weight.test.json +242 -238
  122. package/common/yesno.js +6 -6
  123. package/main.js +68 -45
  124. package/package.json +44 -6
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
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,8 +79,16 @@ const template = {
79
79
 
80
80
  const api = new API();
81
81
 
82
- let configStruct = {
82
+ let config = {
83
83
  name: 'properties',
84
+ associations: {
85
+ negative: [],
86
+ positive: [
87
+ // [['isEdee', 0], ['isEd', 0], ['isEder', 0], ['by', 0]]
88
+ [['queryable', 0], ['is', 0], ['property', 0], ['propertyOf', 0], ['object', 0]]
89
+ ]
90
+ },
91
+
84
92
  operators: [
85
93
  "([hierarchyAble|])",
86
94
  "(([property]) <([propertyOf|of] ([object]))>)",
@@ -112,22 +120,29 @@ let configStruct = {
112
120
  // ['concept', 'theAble'],
113
121
  // ['concept', 'queryable'],
114
122
  ['unknown', 'hierarchyAble'],
115
- ['unknown', 'object'],
123
+ // ['unknown', 'object'],
116
124
  ['what', 'object'],
117
- ['hierarchyAble', 'queryable'],
118
- ['readonly', 'queryable'],
119
- ['property', 'queryable'],
120
- ['object', 'queryable'],
121
- ['xfx', 'queryable'],
122
- ['property', 'theAble'],
123
- ['property', 'unknown'],
124
- ['object', 'theAble'],
125
- ['whose', 'object'],
126
- ['have', 'canBeDoQuestion'],
127
- ['have', 'canBeQuestion'],
125
+ // ['hierarchyAble', 'queryable'],
126
+ // ['readonly', 'queryable'],
127
+ // ['object', 'queryable'],
128
+ // ['xfx', 'queryable'],
129
+
130
+ // ['property', 'queryable'],
131
+ // ['property', 'theAble'],
132
+ // ['property', 'unknown'],
133
+
134
+ // ['object', 'theAble'],
135
+ // ['whose', 'object'],
136
+ // ['have', 'canBeDoQuestion'],
137
+ // ['have', 'canBeQuestion'],
128
138
  ],
129
139
  bridges: [
130
- { id: 'xfx', level: 0, bridge: "{ ...next(operator) }" },
140
+ {
141
+ id: 'xfx',
142
+ level: 0,
143
+ isA: ['queryable'],
144
+ bridge: "{ ...next(operator) }"
145
+ },
131
146
  {
132
147
  id: 'between',
133
148
  isA: ['preposition'],
@@ -136,7 +151,12 @@ let configStruct = {
136
151
  },
137
152
  { id: 'between', level: 1, bridge: "{ ...before[0], arguments: operator.arguments }" },
138
153
 
139
- { id: 'hierarchyAble', level: 0, bridge: "{ ...next(operator) }" },
154
+ {
155
+ id: 'hierarchyAble',
156
+ level: 0,
157
+ isA: ['queryable'],
158
+ bridge: "{ ...next(operator) }"
159
+ },
140
160
  /*
141
161
  {
142
162
  id: "modifies",
@@ -144,32 +164,91 @@ let configStruct = {
144
164
  bridge: "{ ...next(operator), modifier: before[0], concept: after[0] }"
145
165
  },
146
166
  */
147
- { id: "readonly", level: 0, bridge: "{ ...next(operator) }" },
167
+ {
168
+ id: "readonly",
169
+ level: 0,
170
+ isA: ['queryable'],
171
+ bridge: "{ ...next(operator) }"
172
+ },
148
173
  // { id: "concept", level: 0, bridge: "{ ...next(operator) }" },
149
174
  // the cars dont have wings
150
175
  // greg doesnt have wings
151
176
  // { id: "doesnt", level: 0, bridge: "{ ...context, number: operator.number, negation: true }*" },
152
177
  // { id: "doesnt", level: 0, bridge: "{ ...context, number: 'one', negation: true }*" },
153
178
  { id: "doesnt", level: 0, bridge: "{ ...context, number: operator.number, object.number: operator.number, negation: true }*" },
154
- { id: "have", level: 0, bridge: "{ ...next(operator), object: { number: operator.number, ...before }, property: after[0], do: { left: 'object', right: 'property' } }" },
155
- { id: "have", level: 1, bridge: "{ ...next(operator) }" },
156
- { id: "property", level: 0, bridge: "{ ...next(operator) }" },
157
- { id: "object", level: 0, bridge: "{ ...next(operator) }" },
179
+ {
180
+ id: "have",
181
+ level: 0,
182
+ isA: ['canBeDoQuestion', 'canBeQuestion'],
183
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
184
+ bridge: "{ ...next(operator), object: { number: operator.number, ...before }, property: after[0], do: { left: 'object', right: 'property' } }"
185
+ },
186
+ {
187
+ id: "have",
188
+ level: 1,
189
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
190
+ bridge: "{ ...next(operator) }"
191
+ },
192
+ {
193
+ id: "property",
194
+ words: ['properties'],
195
+ isA: ['queryable', 'theAble'],
196
+ level: 0,
197
+ bridge: "{ ...next(operator) }"
198
+ },
199
+ {
200
+ id: "object",
201
+ isA: ['queryable', 'theAble'],
202
+ level: 0,
203
+ bridge: "{ ...next(operator) }"
204
+ },
158
205
 
159
206
  // old
160
207
  // { id: "possession", level: 0, bridge: "{ ...next(operator), object: before[0] }" },
161
208
  // { id: "possession", level: 1, bridge: "{ ...after[0], object: operator.object, marker: operator('property', 0) }" },
162
209
 
163
- { id: "possession", level: 0, inverted: true, bridge: "{ ...next(operator), possession: true, object: before[0], objects: before }" },
210
+ {
211
+ id: "possession",
212
+ level: 0,
213
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
214
+ inverted: true,
215
+ bridge: "{ ...next(operator), possession: true, object: before[0], objects: before }"
216
+ },
164
217
  // 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
- { id: "possession", level: 1, inverted: true, 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']) }" },
218
+ {
219
+ id: "possession",
220
+ level: 1,
221
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
222
+ inverted: true,
223
+ 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']) }"
224
+ },
166
225
  // TODO make object be after[0] that makes more sense
167
226
  // { 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
227
 
169
- { id: "propertyOf", level: 0, bridge: "{ ...next(operator), object: after[0], objects: after }" },
170
- { id: "propertyOf", level: 1, bridge: "{ ...before[0], object: operator.object, objects: append(default(before[0].objects, before), operator.objects) }" },
171
- { id: "whose", level: 0, bridge: '{ ...after[0], query: true, whose: "whose", modifiers: append(["whose"], after[0].modifiers)}' },
172
- { id: "objectPrefix", level: 0, bridge: '{ ...after[0], object: operator, objects: [after[0], operator] }' },
228
+ {
229
+ id: "propertyOf",
230
+ level: 0,
231
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown'], ['object', 'unknown']],
232
+ bridge: "{ ...next(operator), object: after[0], objects: after }"
233
+ },
234
+ {
235
+ id: "propertyOf",
236
+ level: 1,
237
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
238
+ bridge: "{ ...before[0], object: operator.object, objects: append(default(before[0].objects, before), operator.objects) }"
239
+ },
240
+ {
241
+ id: "whose",
242
+ level: 0,
243
+ isA: ['object'],
244
+ bridge: '{ ...after[0], query: true, whose: "whose", modifiers: append(["whose"], after[0].modifiers)}'
245
+ },
246
+ {
247
+ id: "objectPrefix",
248
+ level: 0,
249
+ localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
250
+ bridge: '{ ...after[0], object: operator, objects: [after[0], operator] }'
251
+ },
173
252
  ],
174
253
  words: {
175
254
  literals: {
@@ -216,7 +295,7 @@ let configStruct = {
216
295
  notes: 'expression with constraints',
217
296
  where: where(),
218
297
  match: ({context}) => context.constraints && context.paraphrase,
219
- apply: ({context, g}) => {
298
+ apply: async ({context, g}) => {
220
299
  // TODO assume one constaints deal with more in the future
221
300
  const constraint = context.constraints[0]
222
301
  const constrained = Object.assign({}, constraint.constraint)
@@ -229,87 +308,25 @@ let configStruct = {
229
308
  paraphrase.paraphrase = true;
230
309
  paraphrase[constraint.property] = property
231
310
  if (false && context.isResponse) {
232
- return g({...constraint.paraphrase, paraphrase: true})
311
+ return await g({...constraint.paraphrase, paraphrase: true})
233
312
  } else {
234
- return g(constrained)
313
+ return await g(constrained)
235
314
  }
236
315
  },
237
316
  },
238
317
  {
239
318
  where: where(),
240
319
  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
- // },
320
+ apply: async ({context, g}) => `${context.word} between ${await g(context.arguments)}`
321
+ },
305
322
  {
306
323
  notes: 'add possession ending',
307
324
  priority: -1,
308
325
  where: where(),
309
326
  match: ({context}) => context.paraphrase && context.possessive,
310
- apply: ({context, g}) => {
327
+ apply: async ({context, g}) => {
311
328
  context.possessive = false
312
- const phrase = g(context)
329
+ const phrase = await g(context)
313
330
  context.possessive = true
314
331
  if (phrase.endsWith('s')) {
315
332
  return `${phrase}'`
@@ -318,13 +335,6 @@ let configStruct = {
318
335
  }
319
336
  }
320
337
  },
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
338
  {
329
339
  where: where(),
330
340
  match: ({context}) => context.marker == 'objectPrefix' && context.value == 'other' && context.paraphrase,
@@ -349,15 +359,8 @@ let configStruct = {
349
359
  notes: 'negative do questions',
350
360
  where: where(),
351
361
  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])}`
362
+ apply: async ({context, g}) => {
363
+ return `${await g(context[context.do.left])} doesnt ${pluralize.plural(context.word)} ${await g(context[context.do.right])}`
361
364
  },
362
365
  },
363
366
  {
@@ -365,23 +368,22 @@ let configStruct = {
365
368
  // debug: 'call9',
366
369
  where: where(),
367
370
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.query && context.do,
368
- apply: ({context, g}) => {
371
+ apply: async ({context, g}) => {
369
372
  const right = context['do'].right
370
373
  if (context[right].query) {
371
374
  const left = context['do'].left
372
- return `${g(context[right])} ${chooseNumber(context[right], "does", "do")} ${g(context[left])} ${context.word}`
375
+ return `${await g(context[right])} ${chooseNumber(context[right], "does", "do")} ${await g(context[left])} ${context.word}`
373
376
  } else {
374
- // return `does ${g(context[context.do.left])} ${pluralize.singular(context.word)} ${g(context[context.do.right])}`
375
377
  // 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])}`
378
+ return `${chooseNumber(context[context.do.left], "does", "do")} ${await g(context[context.do.left])} ${context.marker} ${await g(context[context.do.right])}`
377
379
  }
378
380
  },
379
381
  },
380
382
  {
381
383
  where: where(),
382
384
  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)}`
385
+ apply: async ({context, g}) => {
386
+ return `${await g(context.object)} ${context.word} ${await g(context.property)}`
385
387
  }
386
388
  },
387
389
  {
@@ -389,17 +391,21 @@ let configStruct = {
389
391
  where: where(),
390
392
  // match: ({context}) => context.paraphrase && context.modifiers && context.object,
391
393
  match: ({context}) => context.paraphrase && !context.possession && context.object,
392
- apply: ({context, g, gs}) => {
394
+ apply: async ({context, g, gs}) => {
393
395
  const base = { ...context }
394
396
  base.object = undefined;
395
397
  if (context.object.marker == 'objectPrefix') {
396
- return `${g(context.object)} ${g(base)}`
398
+ return `${await g(context.object)} ${await g(base)}`
397
399
  } else {
398
400
  if (context.objects) {
399
- return gs(context.objects.map( (c) => g({...c, paraphrase: true}) ), ' of ')
401
+ const gObjects = []
402
+ for (const object of context.objects) {
403
+ gObjects.push(await g({...object, paraphrase: true}))
404
+ }
405
+ return await gs(gObjects, ' of ')
400
406
  } else {
401
407
  // TODO make paraphrase be a default when paraphrasing?
402
- return `${g(base)} of ${g({...context.object, paraphrase: true})}`
408
+ return `${await g(base)} of ${await g({...context.object, paraphrase: true})}`
403
409
  }
404
410
  }
405
411
  },
@@ -408,9 +414,9 @@ let configStruct = {
408
414
  // ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
409
415
  where: where(),
410
416
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && !context.evaluate && !context.object.marker == 'objectPrefix',
411
- apply: ({context, g}) => {
417
+ apply: async ({context, g}) => {
412
418
  const property = Object.assign({}, context, { object: undefined })
413
- return `${g(property)} of ${g({ ...context.object, paraphrase: true })}`
419
+ return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
414
420
  }
415
421
  },
416
422
  {
@@ -418,25 +424,25 @@ let configStruct = {
418
424
  where: where(),
419
425
  // match: ({context}) => context.paraphrase && !context.modifiers && context.object,
420
426
  match: ({context}) => !context.modifiers && context.object,
421
- apply: ({context, g, gs}) => {
427
+ apply: async ({context, g, gs}) => {
422
428
  if (context.objects) {
423
429
  const objects = [ ...context.objects ]
424
430
  objects.reverse()
425
431
  let phrase = ''
426
432
  let separator = ''
427
433
  for (let i = 0; i < objects.length-1; ++i) {
428
- phrase = phrase + separator + g({...objects[i], paraphrase: context.paraphrase, possessive: true})
434
+ phrase = phrase + separator + await g({...objects[i], paraphrase: context.paraphrase, possessive: true})
429
435
  separator = ' '
430
436
  }
431
- phrase = phrase + separator + g({...objects[objects.length-1], paraphrase: context.paraphrase})
437
+ phrase = phrase + separator + await g({...objects[objects.length-1], paraphrase: context.paraphrase})
432
438
  return phrase
433
439
  } else {
434
440
  const base = { ...context }
435
441
  base.object = undefined; // TODO make paraphrase be a default when paraphrasing?
436
442
  if (context.object.marker == 'objectPrefix') {
437
- return `${g(context.object)} ${g(base)}`
443
+ return `${await g(context.object)} ${await g(base)}`
438
444
  } else {
439
- return `${g({...context.object, paraphrase: context.paraphrase})}'s ${g(base)}`
445
+ return `${await g({...context.object, paraphrase: context.paraphrase})}'s ${await g(base)}`
440
446
  }
441
447
  }
442
448
  },
@@ -530,15 +536,15 @@ let configStruct = {
530
536
  notes: 'greg has eyes?',
531
537
  where: where(),
532
538
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
533
- apply: ({context, g, api, objects}) => {
539
+ apply: async ({context, g, api, objects}) => {
534
540
  const object = pluralize.singular(context.object.value);
535
541
  const property = pluralize.singular(context.property.value);
536
542
  context.isResponse = true
537
- if (!api.knownObject(object)) {
538
- context.verbatim = `There is no object named ${g({...context.object, paraphrase: true})}`
543
+ if (!await api.knownObject(object)) {
544
+ context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
539
545
  return
540
546
  }
541
- if (!api.hasProperty(object, property)) {
547
+ if (!await api.hasProperty(object, property)) {
542
548
  context.evalue = {
543
549
  marker: 'yesno',
544
550
  value: false,
@@ -557,7 +563,7 @@ let configStruct = {
557
563
  where: where(),
558
564
  // match: ({context}) => context.marker == 'property' && context.same && context.object,
559
565
  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}) => {
566
+ apply: async ({context, fragments, objects, km, api, log, s, uuid}) => {
561
567
  const objectContext = context.object;
562
568
  const propertyContext = context;
563
569
  const objectId = context.object.value
@@ -565,17 +571,14 @@ let configStruct = {
565
571
  /*
566
572
  const propertyId = context.marker
567
573
  if (context.marker != context.value) {
568
- debugger
569
- debugger // target
570
574
  }
571
575
  */
572
576
  // const propertyId = context.marker
573
577
  /*
574
578
  // greg HERE
575
579
  */
576
- // debugger;
577
580
  propertyContext[`disable${uuid}`] = true
578
- const propertyId = km("dialogues").api.evaluateToConcept(propertyContext, context, log, s).evalue;
581
+ const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
579
582
  try{
580
583
  // greg
581
584
  // api.makeObject({config, context: objectContext, doPluralize: false})
@@ -587,8 +590,8 @@ let configStruct = {
587
590
  } catch (e) {
588
591
  log(`Error processing set property of an object: ${e}`)
589
592
  const config = km('properties')
590
- const fragment = config.fragment("the property1 of object1 is value1")
591
- const value = api.getProperty(objectId, propertyId)
593
+ const fragment = fragments("the property1 of object1 is value1")
594
+ const value = await api.getProperty(objectId, propertyId)
592
595
  if (value.value == context.same.value) {
593
596
  context.evalue = [
594
597
  { marker: 'yesno', value: true, paraphrase: true },
@@ -619,7 +622,7 @@ let configStruct = {
619
622
  context.evalue = [
620
623
  { marker: 'yesno', value: false, paraphrase: true },
621
624
  ]
622
- context.evalue = context.evalue.concat(fragment.instantiate(mappings))
625
+ context.evalue = context.evalue.concat(await fragment.instantiate(mappings))
623
626
  context.evalue.forEach( (r) => r.paraphrase = true )
624
627
  context.isResponse = true
625
628
  context.sameWasProcessed = true
@@ -637,49 +640,47 @@ let configStruct = {
637
640
  !context.evaluate.toConcept, // && !context.value,
638
641
  // greghere
639
642
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
640
- apply: ({context, api, kms, objects, g, s, log}) => {
643
+ apply: async ({context, api, kms, objects, g, s, log}) => {
641
644
  const toDo = [ ...context.objects ]
642
645
 
643
- const toValue = (objectContext) => {
646
+ const toValue = async (objectContext) => {
644
647
  if (!objectContext.value) {
645
648
  return objectContext;
646
649
  }
647
650
  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})}"`
651
+ if (!await api.knownObject(objectValue)) {
652
+ context.verbatim = `There is no object named "${await g({...objectContext, paraphrase: true})}"`
650
653
  return
651
654
  }
652
655
  return objectValue
653
656
  }
654
657
 
655
658
  let currentContext = toDo.pop()
656
- let currentValue = toValue(currentContext)
659
+ let currentValue = await toValue(currentContext)
657
660
  while (toDo.length > 0) {
658
661
  const nextContext = toDo.pop()
659
- const nextValue = toValue(nextContext)
662
+ const nextValue = await toValue(nextContext)
660
663
  if (!nextValue) {
661
664
  // TODO maybe this I aware so it can say "I don't know about blah..." and below
662
665
  // if (currentContext.unknown || !currentContext.value) {
663
666
  if (!api.conceptExists(currentContext.value)) {
664
- // debugger;
665
667
  // api.conceptExists(currentContext)
666
- const objectPhrase = g({...currentContext, paraphrase: true})
668
+ const objectPhrase = await g({...currentContext, paraphrase: true})
667
669
  context.verbatim = `What "${objectPhrase}" means is unknown`
668
670
  return
669
671
  }
670
672
 
671
- const propertyPhrase = g({...nextContext, paraphrase: true})
672
- const objectPhrase = g({...currentContext, paraphrase: true})
673
+ const propertyPhrase = await g({...nextContext, paraphrase: true})
674
+ const objectPhrase = await g({...currentContext, paraphrase: true})
673
675
  context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
674
676
  return
675
677
  }
676
678
 
677
- if (!api.knownProperty(currentContext, nextContext)) {
678
- api.knownProperty(currentContext, nextContext)
679
- context.verbatim = `There is no property ${g({...nextContext, paraphrase: true})} of ${g({...currentContext, paraphrase: true})}`
679
+ if (!await api.knownProperty(currentContext, nextContext)) {
680
+ context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
680
681
  return
681
682
  }
682
- currentContext = api.getProperty(currentValue, nextValue, g)
683
+ currentContext = await api.getProperty(currentValue, nextValue, g)
683
684
  currentValue = currentContext.value
684
685
  }
685
686
  context.focusable = ['object[0]']
@@ -690,30 +691,26 @@ let configStruct = {
690
691
  ]
691
692
  };
692
693
 
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
694
  knowledgeModule( {
695
+ config,
696
+ api: () => new API(),
697
+ includes: [concept, meta, dialogues],
698
+
703
699
  module,
704
700
  description: 'properties of objects',
705
- createConfig,
706
701
  test: {
707
702
  name: './properties.test.json',
708
703
  contents: properties_tests,
709
704
  checks: {
710
- context: defaultContextCheck,
711
- xobjects: [
705
+ context: defaultContextCheck(),
706
+ /*
707
+ objects: [
712
708
  'children',
713
709
  'concept',
714
710
  'parents',
715
711
  'properties'
716
712
  ]
713
+ */
717
714
  },
718
715
  include: {
719
716
  words: true,