ekms 8.0.0-beta.20 → 8.0.0-beta.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/common/animals.instance.json +0 -88
  2. package/common/animals.js +2 -2
  3. package/common/avatar.js +2 -2
  4. package/common/characters.js +12 -16
  5. package/common/colors.instance.json +0 -344
  6. package/common/colors.js +2 -2
  7. package/common/comparable.js +2 -15
  8. package/common/concept.js +13 -10
  9. package/common/countable.js +5 -5
  10. package/common/crew.instance.json +0 -416
  11. package/common/crew.js +4 -4
  12. package/common/currency.js +7 -7
  13. package/common/dialogues.js +52 -121
  14. package/common/dimension.instance.json +4 -4
  15. package/common/dimension.js +12 -12
  16. package/common/dimension.test.json +242 -1248
  17. package/common/edible.instance.json +30 -134
  18. package/common/edible.js +2 -2
  19. package/common/emotions.instance.json +0 -60
  20. package/common/emotions.js +4 -4
  21. package/common/events.js +6 -6
  22. package/common/fastfood.instance.json +929 -1408
  23. package/common/fastfood.js +24 -24
  24. package/common/formulas.instance.json +6 -6
  25. package/common/formulas.js +12 -12
  26. package/common/gdefaults.js +13 -13
  27. package/common/help.js +4 -4
  28. package/common/helpers/concept.js +0 -1
  29. package/common/helpers/dialogues.js +2 -3
  30. package/common/helpers/properties.js +48 -58
  31. package/common/hierarchy.js +12 -16
  32. package/common/javascript.js +8 -8
  33. package/common/kirk.js +2 -2
  34. package/common/length.instance.json +0 -60
  35. package/common/length.js +2 -2
  36. package/common/math.instance.json +12 -12
  37. package/common/math.js +7 -7
  38. package/common/meta.js +22 -29
  39. package/common/negation.js +1 -1
  40. package/common/numbers.js +2 -2
  41. package/common/ordering.js +5 -5
  42. package/common/people.js +4 -5
  43. package/common/percentages.js +4 -4
  44. package/common/pipboy.instance.json +30 -154
  45. package/common/pipboy.js +29 -32
  46. package/common/pokemon.instance.json +0 -44
  47. package/common/pokemon.js +4 -4
  48. package/common/pos.js +1 -1
  49. package/common/pressure.js +2 -2
  50. package/common/properties.js +52 -125
  51. package/common/punctuation.js +2 -2
  52. package/common/reports.instance.json +1 -1
  53. package/common/reports.js +59 -76
  54. package/common/scorekeeper.js +13 -21
  55. package/common/sdefaults.js +5 -5
  56. package/common/sizeable.js +2 -2
  57. package/common/spock.js +2 -2
  58. package/common/stgame.js +13 -9
  59. package/common/stm.js +4 -4
  60. package/common/tell.js +10 -10
  61. package/common/temperature.instance.json +0 -60
  62. package/common/temperature.js +2 -2
  63. package/common/tester.js +2 -2
  64. package/common/testing.js +5 -5
  65. package/common/time.js +7 -7
  66. package/common/tokenize.js +1 -1
  67. package/common/ui.js +9 -9
  68. package/common/weight.js +2 -2
  69. package/common/yesno.js +1 -1
  70. package/package.json +2 -2
@@ -216,7 +216,7 @@ const template = {
216
216
  {
217
217
  where: where(),
218
218
  match: ({context}) => false && context.marker == 'combo' && context.comboNumber,
219
- apply: ({context, g}) => g(context.comboNumber),
219
+ apply: async ({context, g}) => await g(context.comboNumber),
220
220
  }
221
221
  ],
