ekms 8.0.0-beta.9 → 8.0.0-beta.91

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 (113) hide show
  1. package/common/animals.instance.json +2915 -1553
  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 -29
  10. package/common/colors.instance.json +7487 -4114
  11. package/common/colors.js +5 -9
  12. package/common/colors.test.json +345 -780
  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/conjunction.instance.json +2 -0
  18. package/common/conjunction.js +104 -0
  19. package/common/conjunction.test.json +322 -0
  20. package/common/countable.js +20 -14
  21. package/common/countable.test.json +1050 -0
  22. package/common/crew.instance.json +13553 -7026
  23. package/common/crew.js +37 -42
  24. package/common/crew.test.json +714 -452
  25. package/common/currency.js +28 -46
  26. package/common/dialogues.js +150 -426
  27. package/common/dialogues.test.json +0 -786
  28. package/common/dimension.instance.json +491 -262
  29. package/common/dimension.js +22 -24
  30. package/common/dimension.test.json +508 -1702
  31. package/common/edible.instance.json +20446 -10806
  32. package/common/edible.js +4 -9
  33. package/common/emotions.instance.json +192 -124
  34. package/common/emotions.js +36 -39
  35. package/common/evaluate.instance.json +2 -0
  36. package/common/evaluate.js +53 -0
  37. package/common/evaluate.test.json +574 -0
  38. package/common/events.js +11 -15
  39. package/common/fastfood.instance.json +222642 -113618
  40. package/common/fastfood.js +76 -86
  41. package/common/fastfood.test.json +268 -90
  42. package/common/formulas.instance.json +443 -247
  43. package/common/formulas.js +20 -27
  44. package/common/gdefaults.js +40 -27
  45. package/common/help.js +9 -14
  46. package/common/help.test.json +65 -16
  47. package/common/helpers/concept.js +10 -7
  48. package/common/helpers/dialogues.js +5 -3
  49. package/common/helpers/properties.js +67 -64
  50. package/common/helpers.js +35 -24
  51. package/common/hierarchy.js +17 -25
  52. package/common/javascript.js +12 -19
  53. package/common/kirk.instance.json +583 -299
  54. package/common/kirk.js +6 -9
  55. package/common/length.instance.json +9005 -5001
  56. package/common/length.js +5 -9
  57. package/common/listener.js +48 -0
  58. package/common/listener.test.json +104 -0
  59. package/common/math.instance.json +406 -1178
  60. package/common/math.js +17 -21
  61. package/common/meta.js +24 -48
  62. package/common/nameable.instance.json +2 -0
  63. package/common/nameable.js +144 -0
  64. package/common/nameable.test.json +3191 -0
  65. package/common/negation.js +11 -7
  66. package/common/numbers.js +28 -32
  67. package/common/ordering.instance.json +443 -343
  68. package/common/ordering.js +81 -87
  69. package/common/ordinals.instance.json +2 -0
  70. package/common/ordinals.js +60 -0
  71. package/common/ordinals.test.json +306 -0
  72. package/common/people.instance.json +2210 -1150
  73. package/common/people.js +9 -14
  74. package/common/percentages.instance.json +2 -0
  75. package/common/percentages.js +53 -0
  76. package/common/percentages.test.json +751 -0
  77. package/common/pipboy.instance.json +11845 -6590
  78. package/common/pipboy.js +53 -62
  79. package/common/pipboy.test.json +2835 -0
  80. package/common/pokemon.instance.json +4300 -2285
  81. package/common/pokemon.js +8 -21
  82. package/common/pos.js +16 -14
  83. package/common/pressure.instance.json +2325 -1340
  84. package/common/pressure.js +5 -9
  85. package/common/properties.instance.json +148 -88
  86. package/common/properties.js +149 -160
  87. package/common/punctuation.js +16 -8
  88. package/common/reports.instance.json +1019 -551
  89. package/common/reports.js +77 -101
  90. package/common/reports.test.json +15623 -10458
  91. package/common/scorekeeper.js +19 -31
  92. package/common/sdefaults.js +17 -8
  93. package/common/sizeable.js +7 -11
  94. package/common/spock.instance.json +582 -298
  95. package/common/spock.js +6 -9
  96. package/common/stgame.js +20 -20
  97. package/common/stm.js +173 -31
  98. package/common/stm.test.json +1734 -1
  99. package/common/tell.js +15 -19
  100. package/common/temperature.instance.json +2430 -1429
  101. package/common/temperature.js +5 -9
  102. package/common/tester.js +15 -4
  103. package/common/testing.js +8 -12
  104. package/common/time.js +21 -26
  105. package/common/tokenize.js +6 -7
  106. package/common/ui.instance.json +150 -463
  107. package/common/ui.js +22 -33
  108. package/common/ui.test.json +641 -5357
  109. package/common/weight.instance.json +8034 -4503
  110. package/common/weight.js +5 -9
  111. package/common/yesno.js +6 -6
  112. package/main.js +20 -4
  113. package/package.json +37 -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,7 +79,7 @@ const template = {
79
79
 
80
80
  const api = new API();
81
81
 
82
- let configStruct = {
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
- ['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'],
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
- { id: 'xfx', level: 0, bridge: "{ ...next(operator) }" },
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
- { id: 'hierarchyAble', level: 0, bridge: "{ ...next(operator) }" },
146
+ {
147
+ id: 'hierarchyAble',
148
+ level: 0,
149
+ isA: ['queryable'],
150
+ bridge: "{ ...next(operator) }"
151
+ },
140
152
  /*
141
153
  {
142
154
  id: "modifies",
@@ -144,37 +156,91 @@ let configStruct = {
144
156
  bridge: "{ ...next(operator), modifier: before[0], concept: after[0] }"
145
157
  },
146
158
  */
147
- { id: "readonly", level: 0, bridge: "{ ...next(operator) }" },
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
- { 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) }" },
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
+ },
156
184
  {
157
185
  id: "property",
158
186
  words: ['properties'],
187
+ isA: ['queryable', 'theAble'],
188
+ level: 0,
189
+ bridge: "{ ...next(operator) }"
190
+ },
191
+ {
192
+ id: "object",
193
+ isA: ['queryable', 'theAble'],
159
194
  level: 0,
160
195
  bridge: "{ ...next(operator) }"
161
196
  },
