ekms 8.0.0-beta.3 → 8.0.0-beta.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/common/animals.instance.json +2542 -1375
  2. package/common/animals.js +2 -2
  3. package/common/avatar.js +2 -2
  4. package/common/characters.js +9 -11
  5. package/common/colors.instance.json +6646 -3529
  6. package/common/colors.js +2 -2
  7. package/common/colors.test.json +345 -780
  8. package/common/comparable.js +2 -15
  9. package/common/concept.js +17 -11
  10. package/common/countable.js +5 -5
  11. package/common/crew.instance.json +12534 -6597
  12. package/common/crew.js +4 -4
  13. package/common/crew.test.json +714 -452
  14. package/common/currency.js +7 -7
  15. package/common/dialogues.js +53 -138
  16. package/common/dimension.instance.json +246 -265
  17. package/common/dimension.js +12 -12
  18. package/common/dimension.test.json +446 -1640
  19. package/common/edible.instance.json +19308 -10008
  20. package/common/edible.js +2 -2
  21. package/common/emotions.instance.json +122 -129
  22. package/common/emotions.js +4 -4
  23. package/common/events.js +6 -6
  24. package/common/fastfood.instance.json +219409 -111252
  25. package/common/fastfood.js +24 -24
  26. package/common/formulas.instance.json +222 -256
  27. package/common/formulas.js +14 -14
  28. package/common/gdefaults.js +13 -13
  29. package/common/help.js +4 -4
  30. package/common/help.test.json +10 -22
  31. package/common/helpers/concept.js +9 -6
  32. package/common/helpers/dialogues.js +2 -3
  33. package/common/helpers/properties.js +48 -58
  34. package/common/hierarchy.js +12 -16
  35. package/common/javascript.js +8 -8
  36. package/common/kirk.instance.json +564 -290
  37. package/common/kirk.js +2 -2
  38. package/common/length.instance.json +5153 -4677
  39. package/common/length.js +2 -2
  40. package/common/math.instance.json +152 -1169
  41. package/common/math.js +11 -11
  42. package/common/meta.js +22 -29
  43. package/common/negation.instance.json +2 -0
  44. package/common/negation.js +38 -0
  45. package/common/negation.test.json +308 -0
  46. package/common/numbers.js +3 -3
  47. package/common/ordering.instance.json +292 -230
  48. package/common/ordering.js +5 -5
  49. package/common/people.instance.json +1902 -1015
  50. package/common/people.js +4 -5
  51. package/common/percentages.instance.json +2 -0
  52. package/common/percentages.js +57 -0
  53. package/common/percentages.test.json +751 -0
  54. package/common/pipboy.instance.json +7720 -6386
  55. package/common/pipboy.js +29 -32
  56. package/common/pokemon.instance.json +3954 -2081
  57. package/common/pokemon.js +4 -4
  58. package/common/pos.js +1 -1
  59. package/common/pressure.instance.json +1265 -1193
  60. package/common/pressure.js +2 -2
  61. package/common/properties.instance.json +106 -61
  62. package/common/properties.js +54 -125
  63. package/common/punctuation.js +2 -2
  64. package/common/reports.instance.json +557 -559
  65. package/common/reports.js +54 -74
  66. package/common/scorekeeper.js +13 -21
  67. package/common/sdefaults.js +13 -3
  68. package/common/sizeable.js +2 -2
  69. package/common/spock.instance.json +564 -290
  70. package/common/spock.js +2 -2
  71. package/common/stgame.js +13 -9
  72. package/common/stm.js +4 -4
  73. package/common/tell.js +10 -10
  74. package/common/temperature.instance.json +1297 -1209
  75. package/common/temperature.js +2 -2
  76. package/common/tester.js +2 -2
  77. package/common/testing.js +5 -5
  78. package/common/time.js +7 -7
  79. package/common/tokenize.js +1 -1
  80. package/common/ui.instance.json +238 -259
  81. package/common/ui.js +9 -9
  82. package/common/weight.instance.json +4905 -4166
  83. package/common/weight.js +2 -2
  84. package/common/yesno.js +1 -1
  85. package/main.js +51 -46
  86. package/package.json +13 -6
@@ -102,16 +102,16 @@ let configStruct = {
102
102
  "(([expression]) [equals] ([expression]))",
103
103
  ],
104
104
  priorities: [
105
- { "context": [['mathematicalOperator', 0], ['number', 0], ], "choose": [0] },
105
+ { "context": [['mathematical_operator', 0], ['number', 0], ], "choose": [0] },
106
106
  ],
107
107
  semantics: [
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
  },
@@ -172,10 +172,10 @@ let configStruct = {
172
172
  id: 'equals',
173
173
  bridge: "{ ...next(operator), left: before[0], right: after[0] }",
174
174
  words: ['='],
175
- after: ['mathematicalOperator'],
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
 
@@ -19,24 +19,6 @@
19
19
  0
20
20
  ]