222
222
  bridges: [
@@ -225,7 +225,7 @@ const template = {
225
225
  id: 'withModification',
226
226
  level: 0,
227
227
  before: ['preposition'],
228
- generatorp: ({context, gp}) => `with ${gp(context.modifications)}`,
228
+ generatorp: async ({context, gp}) => `with ${await gp(context.modifications)}`,
229
229
  bridge: "{ ...next(operator), modifications: after[0], flatten: false }",
230
230
  },
231
231
  {
@@ -287,18 +287,16 @@ const template = {
287
287
  {
288
288
  // split "sprite and fanta" into separate things so the ask will pick them up
289
289
  match: ({context}) => context.marker == 'list' && context.topLevel && !context.flatten,
290
- apply: ({context, s}) => {
291
- s({...context, flatten: true})
292
- }
290
+ apply: async ({context, s}) => await s({...context, flatten: true}),
293
291
  },
294
292
  {
295
293
  where: where(),
296
294
  match: ({context, api}) => context.marker == 'controlEnd' && api.hasAskedForButNotAvailable(),
297
- apply: ({context, api, gp, toContext, verbatim}) => {
295
+ apply: async ({context, api, gp, toContext, verbatim}) => {
298
296
  const naArray = api.getAskedForButNotAvailable()
299
297
  naArray.forEach((f) => f.paraphrase = true)
300
298
  const naContext = toContext(naArray)
301
- verbatim(`The following are not menu items: ${gp(naContext)}`)
299
+ verbatim(`The following are not menu items: ${await gp(naContext)}`)
302
300
  // allow other motivation to run
303
301
  context.cascade = true
304
302
  }
@@ -306,11 +304,13 @@ const template = {
306
304
  {
307
305
  where: where(),
308
306
  match: ({context, api}) => context.marker == 'controlEnd' && api.hasAskedForButNotAvailableModification(),
309
- apply: ({context, api, gp, toContext, verbatim}) => {
310
- const naArray = api.getAskedForButNotAvailableModification().map(({ item, modification }) => {
307
+ apply: async ({context, api, gp, toContext, verbatim}) => {
308
+ const naArray = []
309
+ for (const args of api.getAskedForButNotAvailableModification()) {
310
+ const args = { item, modification }
311
311
  // return `${gp(item)} can not be modified with ${gp(modification)}.`
312
- return `XXX can not be modified with ${gp(modification)}.`
313
- })
312
+ naArray.push(`XXX can not be modified with ${await gp(modification)}.`)
313
+ }
314
314
  verbatim(naArray.join(' '))
315
315
  // allow other motivation to run
316
316
  context.cascade = true
@@ -413,11 +413,11 @@ const template = {
413
413
  id: "change",
414
414
  isA: ['verby'],
415
415
  localHierarchy: [ ['thisitthat', 'meal'] ],
416
- generatorp: ({context, gp}) => `change ${gp(context.from)} to ${gp(context.to)}`,
416
+ generatorp: async ({context, gp}) => `change ${await gp(context.from)} to ${await gp(context.to)}`,
417
417
  bridge: "{ ...next(operator), from: after[0], to: after[1].toObject }",
418
- semantic: ({context, api, e}) => {
418
+ semantic: async ({context, api, e}) => {
419
419
  const state = api.state
420
- const eFrom = e(context.from).evalue
420
+ const eFrom = (await e(context.from)).evalue
421
421
  const from = state.getIdCombo(eFrom.fromSTM ? eFrom : context.from)
422
422
  const to = state.getIdCombo(context.to)
423
423
  for (const item of api.items()) {
@@ -887,8 +887,8 @@ class State {
887
887
  {
888
888
  where: where(),
889
889
  match: ({context, isA}) => isA(context.marker, 'number') && !context.evaluate,
890
- apply: ({context, e}) => {
891
- food.comboNumber = { value: e(context).value }
890
+ apply: async ({context, e}) => {
891
+ food.comboNumber = { value: (await e(context)).value }
892
892
  this.add(Object.assign(food, context))
893
893
  }
894
894
  },
@@ -935,7 +935,7 @@ class State {
935
935
  }
936
936
  }
937
937
 
938
- const createConfig = (additionalConfig) => {
938
+ const createConfig = async (additionalConfig) => {
939
939
  const config = new Config({
940
940
  name: 'fastfood',
941
941
  operators: [
@@ -949,10 +949,10 @@ const createConfig = (additionalConfig) => {
949
949
  where: where(),
950
950
  priority: -10,
951
951
  match: ({context}) => context.marker == 'compound_operator',
952
- apply: ({context, s}) => {
952
+ apply: async ({context, s}) => {
953
953
  context.marker = 'list'
954
954
  context.flatten = true
955
- s(context)
955
+ await s(context)
956
956
  }
957
957
  },
958
958
  {
@@ -979,7 +979,7 @@ const createConfig = (additionalConfig) => {
979
979
  id: 'showOrder',
980
980
  parents: ['verby'],
981
981
  bridge: "{ ...next(operator), order: after[0] }",
982
- generatorp: ({context, g}) => `show ${g(context.order)}`,
982
+ generatorp: async ({context, g}) => `show ${await g(context.order)}`,
983
983
  semantic: ({api}) => {
984
984
  api.state.show()
985
985
  },
@@ -987,15 +987,15 @@ const createConfig = (additionalConfig) => {
987
987
  ],
988
988
  }, module)
989
989
  config.stop_auto_rebuild()
990
- config.add(edible(), countable(), events(), sizeable())
991
- config.api = api
992
- config.initializer( ({api}) => {
990
+ await config.add(edible, countable, events, sizeable)
991
+ await config.setApi(api)
992
+ await config.initializer( ({api}) => {
993
993
  api.state = new State(api)
994
994
  })
995
995
  if (additionalConfig) {
996
996
  additionalConfig(config)
997
997
  }
998
- config.restart_auto_rebuild()
998
+ await config.restart_auto_rebuild()
999
999
  return config
1000
1000
  }
1001
1001
 
@@ -31,7 +31,7 @@
31
31
  {
32
32
  "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:109",
33
33
  "match": "({context, api}) => context.evaluate && api.get(context)",
34
- "apply": "({context, api, e}) => {\n const { formula } = api.get(context)\n // console.log('greg24 -----------', JSON.stringify(formula, null, 2))\n context.evalue = e(formula) \n }"
34
+ "apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n // console.log('greg24 -----------', JSON.stringify(formula, null, 2))\n context.evalue = await e(formula) \n }"
35
35
  }
36
36
  ],
37
37
  "bridges": [
@@ -44,14 +44,14 @@
44
44
  ],
45
45
  "convolution": true,
46
46
  "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
47
- "generatorp": "({context, g}) => `${g(context.what)} ${g(context.equality)} ${g(context.variable)}`",
47
+ "generatorp": "async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`",
48
48
  "evaluator": "({context, api, objects}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n context.evalue = { marker: 'list', value: formulas }\n }"
49
49
  },
50
50
  {
51
51
  "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:132",
52
52
  "id": "solve",
53
53
  "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
54
- "generatorp": "({context, gp}) => `${context.word} ${gp(context.equality)} for ${gp(context.variable)}`",
54
+ "generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`",
55
55
  "semantic": "({context}) => {\n context.response = solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n if (!context.response) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }"
56
56
  },
57
57
  {
@@ -80,14 +80,14 @@
80
80
  "verby"
81
81
  ],
82
82
  "bridge": "{ ...next(operator), expression: after[0] }",
83
- "generatorp": "({context, g}) => `${context.word} ${g(context.expression)}`",
83
+ "generatorp": "async ({context, g}) => `${context.word} ${await g(context.expression)}`",
84
84
  "localHierarchy": [
85
85
  [
86
86
  "unknown",
87
87
  "expression"
88
88
  ]
89
89
  ],
90
- "semantic": "({context, e}) => {\n context.evalue = e(context.expression)\n context.isResponse = true\n }"
90
+ "semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression)\n context.isResponse = true\n }"
91
91
  },
92
92
  {
93
93
  "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:171",
@@ -105,7 +105,7 @@
105
105
  "expression"
106
106
  ]
107
107
  ],
108
- "generatorp": "({context, gp}) => `${gp(context.left)} ${context.word} ${gp(context.right)}`",
108
+ "generatorp": "async ({context, gp}) => `${await gp(context.left)} ${context.word} ${await gp(context.right)}`",
109
109
  "semantic": "({context, api}) => {\n // TODO make sure left is a single name\n // TODO calculate invertable formulas?\n api.add(context.left, context.right, context)\n }"
110
110
  }
111
111
  ]
@@ -108,10 +108,10 @@ let configStruct = {
108
108
  {
109
109
  where: where(),
110
110
  match: ({context, api}) => context.evaluate && api.get(context),
111
- apply: ({context, api, e}) => {
111
+ apply: async ({context, api, e}) => {
112
112
  const { formula } = api.get(context)
113
113
  // console.log('greg24 -----------', JSON.stringify(formula, null, 2))
114
- context.evalue = e(formula)
114
+ context.evalue = await e(formula)
115
115
  }
116
116
  },
117
117
  ],
@@ -122,7 +122,7 @@ let configStruct = {
122
122
  isA: ['preposition', 'queryable'],
123
123
  convolution: true,
124
124
  bridge: "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
125
- generatorp: ({context, g}) => `${g(context.what)} ${g(context.equality)} ${g(context.variable)}`,
125
+ generatorp: async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`,
126
126
  evaluator: ({context, api, objects}) => {
127
127
  const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })
128
128
  context.evalue = { marker: 'list', value: formulas }
@@ -132,7 +132,7 @@ let configStruct = {
132
132
  where: where(),
133
133
  id: 'solve',
134
134
  bridge: "{ ...next(operator), equality: after[0], variable: after[2] }",
135
- generatorp: ({context, gp}) => `${context.word} ${gp(context.equality)} for ${gp(context.variable)}`,
135
+ generatorp: async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`,
136
136
  semantic: ({context}) => {
137
137
  context.response = solveFor(context.equality, context.variable)
138
138
  context.isResponse = true
@@ -160,10 +160,10 @@ let configStruct = {
160
160
  id: 'calculate',
161
161
  isA: ['verby'],
162
162
  bridge: "{ ...next(operator), expression: after[0] }",
163
- generatorp: ({context, g}) => `${context.word} ${g(context.expression)}`,
163
+ generatorp: async ({context, g}) => `${context.word} ${await g(context.expression)}`,
164
164
  localHierarchy: [ ['unknown', 'expression'] ],
165
- semantic: ({context, e}) => {
166
- context.evalue = e(context.expression)
165
+ semantic: async ({context, e}) => {
166
+ context.evalue = await e(context.expression)
167
167
  context.isResponse = true
168
168
  }
169
169
  },
@@ -175,7 +175,7 @@ let configStruct = {
175
175
  after: ['mathematical_operator'],
176
176
  // TODO have this be per argument then 'is' can map to equals where this only applied to before[0] and not after[0]
177
177
  localHierarchy: [ ['unknown', 'expression'] ],
178
- generatorp: ({context, gp}) => `${gp(context.left)} ${context.word} ${gp(context.right)}`,
178
+ generatorp: async ({context, gp}) => `${await gp(context.left)} ${context.word} ${await gp(context.right)}`,
179
179
  semantic: ({context, api}) => {
180
180
  // TODO make sure left is a single name
181
181
  // TODO calculate invertable formulas?
@@ -192,13 +192,13 @@ const template = {
192
192
  ]
193
193
  }
194
194
 
195
- const createConfig = () => {
195
+ const createConfig = async () => {
196
196
  const api = new API()
197
197
  config = new Config({ name: 'formulas' }, module)
198
198
  config.stop_auto_rebuild()
199
- config.add(dialogues(), pos(), math(), hierarchy(), comparable(), countable())
200
- config.api = api
201
- config.restart_auto_rebuild()
199
+ await config.add(dialogues, pos, math, hierarchy, comparable, countable)
200
+ await config.setApi(api)
201
+ await config.restart_auto_rebuild()
202
202
  return config
203
203
  }
204
204
 
@@ -28,15 +28,15 @@ let configStruct = {
28
28
  //({context}) => context.paraphrase && context.modifiers,
29
29
  // match: ({context}) => context.paraphrase && (context.modifiers || context.postModifiers),
30
30
  match: ({context}) => (context.modifiers || context.postModifiers),
31
- apply: ({context, g, gs, callId}) => {
31
+ apply: async ({context, g, callId}) => {
32
32
  const text = []
33
33
  for (modifier of (context.modifiers || [])) {
34
34
  if (Array.isArray(context[modifier])) {
35
35
  for (let m of context[modifier]) {
36
- text.push(g(m))
36
+ text.push(await g(m))
37
37
  }
38
38
  } else {
39
- text.push(g(context[modifier], { isModifier: true }))
39
+ text.push(await g(context[modifier], { isModifier: true }))
40
40
  }
41
41
  }
42
42
  // text.push(context.word)
@@ -47,15 +47,15 @@ let configStruct = {
47
47
  number = isMany(context) ? 'many' : 'one'
48
48
  }
49
49
  if (context.postModifiers) {
50
- text.push(g({...context, number: 'one', postModifiers: undefined, modifiers: undefined}))
50
+ text.push(await g({...context, number: 'one', postModifiers: undefined, modifiers: undefined}))
51
51
  } else {
52
- text.push(g({...context, number, postModifiers: undefined, modifiers: undefined}))
52
+ text.push(await g({...context, number, postModifiers: undefined, modifiers: undefined}))
53
53
  }
54
54
  for ([index, modifier] of (context.postModifiers || []).entries()) {
55
55
  if (index == context.postModifiers.length - 1) {
56
- text.push(g({...context[modifier], number}))
56
+ text.push(await g({...context[modifier], number}))
57
57
  } else {
58
- text.push(g(context[modifier]))
58
+ text.push(await g(context[modifier]))
59
59
  }
60
60
  }
61
61
  return text.join(' ')
@@ -134,19 +134,19 @@ let configStruct = {
134
134
  {
135
135
  where: where(),
136
136
  match: ({context}) => context.evalue,
137
- apply: ({context, g}) => g(context.evalue)
137
+ apply: async ({context, g}) => await g(context.evalue)
138
138
  },
139
139
 
140
140
  {
141
141
  where: where(),
142
142
  match: ({context}) => context.value && Array.isArray(context.value),
143
- apply: ({context, gs}) => gs(context.value)
143
+ apply: async ({context, gs}) => await gs(context.value)
144
144
  },
145
145
 
146
146
  {
147
147
  where: where(),
148
148
  match: ({context}) => context.value,
149
- apply: ({context, g}) => g(context.value)
149
+ apply: async ({context, g}) => await g(context.value)
150
150
  },
151
151
 
152
152
  {
@@ -181,10 +181,10 @@ let configStruct = {
181
181
  ],
182
182
  };
183
183
 
184
- const createConfig = () => {
184
+ const createConfig = async () => {
185
185
  const config = new Config(configStruct, module)
186
- config.add(tokenize())
187
- config.initializer( ({config}) => {
186
+ await config.add(tokenize)
187
+ await config.initializer( ({config}) => {
188
188
  config.addArgs((args) => {
189
189
  return {
190
190
  number: (context) => isMany(context) ? "many" : "one",
package/common/help.js CHANGED
@@ -82,12 +82,12 @@ const configStruct = {
82
82
  },
83
83
  };
84
84
 
85
- const createConfig = () => {
85
+ const createConfig = async () => {
86
86
  const config = new Config(configStruct, module)
87
87
  config.stop_auto_rebuild()
88
- config.add(dialogues())
88
+ await config.add(dialogues)
89
89
 
90
- config.initializer( ({ config, addWord, kms }) => {
90
+ await config.initializer( ({ config, addWord, kms }) => {
91
91
  const names = new Set()
92
92
  for (let name in kms) {
93
93
  names.add(name);
@@ -96,7 +96,7 @@ const createConfig = () => {
96
96
  addWord(name, {id: "km", initial: `{ value: '${name}', word: '${name}' }`})
97
97
  }
98
98
  })
99
- config.restart_auto_rebuild()
99
+ await config.restart_auto_rebuild()
100
100
  return config
101
101
  }
102
102
 
@@ -86,7 +86,6 @@ class API {
86
86
  })
87
87
  // modifierds.forEach((modifierId) => config.addWord(modifierId, { id: modifierId, initial: `{ value: '${modifierId}' }`}))
88
88
 
89
- debugger
90
89
  modifierIds.forEach((modifierId) => config.addBridge({ id: modifierId, level: 0, bridge: `{ ...next(operator), value: '${modifierId}' }`, allowDups: true }))
91
90
  config.addBridge({ id: objectId, level: 0, bridge: `{ ...next(operator), value: '${objectId}' }`, allowDups: true })
92
91
  // config.addBridge({ id: modifierObjectId, level: 0, bridge: `{ ...next(operator), value: '${modifierObjectId}' }`, allowDups: true })
@@ -50,10 +50,9 @@ class API {
50
50
  return this._objects.brief
51
51
  }
52
52
 
53
- evaluateToConcept(value, context, log, s) {
53
+ async evaluateToConcept(value, context, log, s) {
54
54
  value.evaluate = { toConcept: true }
55
- // const concept = s(value, { debug: { apply: true } })
56
- const concept = s(value)
55
+ const concept = await s(value)
57
56
  if (!concept.evalue && !concept.verbatim) {
58
57
  this.warningNotEvaluated(log, value);
59
58
  concept.evalue = concept.value
@@ -136,7 +136,7 @@ class API {
136
136
  notes: 'semantic for setting value with constraint',
137
137
  match: ({context, isA}) => isA(context.marker, after[0].tag) && context.evaluate && context.constraints,
138
138
  // match: ({context, isA}) => context.marker == after[0].tag && context.evaluate,
139
- apply: ({km, context, e, log, isA, s}) => {
139
+ apply: async ({km, context, e, log, isA}) => {
140
140
  const constraint = context.constraints[0];
141
141
  const value = constraint.constraint;
142
142
  let property = constraint.property;
@@ -151,7 +151,7 @@ class API {
151
151
  // value.greg = true
152
152
  // value.ownee.query = true
153
153
  value.query = true
154
- let instance = e(value)
154
+ let instance = await e(value)
155
155
  if (instance.verbatim) {
156
156
  context.evalue = { verbatim: instance.verbatim }
157
157
  return
@@ -168,13 +168,13 @@ class API {
168
168
  config.addGenerator({
169
169
  notes: 'generator for constraint',
170
170
  match: ({context}) => context.marker == edAble.operator && context.paraphrase && context.constrained,
171
- apply: ({context, g}) => {
171
+ apply: async ({context, g}) => {
172
172
  if (context[before[0].tag].marker == 'by') {
173
173
  // the cat wendy owned
174
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${g({...context[before[0].tag], paraphrase: true})}`
174
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${await g({...context[before[0].tag], paraphrase: true})}`
175
175
  } else {
176
176
  // the cat owned by wendy
177
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
177
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', await g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
178
178
  }
179
179
  },
180
180
  })
@@ -194,19 +194,19 @@ class API {
194
194
 
195
195
  return false;
196
196
  },
197
- apply: ({context, g}) => {
197
+ apply: async ({context, g}) => {
198
198
  const chosen = chooseNumber(context, word.singular, word.plural)
199
- return `${g(context[before[0].tag])} ${chosen} ${g(context[after[0].tag])}`
199
+ return `${await g(context[before[0].tag])} ${chosen} ${await g(context[after[0].tag])}`
200
200
  }
201
201
  })
202
202
  config.addGenerator({
203
203
  match: ({context}) => context.marker == edAble.operator && context.isEd,
204
- apply: ({context, g}) => {
204
+ apply: async ({context, g}) => {
205
205
  const chosen = chooseNumber(context[after[0].tag], 'is', 'are')
206
206
  if (context[before[0].tag].evalue && context[before[0].tag].evalue.marker == 'answerNotKnown') {
207
- return g(context[before[0].tag])
207
+ return await g(context[before[0].tag])
208
208
  }
209
- return `${g(context[after[0].tag])} ${chosen} ${edAble.word} by ${g(context[before[0].tag])}`
209
+ return `${await g(context[after[0].tag])} ${chosen} ${edAble.word} by ${await g(context[before[0].tag])}`
210
210
  }
211
211
  })
212
212
  /*
@@ -250,7 +250,7 @@ class API {
250
250
  notes: `generator for who/what is X owned by`,
251
251
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == 'ownee' && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == 'owned' && context.one.constraints[0].constraint.owner.implicit,
252
252
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == after[0].tag && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == edAble.operator && context.one.constraints[0].constraint[before[0].tag].implicit,
253
- apply: ({context, g, gs, callId}) => {
253
+ apply: async ({context, g, gs, callId}) => {
254
254
  const isToFromM = [{"from":["one"],"to":["two"]},{"from":["two"],"to":["one"]}]
255
255
  const fromF = config.fragment(whoIsWhatVerbedBy).contexts()[0]
256
256
  // const fromF = config.fragment[before[0].tag]"ownerVar is owneeVar owned by").contexts()[0]
@@ -269,11 +269,11 @@ class API {
269
269
  // const from = context.one.constraints[0].constraint
270
270
  const from = context
271
271
  const im = translationMappingToInstantiatorMappings(tmPrime, from, to)
272
- const translation = toF.instantiate(im)
272
+ const translation = await toF.instantiate(im)
273
273
  if (Array.isArray(translation)) {
274
- return gs(translation)
274
+ return await gs(translation)
275
275
  } else {
276
- return g(translation)
276
+ return await g(translation)
277
277
  }
278
278
  }
279
279
  }
@@ -383,11 +383,16 @@ class API {
383
383
  config.addGenerator({
384
384
  notes: 'ordering generator for paraphrase',
385
385
  match: ({context}) => context.marker == operator && context.paraphrase && !context.query,
386
- apply: ({context, gp, g}) => {
387
- const beforeGenerator = before.map( (arg) => g(context[arg.tag]) )
388
- const afterGenerator = after.map( (arg) => gp(context[arg.tag]) )
386
+ apply: async ({context, gp, g}) => {
387
+ const beforeGenerator = []
388
+ for (const arg of before) {
389
+ beforeGenerator.push(await g(context[arg.tag]))
390
+ }
391
+ const afterGenerator = []
392
+ for (const arg of after) {
393
+ afterGenerator.push(await gp(context[arg.tag]))
394
+ }
389
395
  const word = context.word
390
- // return beforeGenerator.concat([`${context.word}`]).concat(afterGenerator).join(' ')
391
396
  const sub = []
392
397
  if (context.subphrase) {
393
398
  sub.push(['that'])
@@ -399,7 +404,7 @@ class API {
399
404
  config.addGenerator({
400
405
  notes: 'ordering generator for response',
401
406
  match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
402
- apply: ({context, g, km}) => {
407
+ apply: async ({context, g, km}) => {
403
408
  const brief = km("dialogues").api.getBrief()
404
409
 
405
410
  const { evalue } = context
@@ -414,7 +419,7 @@ class API {
414
419
  if (evalue.truthValueOnly || brief) {
415
420
  return `${yesno}`
416
421
  } else {
417
- return `${yesno} ${g(Object.assign({}, evalue, { paraphrase: true }))}`
422
+ return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
418
423
  }
419
424
  }
420
425
  })
@@ -628,8 +633,8 @@ class API {
628
633
  setValue: ([object, property], value, has) => {
629
634
  return this.setProperty(object, property, value, has, true)
630
635
  },
631
- getValue: ([object, property]) => {
632
- return this.getPropertyDirectly(object, property)
636
+ getValue: async ([object, property]) => {
637
+ return await this.getPropertyDirectly(object, property)
633
638
  },
634
639
  })
635
640
  }
@@ -645,16 +650,18 @@ class API {
645
650
  error.code = 'ReadOnly'
646
651
  throw error
647
652
  },
648
- getValue: ([object, property]) => {
649
- return this.getPropertyDirectly(object, property)
653
+ getValue: async ([object, property]) => {
654
+ return await this.getPropertyDirectly(object, property)
650
655
  },
651
656
  })
652
657
  this.propertiesFH.setHandler(path, handler)
653
658
  }
654
659
 
655
- getObject(object) {
660
+ /*
661
+ async getObject(object) {
656
662
  return this.propertiesFH.getValue([object])
657
663
  }
664
+ */
658
665
 
659
666
  getHandler(object, property) {
660
667
  return this.propertiesFH.getHandler([object, property])
@@ -671,34 +678,33 @@ class API {
671
678
  // return context.value
672
679
  }
673
680
 
674
- getProperty(object, property, g) {
681
+ async getProperty(object, property, g) {
675
682
  object = this.toValue(object)
676
683
  property = this.toValue(property)
677
684
  const handler = this.propertiesFH.getHandler([object, property])
678
685
  if (handler) {
679
- return handler.getValue([object, property])
686
+ return await handler.getValue([object, property])
680
687
  }
681
- return this.getPropertyDirectly(object, property, g)
688
+ return await this.getPropertyDirectly(object, property, g)
682
689
  }
683
690
 
684
- getPropertyDirectly(object, property, g) {
691
+ async getPropertyDirectly(object, property, g) {
685
692
  if (property == 'property') {
686
- const objectProps = this.propertiesFH.getValue([object])
693
+ const objectProps = await this.propertiesFH.getValue([object])
687
694
  const values = []
688
695
  for (let key of Object.keys(objectProps)) {
689
696
  if (objectProps[key].has) {
690
- // values.push(`${g(key)}: ${g({ ...objectProps[key].value, evaluate: true })}`)
691
- values.push(`${g(key)}: ${g({ ...objectProps[key].value, paraphrase: true })}`)
697
+ values.push(`${await g(key)}: ${await g({ ...objectProps[key].value, paraphrase: true })}`)
692
698
  }
693
699
  }
694
700
  return { marker: 'list', value: values }
695
701
  } else {
696
- return this.propertiesFH.getValue([object, property]).value
702
+ return (await this.propertiesFH.getValue([object, property])).value
697
703
  }
698
704
  }
699
705
 
700
- hasProperty(object, property, has) {
701
- return this.propertiesFH.getValue([object, property]).has
706
+ async hasProperty(object, property, has) {
707
+ return (await this.propertiesFH.getValue([object, property])).has
702
708
  }
703
709
 
704
710
  setProperty(object, property, value, has, skipHandler) {
@@ -726,7 +732,7 @@ class API {
726
732
  }
727
733
  }
728
734
 
729
- knownObject(object) {
735
+ async knownObject(object) {
730
736
  if (object == 'property') {
731
737
  return object
732
738
  }
@@ -735,10 +741,10 @@ class API {
735
741
  }
736
742
  const path = [object]
737
743
  // return this.knownPropertyNew(path)
738
- return this.propertiesFH.knownProperty(path)
744
+ return await this.propertiesFH.knownProperty(path)
739
745
  }
740
746
 
741
- hasProperty(object, property) {
747
+ async hasProperty(object, property) {
742
748
  if (property == 'property') {
743
749
  return true;
744
750
  }
@@ -748,7 +754,7 @@ class API {
748
754
  const seen = [object];
749
755
  while (todo.length > 0) {
750
756
  const next = todo.pop();
751
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
757
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
752
758
  return true
753
759
  }
754
760
  const parents = this._objects.parents[next] || [];
@@ -763,11 +769,11 @@ class API {
763
769
  }
764
770
 
765
771
  // NOT DONE
766
- knownProperty(object, property) {
772
+ async knownProperty(object, property) {
767
773
  object = this.toValue(object)
768
774
  property = this.toValue(property)
769
775
  if (property == 'property') {
770
- const objectProps = this.propertiesFH.getValue([object])
776
+ const objectProps = await this.propertiesFH.getValue([object])
771
777
  return !_.isEmpty(objectProps)
772
778
  }
773
779
 
@@ -776,7 +782,7 @@ class API {
776
782
  const seen = [object];
777
783
  while (todo.length > 0) {
778
784
  const next = todo.pop();
779
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
785
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
780
786
  return true
781
787
  }
782
788
  const parents = this._objects.parents[next] || [];
@@ -911,22 +917,6 @@ class API {
911
917
 
912
918
  set config(config) {
913
919
  this._config = config
914
- /*
915
- const toJSON = (h) => {
916
- if (h.child && h.parent) {
917
- return h
918
- } else {
919
- return { child: h[0], parent: h[1] }
920
- }
921
- }
922
- for (const tuple of [...config().config.hierarchy]) {
923
- const h = toJSON(tuple);
924
- // TODO should this notice development flag?
925
- if (this.isOperator(h.child) && this.isOperator(h.parent)) {
926
- this.rememberIsA(h.child, h.parent)
927
- }
928
- }
929
- */
930
920
  }
931
921
 
932
922
  get config() {