162
- { id: "object", level: 0, bridge: "{ ...next(operator) }" },
163
197
 
164
198
  // old
165
199
  // { id: "possession", level: 0, bridge: "{ ...next(operator), object: before[0] }" },
166
200
  // { id: "possession", level: 1, bridge: "{ ...after[0], object: operator.object, marker: operator('property', 0) }" },
167
201
 
168
- { id: "possession", level: 0, inverted: true, bridge: "{ ...next(operator), possession: true, object: before[0], objects: before }" },
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
+ },
169
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) }" },
170
- { 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']) }" },
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
+ },
171
217
  // TODO make object be after[0] that makes more sense
172
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) }" },
173
219
 
174
- { id: "propertyOf", level: 0, bridge: "{ ...next(operator), object: after[0], objects: after }" },
175
- { id: "propertyOf", level: 1, bridge: "{ ...before[0], object: operator.object, objects: append(default(before[0].objects, before), operator.objects) }" },
176
- { id: "whose", level: 0, bridge: '{ ...after[0], query: true, whose: "whose", modifiers: append(["whose"], after[0].modifiers)}' },
177
- { id: "objectPrefix", level: 0, bridge: '{ ...after[0], object: operator, objects: [after[0], operator] }' },
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
+ },
178
244
  ],
179
245
  words: {
180
246
  literals: {
@@ -221,7 +287,7 @@ let configStruct = {
221
287
  notes: 'expression with constraints',
222
288
  where: where(),
223
289
  match: ({context}) => context.constraints && context.paraphrase,
224
- apply: ({context, g}) => {
290
+ apply: async ({context, g}) => {
225
291
  // TODO assume one constaints deal with more in the future
226
292
  const constraint = context.constraints[0]
227
293
  const constrained = Object.assign({}, constraint.constraint)
@@ -234,86 +300,25 @@ let configStruct = {
234
300
  paraphrase.paraphrase = true;
235
301
  paraphrase[constraint.property] = property
236
302
  if (false && context.isResponse) {
237
- return g({...constraint.paraphrase, paraphrase: true})
303
+ return await g({...constraint.paraphrase, paraphrase: true})
238
304
  } else {
239
- return g(constrained)
305
+ return await g(constrained)
240
306
  }
241
307
  },
242
308
  },
243
309
  {
244
310
  where: where(),
245
311
  match: ({context}) => context.marker == 'xfx',
246
- apply: ({context, g}) => `${context.word} between ${g(context.arguments)}`
247
- },
248
- // {
249
- // notes: '"fire type, water type and earth type" to "fire water and earth type"',
250
- // tests: [
251
- // 'chicken modifies strips',
252
- // ],
253
- // /*
254
- // {
255
- // "water": {
256
- // "marker": "water",
257
- // "value": "water",
258
- // "word": "water"
259
- // },
260
- // "marker": "water_type",
261
- // "modifiers": [
262
- // "water"
263
- // ],
264
- // "types": [
265
- // "water_type"
266
- // ],
267
- // "value": "water_type",
268
- // "word": "type",
269
- // "paraphrase": true
270
- // },
271
- // */
272
- // where: where(),
273
- // match: ({context}) => {
274
- // if (!context.paraphrase) {
275
- // return
276
- // }
277
- // if (context.marker !== 'list') {
278
- // return
279
- // }
280
- // if ((context.value || []).length < 2) {
281
- // return
282
- // }
283
- // if (!context.value[0].word) {
284
- // return
285
- // }
286
- // const word = context.value[0].word
287
-
288
- // for (let value of context.value) {
289
- // if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
290
- // return
291
- // }
292
- // }
293
- // return true
294
- // },
295
- // apply: ({g, context}) => {
296
- // const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
297
- // context.word = context.value[0].word
298
- // context.value = null
299
- // context.modifiers = ['modifier']
300
- // context.modifier = {
301
- // marker: 'list',
302
- // paraphrase: true,
303
- // value: modifiers
304
- // }
305
- // context.paraphrase = true
306
- // return g(context)
307
- // }
308
- // },
312
+ apply: async ({context, g}) => `${context.word} between ${await g(context.arguments)}`
313
+ },
309
314
  {
310
315
  notes: 'add possession ending',
311
316
  priority: -1,
312
317
  where: where(),
313
318
  match: ({context}) => context.paraphrase && context.possessive,
314
- apply: ({context, g}) => {
319
+ apply: async ({context, g}) => {
315
320
  context.possessive = false
316
- const phrase = g(context)
321
+ const phrase = await g(context)
317
322
  context.possessive = true
318
323
  if (phrase.endsWith('s')) {
319
324
  return `${phrase}'`
@@ -322,13 +327,6 @@ let configStruct = {
322
327
  }
323
328
  }
324
329
  },
325
- /*
326
- {
327
- where: where(),
328
- match: ({context}) => context.marker == 'modifies' && context.paraphrase,
329
- apply: ({context}) => `${context.modifier.word} modifies ${context.concept.word}`,
330
- },
331
- */
332
330
  {
333
331
  where: where(),
334
332
  match: ({context}) => context.marker == 'objectPrefix' && context.value == 'other' && context.paraphrase,
@@ -353,15 +351,8 @@ let configStruct = {
353
351
  notes: 'negative do questions',
354
352
  where: where(),
355
353
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.negation,
356
- apply: ({context, g}) => {
357
- /*
358
- let query = ''
359
- if (context.query) {
360
- query = "?"
361
- }
362
- return `${g(context.object)} ${context.word} ${g(context.property)}${query}`
363
- */
364
- 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])}`
365
356
  },
366
357
  },
367
358
  {
@@ -369,23 +360,22 @@ let configStruct = {
369
360
  // debug: 'call9',
370
361
  where: where(),
371
362
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.query && context.do,
372
- apply: ({context, g}) => {
363
+ apply: async ({context, g}) => {
373
364
  const right = context['do'].right
374
365
  if (context[right].query) {
375
366
  const left = context['do'].left
376
- 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}`
377
368
  } else {
378
- // return `does ${g(context[context.do.left])} ${pluralize.singular(context.word)} ${g(context[context.do.right])}`
379
369
  // the marker is the infinite form
380
- 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])}`
381
371
  }
382
372
  },
383
373
  },
384
374
  {
385
375
  where: where(),
386
376
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && !context.query,
387
- apply: ({context, g}) => {
388
- 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)}`
389
379
  }
390
380
  },
