ekms 8.0.0 → 8.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/common/animals.instance.json +3055 -1651
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/asking.instance.json +2 -0
  6. package/common/asking.js +253 -0
  7. package/common/asking.test.json +2290 -0
  8. package/common/avatar.js +6 -10
  9. package/common/characters.js +23 -30
  10. package/common/colors.instance.json +25666 -0
  11. package/common/colors.js +67 -0
  12. package/common/colors.test.json +4425 -0
  13. package/common/comparable.instance.json +1750 -0
  14. package/common/comparable.js +36 -28
  15. package/common/comparable.test.json +1196 -2
  16. package/common/concept.js +121 -119
  17. package/common/concept.test.json +688 -0
  18. package/common/conjunction.instance.json +2 -0
  19. package/common/conjunction.js +104 -0
  20. package/common/conjunction.test.json +322 -0
  21. package/common/countable.js +20 -14
  22. package/common/countable.test.json +1050 -0
  23. package/common/crew.instance.json +16432 -9850
  24. package/common/crew.js +39 -42
  25. package/common/crew.test.json +714 -452
  26. package/common/currency.js +28 -46
  27. package/common/dialogues.js +187 -429
  28. package/common/dialogues.test.json +684 -450
  29. package/common/dimension.instance.json +517 -289
  30. package/common/dimension.js +22 -24
  31. package/common/dimension.test.json +727 -1944
  32. package/common/edible.instance.json +20506 -10664
  33. package/common/edible.js +4 -9
  34. package/common/emotions.instance.json +195 -123
  35. package/common/emotions.js +36 -39
  36. package/common/evaluate.instance.json +2 -0
  37. package/common/evaluate.js +53 -0
  38. package/common/evaluate.test.json +574 -0
  39. package/common/events.js +11 -15
  40. package/common/fastfood.instance.json +223185 -113172
  41. package/common/fastfood.js +77 -87
  42. package/common/fastfood.test.json +8205 -3733
  43. package/common/formulas.instance.json +444 -244
  44. package/common/formulas.js +20 -27
  45. package/common/formulas.test.json +1027 -955
  46. package/common/gdefaults.js +45 -32
  47. package/common/help.js +9 -14
  48. package/common/help.test.json +71 -18
  49. package/common/helpers/concept.js +37 -10
  50. package/common/helpers/dialogues.js +22 -4
  51. package/common/helpers/formulas.js +0 -14
  52. package/common/helpers/meta.js +0 -1
  53. package/common/helpers/properties.js +92 -84
  54. package/common/helpers.js +35 -24
  55. package/common/hierarchy.js +18 -25
  56. package/common/javascript.js +12 -19
  57. package/common/kirk.instance.json +583 -300
  58. package/common/kirk.js +6 -9
  59. package/common/length.instance.json +8995 -4964
  60. package/common/length.js +5 -9
  61. package/common/listener.js +48 -0
  62. package/common/listener.test.json +104 -0
  63. package/common/math.instance.json +409 -1202
  64. package/common/math.js +17 -21
  65. package/common/meta.js +24 -50
  66. package/common/nameable.instance.json +2 -0
  67. package/common/nameable.js +144 -0
  68. package/common/nameable.test.json +3191 -0
  69. package/common/negation.instance.json +2 -0
  70. package/common/negation.js +38 -0
  71. package/common/negation.test.json +308 -0
  72. package/common/numbers.js +28 -32
  73. package/common/ordering.instance.json +459 -274
  74. package/common/ordering.js +81 -87
  75. package/common/ordinals.instance.json +2 -0
  76. package/common/ordinals.js +61 -0
  77. package/common/ordinals.test.json +412 -0
  78. package/common/people.instance.json +2138 -1321
  79. package/common/people.js +9 -14
  80. package/common/people.test.json +1815 -1073
  81. package/common/percentages.instance.json +2 -0
  82. package/common/percentages.js +53 -0
  83. package/common/percentages.test.json +751 -0
  84. package/common/pipboy.instance.json +12261 -6898
  85. package/common/pipboy.js +53 -62
  86. package/common/pipboy.test.json +2835 -0
  87. package/common/pokemon.instance.json +4432 -2351
  88. package/common/pokemon.js +8 -21
  89. package/common/pos.js +16 -14
  90. package/common/pressure.instance.json +2311 -1303
  91. package/common/pressure.js +5 -9
  92. package/common/properties.instance.json +151 -87
  93. package/common/properties.js +164 -167
  94. package/common/properties.test.json +17605 -4030
  95. package/common/punctuation.js +24 -8
  96. package/common/punctuation.test.json +233 -5
  97. package/common/reports.instance.json +1037 -551
  98. package/common/reports.js +77 -103
  99. package/common/reports.test.json +15623 -10458
  100. package/common/scorekeeper.js +19 -31
  101. package/common/sdefaults.js +17 -8
  102. package/common/sizeable.js +13 -12
  103. package/common/spock.instance.json +582 -299
  104. package/common/spock.js +6 -9
  105. package/common/stgame.js +20 -20
  106. package/common/stm.js +182 -29
  107. package/common/stm.test.json +1734 -1
  108. package/common/tell.js +15 -19
  109. package/common/temperature.instance.json +2379 -1355
  110. package/common/temperature.js +5 -9
  111. package/common/tester.js +15 -4
  112. package/common/testing.js +8 -13
  113. package/common/time.js +21 -26
  114. package/common/tokenize.js +8 -8
  115. package/common/tokenize.test.json +86 -1
  116. package/common/ui.instance.json +151 -460
  117. package/common/ui.js +22 -34
  118. package/common/ui.test.json +641 -5357
  119. package/common/weight.instance.json +7957 -4350
  120. package/common/weight.js +5 -9
  121. package/common/weight.test.json +242 -238
  122. package/common/yesno.js +6 -6
  123. package/main.js +68 -45
  124. package/package.json +44 -6