21
21
  ],
22
- [
23
- [
24
- "help",
25
- 0
26
- ],
27
- [
28
- "km",
29
- 0
30
- ],
31
- [
32
- "list",
33
- 0
34
- ],
35
- [
36
- "withKM",
37
- 0
38
- ]
39
- ],
40
22
  [
41
23
  [
42
24
  "help",
@@ -216,6 +198,7 @@
216
198
  "gdefaults": "gdefaults2",
217
199
  "help": "help1",
218
200
  "meta": "meta2",
201
+ "negation": "negation2",
219
202
  "pos": "pos2",
220
203
  "punctuation": "punctuation2",
221
204
  "sdefaults": "sdefaults2",
@@ -236,6 +219,8 @@
236
219
  },
237
220
  "meta2": {
238
221
  },
222
+ "negation2": {
223
+ },
239
224
  "pos2": {
240
225
  },
241
226
  "punctuation2": {
@@ -361,7 +346,7 @@
361
346
  }
362
347
  ],
363
348
  "generatedParenthesized": [
364
- "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)"
349
+ "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)"
365
350
  ],
366
351
  "metadata": {
367
352
  "opChoices": [
@@ -386,6 +371,7 @@
386
371
  "gdefaults": "gdefaults2",
387
372
  "help": "help1",
388
373
  "meta": "meta2",
374
+ "negation": "negation2",
389
375
  "pos": "pos2",
390
376
  "punctuation": "punctuation2",
391
377
  "sdefaults": "sdefaults2",
@@ -406,6 +392,8 @@
406
392
  },
407
393
  "meta2": {
408
394
  },
395
+ "negation2": {
396
+ },
409
397
  "pos2": {
410
398
  },
411
399
  "punctuation2": {
@@ -440,11 +428,11 @@
440
428
  "value": "help",
441
429
  "word": "help"
442
430
  },
443
- "generatedParenthesized": "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)",
431
+ "generatedParenthesized": "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)",
444
432
  "paraphrases": "help",
445
433
  "paraphrasesParenthesized": "(help)",
446
434
  "responses": [
447
- " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
435
+ " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
448
436
  ]
449
437
  }
450
438
  ]
@@ -457,7 +445,7 @@
457
445
  ],
458
446
  "query": "help",
459
447
  "responses": [
460
- " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
448
+ " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
461
449
  ]
462
450
  }
463
451
  ]
@@ -34,10 +34,9 @@ class API {
34
34
  // TODO make the modifiers objects then below for add words for modifiers only do if !unknown
35
35
  // const objectId = pluralize.singular(object)
36
36
  const objectId = this.args.kms.dialogues.api.toScopedId(object)
37
-
38
37
  // const modifierIds = modifiers.map( (modifier) => pluralize.singular(modifier) )
39
38
  const modifierIds = modifiers.map( (modifier) => this.args.kms.dialogues.api.toScopedId(modifier) )
40
- const modifiersObjectId = `${modifiers.join("_")}_${objectId}`
39
+ const modifiersObjectId = `${modifierIds.join("_")}_${objectId}`
41
40
 
42
41
  const toWord = (object) => {
43
42
  if (typeof object == 'string') {
@@ -76,11 +75,14 @@ class API {
76
75
  config.addWord(objectPlural, { id: objectId, initial: `{ value: '${objectId}', number: 'many' }`})
77
76
  }
78
77
 
79
- zip(modifiers, modifierIds).forEach(([modifierWord, modifierId]) => {
78
+ zip(modifiers, modifierIds).forEach(([modifier, modifierId]) => {
80
79
  // config.addWord(modifier, { id: modifierId, initial: `{ value: '${modifierId}' }`})
81
80
  // TODO call evaluator to pick up overrides
82
- config.addWord(pluralize.singular(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'one' }`})
83
- config.addWord(pluralize.plural(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'many' }`})
81
+ if (modifier.unknown) {
82
+ const modifierWord = modifier.text
83
+ config.addWord(pluralize.singular(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'one' }`})
84
+ config.addWord(pluralize.plural(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'many' }`})
85
+ }
84
86
  })
85
87
  // modifierds.forEach((modifierId) => config.addWord(modifierId, { id: modifierId, initial: `{ value: '${modifierId}' }`}))
86
88
 
@@ -94,7 +96,8 @@ class API {
94
96
  id: modifiersObjectId,
95
97
  level: 0,
96
98
  convolution: true,
97
- isA: ['adjective'],
99
+ isA: [{ parent: 'adjective', instance: true }],
100
+ // isA: ['adjective'],
98
101
  before: ['verby'],
99
102
  bridge: `{ ...after[0], ${modifierProperties}, atomic: true, dead: true, marker: next(operator('${modifiersObjectId}')), value: '${modifiersObjectId}', modifiers: append([${modifierList}], after[0].modifiers)}`,
100
103
  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() {