391
381
  {
@@ -393,17 +383,21 @@ let configStruct = {
393
383
  where: where(),
394
384
  // match: ({context}) => context.paraphrase && context.modifiers && context.object,
395
385
  match: ({context}) => context.paraphrase && !context.possession && context.object,
396
- apply: ({context, g, gs}) => {
386
+ apply: async ({context, g, gs}) => {
397
387
  const base = { ...context }
398
388
  base.object = undefined;
399
389
  if (context.object.marker == 'objectPrefix') {
400
- return `${g(context.object)} ${g(base)}`
390
+ return `${await g(context.object)} ${await g(base)}`
401
391
  } else {
402
392
  if (context.objects) {
403
- return gs(context.objects.map( (c) => g({...c, paraphrase: true}) ), ' of ')
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 ')
404
398
  } else {
405
399
  // TODO make paraphrase be a default when paraphrasing?
406
- return `${g(base)} of ${g({...context.object, paraphrase: true})}`
400
+ return `${await g(base)} of ${await g({...context.object, paraphrase: true})}`
407
401
  }
408
402
  }
409
403
  },
@@ -412,9 +406,9 @@ let configStruct = {
412
406
  // ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
413
407
  where: where(),
414
408
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && !context.evaluate && !context.object.marker == 'objectPrefix',
415
- apply: ({context, g}) => {
409
+ apply: async ({context, g}) => {
416
410
  const property = Object.assign({}, context, { object: undefined })
417
- return `${g(property)} of ${g({ ...context.object, paraphrase: true })}`
411
+ return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
418
412
  }
419
413
  },
420
414
  {
@@ -422,25 +416,25 @@ let configStruct = {
422
416
  where: where(),
423
417
  // match: ({context}) => context.paraphrase && !context.modifiers && context.object,
424
418
  match: ({context}) => !context.modifiers && context.object,
425
- apply: ({context, g, gs}) => {
419
+ apply: async ({context, g, gs}) => {
426
420
  if (context.objects) {
427
421
  const objects = [ ...context.objects ]
428
422
  objects.reverse()
429
423
  let phrase = ''
430
424
  let separator = ''
431
425
  for (let i = 0; i < objects.length-1; ++i) {
432
- phrase = phrase + separator + g({...objects[i], paraphrase: context.paraphrase, possessive: true})
426
+ phrase = phrase + separator + await g({...objects[i], paraphrase: context.paraphrase, possessive: true})
433
427
  separator = ' '
434
428
  }
435
- phrase = phrase + separator + g({...objects[objects.length-1], paraphrase: context.paraphrase})
429
+ phrase = phrase + separator + await g({...objects[objects.length-1], paraphrase: context.paraphrase})
436
430
  return phrase
437
431
  } else {
438
432
  const base = { ...context }
439
433
  base.object = undefined; // TODO make paraphrase be a default when paraphrasing?
440
434
  if (context.object.marker == 'objectPrefix') {
441
- return `${g(context.object)} ${g(base)}`
435
+ return `${await g(context.object)} ${await g(base)}`
442
436
  } else {
443
- return `${g({...context.object, paraphrase: context.paraphrase})}'s ${g(base)}`
437
+ return `${await g({...context.object, paraphrase: context.paraphrase})}'s ${await g(base)}`
444
438
  }
445
439
  }
446
440
  },
@@ -534,15 +528,15 @@ let configStruct = {
534
528
  notes: 'greg has eyes?',
535
529
  where: where(),
536
530
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
537
- apply: ({context, g, api, objects}) => {
531
+ apply: async ({context, g, api, objects}) => {
538
532
  const object = pluralize.singular(context.object.value);
539
533
  const property = pluralize.singular(context.property.value);
540
534
  context.isResponse = true
541
- if (!api.knownObject(object)) {
542
- 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})}`
543
537
  return
544
538
  }
545
- if (!api.hasProperty(object, property)) {
539
+ if (!await api.hasProperty(object, property)) {
546
540
  context.evalue = {
547
541
  marker: 'yesno',
548
542
  value: false,
@@ -561,7 +555,7 @@ let configStruct = {
561
555
  where: where(),
562
556
  // match: ({context}) => context.marker == 'property' && context.same && context.object,
563
557
  match: ({context, hierarchy, uuid}) => hierarchy.isA(context.marker, 'property') && context.same && context.objects && !context[`disable${uuid}`],
564
- apply: ({context, objects, km, api, log, s, uuid}) => {
558
+ apply: async ({context, fragments, objects, km, api, log, s, uuid}) => {
565
559
  const objectContext = context.object;
566
560
  const propertyContext = context;
567
561
  const objectId = context.object.value
@@ -576,7 +570,7 @@ let configStruct = {
576
570
  // greg HERE
577
571
  */
578
572
  propertyContext[`disable${uuid}`] = true
579
- const propertyId = km("dialogues").api.evaluateToConcept(propertyContext, context, log, s).evalue;
573
+ const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
580
574
  try{
581
575
  // greg
582
576
  // api.makeObject({config, context: objectContext, doPluralize: false})
@@ -588,8 +582,8 @@ let configStruct = {
588
582
  } catch (e) {
589
583
  log(`Error processing set property of an object: ${e}`)
590
584
  const config = km('properties')
591
- const fragment = config.fragment("the property1 of object1 is value1")
592
- const value = api.getProperty(objectId, propertyId)
585
+ const fragment = fragments("the property1 of object1 is value1")
586
+ const value = await api.getProperty(objectId, propertyId)
593
587
  if (value.value == context.same.value) {
594
588
  context.evalue = [
595
589
  { marker: 'yesno', value: true, paraphrase: true },
@@ -620,7 +614,7 @@ let configStruct = {
620
614
  context.evalue = [
621
615
  { marker: 'yesno', value: false, paraphrase: true },
622
616
  ]
623
- context.evalue = context.evalue.concat(fragment.instantiate(mappings))
617
+ context.evalue = context.evalue.concat(await fragment.instantiate(mappings))
624
618
  context.evalue.forEach( (r) => r.paraphrase = true )
625
619
  context.isResponse = true
626
620
  context.sameWasProcessed = true
@@ -638,48 +632,47 @@ let configStruct = {
638
632
  !context.evaluate.toConcept, // && !context.value,
639
633
  // greghere
640
634
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
641
- apply: ({context, api, kms, objects, g, s, log}) => {
635
+ apply: async ({context, api, kms, objects, g, s, log}) => {
642
636
  const toDo = [ ...context.objects ]
643
637
 
644
- const toValue = (objectContext) => {
638
+ const toValue = async (objectContext) => {
645
639
  if (!objectContext.value) {
646
640
  return objectContext;
647
641
  }
648
642
  let objectValue = kms.stm.api.getVariable(objectContext.value);
649
- if (!api.knownObject(objectValue)) {
650
- 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})}"`
651
645
  return
652
646
  }
653
647
  return objectValue
654
648
  }
655
649
 
656
650
  let currentContext = toDo.pop()
657
- let currentValue = toValue(currentContext)
651
+ let currentValue = await toValue(currentContext)
658
652
  while (toDo.length > 0) {
659
653
  const nextContext = toDo.pop()
660
- const nextValue = toValue(nextContext)
654
+ const nextValue = await toValue(nextContext)
661
655
  if (!nextValue) {
662
656
  // TODO maybe this I aware so it can say "I don't know about blah..." and below
663
657
  // if (currentContext.unknown || !currentContext.value) {
664
658
  if (!api.conceptExists(currentContext.value)) {
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
- api.knownProperty(currentContext, nextContext)
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,
697
+ context: defaultContextCheck(),
698
+ /*
711
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,
@@ -1,14 +1,15 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const gdefaults = require('./gdefaults')
4
4
  const punctuation_tests = require('./punctuation.test.json')
5
5
 
6
- let configStruct = {
6
+ let config = {
7
7
  name: 'punctuation',
8
8
  operators: [
9
9
  "([leftParenthesis|] (phrase) ([rightParenthesis|]))",
10
10
  "((before) [comma|])", // comma applies if before is dead
11
11
  "([colon|])",
12
+ "((sentence) <endOfSentence|>)",
12
13
  "([doubleQuote|] (!doubleQuote/*)* (doubleQuote/*))",
13
14
  ],
14
15
  bridges: [
@@ -30,7 +31,14 @@ let configStruct = {
30
31
  bridge: "{ ...next(operator) }",
31
32
  words: [{ word: ")", value: ')', depth: '-' }],
32
33
  },
33
- { id: "colon", words: [':'], },
34
+ {
35
+ id: "colon",
36
+ words: [':'],
37
+ },
38
+ {
39
+ id: "endOfSentence", words: ['.'],
40
+ bridge: "{ ...before, postModifiers: append(before.postModifiers, ['endOfSentence']), endOfSentence: operator }",
41
+ },
34
42
  {
35
43
  id: "doubleQuote",
36
44
  level: 0,
@@ -45,22 +53,22 @@ let configStruct = {
45
53
  where: where(),
46
54
  priority: -1,
47
55
  match: ({context}) => context.parenthesis == '(',
48
- apply: ({context, g}) => `(${g({ ...context, parenthesis: null })})`
56
+ apply: async ({context, g}) => `(${await g({ ...context, parenthesis: null })})`
49
57
  },
50
58
  ],
51
59
  };
52
60
 
53
- const createConfig = () => new Config(configStruct, module).add(gdefaults())
54
-
55
61
  knowledgeModule( {
62
+ config,
63
+ includes: [gdefaults],
64
+
56
65
  module,
57
- createConfig,
58
66
  description: 'punctuation',
59
67
  test: {
60
68
  name: './punctuation.test.json',
61
69
  contents: punctuation_tests,
62
70
  checks: {
63
- context: defaultContextCheck,
71
+ context: defaultContextCheck(),
64
72
  },
65
73
  },
66
74
  })