@@ -1,11 +1,11 @@
1
1
  const pluralize = require('pluralize')
2
2
  const { defaultContextCheck } = require('./helpers')
3
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
3
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
5
  const gdefaults_tests = require('./gdefaults.test.json')
6
6
  const { isMany } = require('./helpers.js')
7
7
 
8
- let configStruct = {
8
+ let config = {
9
9
  name: 'gdefaults',
10
10
  generators: [
11
11
  /* TODO save for later
@@ -23,20 +23,47 @@ let configStruct = {
23
23
  /*
24
24
  * modifiers = <list of properties>
25
25
  */
26
+ {
27
+ where: where(),
28
+ match: ({context}) => context.isResponse && context.response,
29
+ apply: ({context, gp}) => gp(context.response),
30
+ },
31
+
32
+ {
33
+ where: where(),
34
+ match: ({context}) => context.generate,
35
+ apply: async ({context, gs}) => {
36
+ const existing = context.generate.filter((key) => context[key] !== undefined)
37
+ const filtered = existing.filter((key) => {
38
+ if (context[key] && context[key].skipDefault) {
39
+ return false
40
+ }
41
+ return true
42
+ })
43
+ return gs(filtered.map((key) => context[key]))
44
+ }
45
+ },
46
+
47
+ {
48
+ where: where(),
49
+ match: ({context}) => context.evalue,
50
+ apply: async ({context, g}) => await g(context.evalue)
51
+ },
52
+
26
53
  {
27
54
  where: where(),
28
55
  //({context}) => context.paraphrase && context.modifiers,
29
56
  // match: ({context}) => context.paraphrase && (context.modifiers || context.postModifiers),
30
57
  match: ({context}) => (context.modifiers || context.postModifiers),
31
- apply: ({context, g, gs, callId}) => {
58
+ apply: async ({context, g, callId}) => {
32
59
  const text = []
33
60
  for (modifier of (context.modifiers || [])) {
34
61
  if (Array.isArray(context[modifier])) {
35
62
  for (let m of context[modifier]) {
36
- text.push(g(m))
63
+ text.push(await g(m))
37
64
  }
38
65
  } else {
39
- text.push(g(context[modifier], { isModifier: true }))
66
+ text.push(await g(context[modifier], { isModifier: true }))
40
67
  }
41
68
  }
42
69
  // text.push(context.word)
@@ -47,15 +74,15 @@ let configStruct = {
47
74
  number = isMany(context) ? 'many' : 'one'
48
75
  }
49
76
  if (context.postModifiers) {
50
- text.push(g({...context, number: 'one', postModifiers: undefined, modifiers: undefined}))
77
+ text.push(await g({...context, number: 'one', postModifiers: undefined, modifiers: undefined}))
51
78
  } else {
52
- text.push(g({...context, number, postModifiers: undefined, modifiers: undefined}))
79
+ text.push(await g({...context, number, postModifiers: undefined, modifiers: undefined}))
53
80
  }
54
81
  for ([index, modifier] of (context.postModifiers || []).entries()) {
55
82
  if (index == context.postModifiers.length - 1) {
56
- text.push(g({...context[modifier], number}))
83
+ text.push(await g({...context[modifier], number}))
57
84
  } else {
58
- text.push(g(context[modifier]))
85
+ text.push(await g(context[modifier]))
59
86
  }
60
87
  }
61
88
  return text.join(' ')
@@ -131,22 +158,16 @@ let configStruct = {
131
158
  apply: ({context}) => context.verbatim
132
159
  },
133
160
 
134
- {
135
- where: where(),
136
- match: ({context}) => context.evalue,
137
- apply: ({context, g}) => g(context.evalue)
138
- },
139
-
140
161
  {
141
162
  where: where(),
142
163
  match: ({context}) => context.value && Array.isArray(context.value),
143
- apply: ({context, gs}) => gs(context.value)
164
+ apply: async ({context, gs}) => await gs(context.value)
144
165
  },
145
166
 
146
167
  {
147
168
  where: where(),
148
169
  match: ({context}) => context.value,
149
- apply: ({context, g}) => g(context.value)
170
+ apply: async ({context, g}) => await g(context.value)
150
171
  },
151
172
 
152
173
  {
@@ -155,12 +176,6 @@ let configStruct = {
155
176
  apply: ({context}) => `the ${context.word}`
156
177
  },
157
178
 
158
- {
159
- where: where(),
160
- match: ({context}) => context.isResponse && context.response,
161
- apply: ({context, gp}) => gp(context.response),
162
- },
163
-
164
179
  {
165
180
  where: where(),
166
181
  match: ({context}) => context.word,
@@ -181,10 +196,7 @@ let configStruct = {
181
196
  ],
182
197
  };
183
198
 
184
- const createConfig = () => {
185
- const config = new Config(configStruct, module)
186
- config.add(tokenize())
187
- config.initializer( ({config}) => {
199
+ const initializer = ({config}) => {
188
200
  config.addArgs((args) => {
189
201
  return {
190
202
  number: (context) => isMany(context) ? "many" : "one",
@@ -198,19 +210,20 @@ const createConfig = () => {
198
210
  },
199
211
  }
200
212
  })
201
- })
202
- return config
203
- }
213
+ }
204
214
 
205
215
  knowledgeModule({
216
+ config,
217
+ includes: [tokenize],
218
+ initializer,
219
+
206
220
  module,
207
221
  description: 'defaults for generators',
208
- createConfig,
209
222
  test: {
210
223
  name: './gdefaults.test.json',
211
224
  contents: gdefaults_tests,
212
225
  checks: {
213
- context: defaultContextCheck,
226
+ context: defaultContextCheck(),
214
227
  },
215
228
 
216
229
  },
package/common/help.js CHANGED
@@ -22,7 +22,7 @@ const getHelp = (config, indent=2) => {
22
22
  return help
23
23
  }
24
24
 
25
- const configStruct = {
25
+ const config = {
26
26
  name: 'help',
27
27
  operators: [
28
28
  "([help] ([withKM|with] ([km]))?)",
@@ -67,7 +67,7 @@ const configStruct = {
67
67
 
68
68
  return help
69
69
  },
70
- optional: { withKM: "{ marker: 'km', kms: []}" },
70
+ optional: { 1: "{ marker: 'km', kms: []}" },
71
71
  bridge: "{ ...next(operator), kms: after[0].kms, isResponse: true }"
72
72
  },
73
73
  { id: "withKM", level: 0, bridge: "{ ...next(operator), kms: after[0] }" },
@@ -82,12 +82,7 @@ const configStruct = {
82
82
  },
83
83
  };
84
84
 
85
- const createConfig = () => {
86
- const config = new Config(configStruct, module)
87
- config.stop_auto_rebuild()
88
- config.add(dialogues())
89
-
90
- config.initializer( ({ config, addWord, kms }) => {
85
+ const initializer = ({ config, addWord, kms }) => {
91
86
  const names = new Set()
92
87
  for (let name in kms) {
93
88
  names.add(name);
@@ -95,20 +90,20 @@ const createConfig = () => {
95
90
  for (let name of names) {
96
91
  addWord(name, {id: "km", initial: `{ value: '${name}', word: '${name}' }`})
97
92
  }
98
- })
99
- config.restart_auto_rebuild()
100
- return config
101
- }
93
+ }
102
94
 
103
95
  knowledgeModule({
96
+ config,
97
+ includes: [dialogues],
98
+ initializer,
99
+
104
100
  module,
105
101
  description: 'Help the user with the current knowledge modules',
106
- createConfig,
107
102
  test: {
108
103
  name: './help.test.json',
109
104
  contents: help_tests,
110
105
  checks: {
111
- context: defaultContextCheck,
106
+ context: defaultContextCheck(),
112
107
  },
113
108
  },
114
109
  })
@@ -24,10 +24,6 @@
24
24
  "help",
25
25
  0
26
26
  ],
27
- [
28
- "km",
29
- 0
30
- ],
31
27
  [
32
28
  "list",
33
29
  0
@@ -91,7 +87,8 @@
91
87
  "word": "help"
92
88
  },
93
89
  {
94
- "level": 0,
90
+ "dead": true,
91
+ "level": 1,
95
92
  "marker": "km",
96
93
  "range": {
97
94
  "end": 27,
@@ -120,7 +117,7 @@
120
117
  }
121
118
  ],
122
119
  "generatedParenthesized": [
123
- "( 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)"
120
+ "( 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n)"
124
121
  ],
125
122
  "metadata": {
126
123
  "opChoices": [
@@ -156,7 +153,7 @@
156
153
  {
157
154
  "counter": 2,
158
155
  "op": [
159
- "list",
156
+ "km",
160
157
  0
161
158
  ],
162
159
  "ops": [
@@ -181,7 +178,7 @@
181
178
  {
182
179
  "counter": 3,
183
180
  "op": [
184
- "withKM",
181
+ "list",
185
182
  0
186
183
  ],
187
184
  "ops": [
@@ -189,6 +186,10 @@
189
186
  "help",
190
187
  0
191
188
  ],
189
+ [
190
+ "list",
191
+ 0
192
+ ],
192
193
  [
193
194
  "withKM",
194
195
  0
@@ -197,6 +198,23 @@
197
198
  },
198
199
  {
199
200
  "counter": 4,
201
+ "op": [
202
+ "withKM",
203
+ 0
204
+ ],
205
+ "ops": [
206
+ [
207
+ "help",
208
+ 0
209
+ ],
210
+ [
211
+ "withKM",
212
+ 0
213
+ ]
214
+ ]
215
+ },
216
+ {
217
+ "counter": 5,
200
218
  "op": [
201
219
  "help",
202
220
  0
@@ -212,28 +230,45 @@
212
230
  },
213
231
  "objects": {
214
232
  "nameToUUID": {
233
+ "articles": "articles2",
234
+ "asking": "asking2",
235
+ "conjunction": "conjunction2",
215
236
  "dialogues": "dialogues2",
237
+ "evaluate": "evaluate2",
216
238
  "gdefaults": "gdefaults2",
217
239
  "help": "help1",
218
240
  "meta": "meta2",
241
+ "negation": "negation2",
219
242
  "pos": "pos2",
220
243
  "punctuation": "punctuation2",
221
244
  "sdefaults": "sdefaults2",
222
- "stm": "stm2"
245
+ "stm": "stm2",
246
+ "tokenize": "tokenize2"
223
247
  },
224
248
  "namespaced": {
249
+ "articles2": {
250
+ },
251
+ "asking2": {
252
+ },
253
+ "conjunction2": {
254
+ },
225
255
  "dialogues2": {
256
+ "idSuffix": "",
226
257
  "mentioned": [
227
258
  ],
228
259
  "variables": {
229
260
  }
230
261
  },
262
+ "evaluate2": {
263
+ },
231
264
  "gdefaults2": {
232
265
  },
233
266
  "help1": {
234
267
  },
235
268
  "meta2": {
236
269
  },
270
+ "negation2": {
271
+ },
237
272
  "pos2": {
238
273
  },
239
274
  "punctuation2": {
@@ -245,6 +280,8 @@
245
280
  ],
246
281
  "variables": {
247
282
  }
283
+ },
284
+ "tokenize2": {
248
285
  }
249
286
  },
250
287
  "processed": [
@@ -285,7 +322,8 @@
285
322
  "word": "help"
286
323
  },
287
324
  {
288
- "level": 0,
325
+ "dead": true,
326
+ "level": 1,
289
327
  "marker": "km",
290
328
  "range": {
291
329
  "end": 27,
@@ -312,11 +350,11 @@
312
350
  "value": "help",
313
351
  "word": "help"
314
352
  },
315
- "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)",
353
+ "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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n)",
316
354
  "paraphrases": "help",
317
355
  "paraphrasesParenthesized": "(help)",
318
356
  "responses": [
319
- " 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"
357
+ " 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n"
320
358
  ]
321
359
  }
322
360
  ]
@@ -329,7 +367,7 @@
329
367
  ],
330
368
  "query": "help with help and dialogues",
331
369
  "responses": [
332
- " 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"
370
+ " 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n"
333
371
  ]
334
372
  },
335
373
  {
@@ -356,9 +394,8 @@
356
394
  "word": "help"
357
395
  }
358
396
  ],
359
- "developerTest": false,
360
397
  "generatedParenthesized": [
361
- "( 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\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\n\n)"
398
+ "( 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\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: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n\n\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)"
362
399
  ],
363
400
  "metadata": {
364
401
  "opChoices": [
@@ -379,10 +416,15 @@
379
416
  },
380
417
  "objects": {
381
418
  "nameToUUID": {
419
+ "articles": "articles2",
420
+ "asking": "asking2",
421
+ "conjunction": "conjunction2",
382
422
  "dialogues": "dialogues2",
423
+ "evaluate": "evaluate2",
383
424
  "gdefaults": "gdefaults2",
384
425
  "help": "help1",
385
426
  "meta": "meta2",
427
+ "negation": "negation2",
386
428
  "pos": "pos2",
387
429
  "punctuation": "punctuation2",
388
430
  "sdefaults": "sdefaults2",
@@ -390,18 +432,29 @@
390
432
  "tokenize": "tokenize2"
391
433
  },
392
434
  "namespaced": {
435
+ "articles2": {
436
+ },
437
+ "asking2": {
438
+ },
439
+ "conjunction2": {
440
+ },
393
441
  "dialogues2": {
442
+ "idSuffix": "",
394
443
  "mentioned": [
395
444
  ],
396
445
  "variables": {
397
446
  }
398
447
  },
448
+ "evaluate2": {
449
+ },
399
450
  "gdefaults2": {
400
451
  },
401
452
  "help1": {
402
453
  },
403
454
  "meta2": {
404
455
  },
456
+ "negation2": {
457
+ },
405
458
  "pos2": {
406
459
  },
407
460
  "punctuation2": {
@@ -436,11 +489,11 @@
436
489
  "value": "help",
437
490
  "word": "help"
438
491
  },
439
- "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\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\n\n)",
492
+ "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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\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: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n\n\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)",
440
493
  "paraphrases": "help",
441
494
  "paraphrasesParenthesized": "(help)",
442
495
  "responses": [
443
- " 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\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\n\n"
496
+ " 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\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: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n\n\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"
444
497
  ]
445
498
  }
446
499
  ]
@@ -453,7 +506,7 @@
453
506
  ],
454
507
  "query": "help",
455
508
  "responses": [
456
- " 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\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\n\n"
509
+ " 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 setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\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: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n\n\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"
457
510
  ]
458
511
  }
459
512
  ]
@@ -1,6 +1,6 @@
1
1
  const pluralize = require('pluralize')
2
2
  const deepEqual = require('deep-equal')
3
- const { chooseNumber } = require('../helpers.js')
3
+ const { chooseNumber, zip } = require('../helpers.js')
4
4
  const { compose, translationMapping, translationMappingToInstantiatorMappings } = require('./meta.js')
5
5
 
6
6
  class API {
@@ -31,13 +31,24 @@ class API {
31
31
  // for example, "crew member" or "photon torpedo"
32
32
  // TODO account for modifier a complex phrase for example "hot (chicken strips)"
33
33
  kindOfConcept({ config, modifiers, object }) {
34
- const objectId = pluralize.singular(object)
34
+ // TODO make the modifiers objects then below for add words for modifiers only do if !unknown
35
+ // const objectId = pluralize.singular(object)
36
+ const objectId = this.args.kms.dialogues.api.toScopedId(object)
35
37
  // const modifierIds = modifiers.map( (modifier) => pluralize.singular(modifier) )
36
- const modifierIds = modifiers
38
+ const modifierIds = modifiers.map( (modifier) => this.args.kms.dialogues.api.toScopedId(modifier) )
37
39
  const modifiersObjectId = `${modifierIds.join("_")}_${objectId}`
38
40
 
39
- const objectSingular = pluralize.singular(object)
40
- const objectPlural = pluralize.plural(object)
41
+ const toWord = (object) => {
42
+ if (typeof object == 'string') {
43
+ return object
44
+ }
45
+ return object.text
46
+ }
47
+ const objectWord = toWord(object)
48
+ // const objectWord = object
49
+ // TODO call evaluator to pick up overrides
50
+ const objectSingular = pluralize.singular(objectWord)
51
+ const objectPlural = pluralize.plural(objectWord)
41
52
  // config.addOperator({ pattern: `(${modifierIds.map((modifierId) => `(${modifierId}/*)`).join(' ')} [${modifiersObjectId}] (${objectId}/0))`, allowDups: true })
42
53
  config.addOperator({ pattern: `(${modifierIds.map((modifierId) => `(${modifierId}/*)`).join(' ')} [${modifiersObjectId}] (${objectId}/*))`, allowDups: true })
43
54
  // config.addOperator({ pattern: `(<${modifierId}|> ([${objectId}|]))`, allowDups: true })
@@ -59,10 +70,25 @@ class API {
59
70
  config.addOperator({ pattern: `([${objectId}|])`, allowDups: true })
60
71
  }
61
72
 
73
+ if (object.unknown || object.marker !== objectId) {
74
+ config.addWord(objectSingular, { id: objectId, initial: `{ value: '${objectId}', number: 'one' }`})
75
+ config.addWord(objectPlural, { id: objectId, initial: `{ value: '${objectId}', number: 'many' }`})
76
+ }
62
77
 
63
- config.addWord(objectSingular, { id: objectId, initial: `{ value: '${objectId}', number: 'one' }`})
64
- config.addWord(objectPlural, { id: objectId, initial: `{ value: '${objectId}', number: 'many' }`})
65
- modifierIds.forEach((modifierId) => config.addWord(modifierId, { id: modifierId, initial: `{ value: '${modifierId}' }`}))
78
+ zip(modifiers, modifierIds).forEach(([modifier, modifierId]) => {
79
+ // config.addWord(modifier, { id: modifierId, initial: `{ value: '${modifierId}' }`})
80
+ // TODO call evaluator to pick up overrides
81
+ if (modifier.unknown) {
82
+ const modifierWord = modifier.word
83
+ if (pluralize.isSingular(modifierWord)) {
84
+ config.addWord(pluralize.singular(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'one' }`})
85
+ }
86
+ if (pluralize.isPlural(modifierWord)) {
87
+ config.addWord(pluralize.plural(modifierWord), { id: modifierId, initial: `{ value: '${modifierId}', number: 'many' }`})
88
+ }
89
+ }
90
+ })
91
+ // modifierds.forEach((modifierId) => config.addWord(modifierId, { id: modifierId, initial: `{ value: '${modifierId}' }`}))
66
92
 
67
93
  modifierIds.forEach((modifierId) => config.addBridge({ id: modifierId, level: 0, bridge: `{ ...next(operator), value: '${modifierId}' }`, allowDups: true }))
68
94
  config.addBridge({ id: objectId, level: 0, bridge: `{ ...next(operator), value: '${objectId}' }`, allowDups: true })
@@ -74,8 +100,9 @@ class API {
74
100
  id: modifiersObjectId,
75
101
  level: 0,
76
102
  convolution: true,
77
- isA: ['adjective'],
78
- before: ['verby'],
103
+ isA: [{ parent: 'adjective', instance: true }],
104
+ // isA: ['adjective'],
105
+ before: ['verb'],
79
106
  bridge: `{ ...after[0], ${modifierProperties}, atomic: true, dead: true, marker: next(operator('${modifiersObjectId}')), value: '${modifiersObjectId}', modifiers: append([${modifierList}], after[0].modifiers)}`,
80
107
  allowDups: true })
81
108
  {
@@ -4,6 +4,21 @@ const { indent, focus } = require('../helpers')
4
4
  class API {
5
5
  initialize({ objects }) {
6
6
  this._objects = objects
7
+ this._objects.idSuffix = ''
8
+ }
9
+
10
+ setIdSuffix(idSuffix) {
11
+ this._objects.idSuffix = idSuffix
12
+ }
13
+
14
+ toScopedId(context) {
15
+ if (typeof context == 'string') {
16
+ return pluralize.singular(context) + this._objects.idSuffix
17
+ } else {
18
+ const { unknown, value, word } = context;
19
+ // return unknown ? pluralize.singular(word) + this._objects.idSuffix : pluralize.singular(value || word)
20
+ return unknown ? pluralize.singular(word) + this._objects.idSuffix : value || pluralize.singular(word)
21
+ }
7
22
  }
8
23
 
9
24
  warningNotEvaluated(log, value) {
@@ -35,10 +50,9 @@ class API {
35
50
  return this._objects.brief
36
51
  }
37
52
 
38
- evaluateToConcept(value, context, log, s) {
53
+ async evaluateToConcept(value, context, log, s) {
39
54
  value.evaluate = { toConcept: true }
40
- // const concept = s(value, { debug: { apply: true } })
41
- const concept = s(value)
55
+ const concept = await s(value)
42
56
  if (!concept.evalue && !concept.verbatim) {
43
57
  this.warningNotEvaluated(log, value);
44
58
  concept.evalue = concept.value
@@ -49,6 +63,9 @@ class API {
49
63
 
50
64
  setupObjectHierarchy(config, id, { types } = {}) {
51
65
  for (let type of types) {
66
+ if (typeof type !== 'string') {
67
+ type = type.word
68
+ }
52
69
  config.addHierarchy(id, type)
53
70
  }
54
71
  }
@@ -64,7 +81,8 @@ class API {
64
81
  if (!value) {
65
82
  return
66
83
  }
67
- const concept = pluralize.singular(value)
84
+ // const concept = pluralize.singular(value)
85
+ const concept = this.toScopedId(context)
68
86
  if (config.exists(concept)) {
69
87
  return concept
70
88
  }
@@ -42,11 +42,9 @@ const unify = (rule, value) => {
42
42
 
43
43
  const f = (values, variable) => (value) => {
44
44
  if (!value) {
45
- debugger
46
45
  throw new Error("Value not present")
47
46
  }
48
47
  if (values[variable] && values[variable] != value) {
49
- debugger
50
48
  throw new Error("Variable already set to different value")
51
49
  }
52
50
  values[variable] = value
@@ -80,18 +78,6 @@ function solveFor(expression, variable, isVariable = (expression) => typeof expr
80
78
  return c1.value == c2.value
81
79
  }
82
80
 
83
- /*
84
- for (let rule of rules) {
85
- debugger
86
- const body = unify(rule, expression)
87
- const lVars = getVariables(body.left, isVariable)
88
- const rVars = getVariables(body.right, isVariable)
89
- if (lVars.length == 1 && sameVar(lVars[0], variable) && !rVars.some((c) => sameVar(c, variable))) {
90
- return body
91
- }
92
- }
93
- */
94
-
95
81
  const lVars = getVariables(expression.left, isVariable)
96
82
  const rVars = getVariables(expression.right, isVariable)
97
83
  if (lVars.length == 1 && sameVar(lVars[0], variable) && !rVars.some((c) => sameVar(c, variable))) {
@@ -104,7 +104,6 @@ const translationMappingToInstantiatorMappings = (translationMapping, from , to
104
104
  match: ({context}) => context[tm.to],
105
105
  apply: ({context}) => {
106
106
  // Object.assign(context[tm.to], from[tm.from])
107
- // debugger;
108
107
  context[tm.to] = from[tm.from]
109
108
  if (context[tm.to]) {
110
109
  context[tm.to].instantiated = true