tpmkms_4wp 9.5.1-beta.2 → 9.5.1-beta.21

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 (84) hide show
  1. package/common/animals.instance.json +21 -61
  2. package/common/asking.js +102 -100
  3. package/common/can.instance.json +2180 -0
  4. package/common/can.js +254 -0
  5. package/common/can.test.json +50706 -0
  6. package/common/characters.js +3 -3
  7. package/common/colors.instance.json +38 -10
  8. package/common/comparable.instance.json +2 -2
  9. package/common/concept.test.json +54 -40
  10. package/common/conjunction.js +13 -5
  11. package/common/crew.instance.json +241 -123
  12. package/common/crew.js +1 -1
  13. package/common/currency.js +1 -1
  14. package/common/dates.instance.json +87 -3
  15. package/common/dialogues.js +41 -119
  16. package/common/dimension.instance.json +16 -12
  17. package/common/dimension.js +23 -4
  18. package/common/dimension.test.json +1758 -2351
  19. package/common/edible.instance.json +79 -95
  20. package/common/emotions.instance.json +53 -80
  21. package/common/emotions.js +1 -1
  22. package/common/english_helpers.js +277 -67
  23. package/common/fastfood.instance.json +35 -663
  24. package/common/fastfood.js +4 -4
  25. package/common/formulas.instance.json +1 -1
  26. package/common/gdefaults.js +85 -14
  27. package/common/help.js +2 -2
  28. package/common/help.test.json +65 -11
  29. package/common/helpers/concept.js +1 -1
  30. package/common/helpers/conjunction.js +54 -44
  31. package/common/helpers/dateTimeSelectors.js +2 -2
  32. package/common/helpers/dialogues.js +1 -1
  33. package/common/helpers/formulas.js +13 -11
  34. package/common/helpers/menus.js +12 -12
  35. package/common/helpers/meta.js +8 -8
  36. package/common/helpers/properties.js +102 -21
  37. package/common/helpers.js +82 -46
  38. package/common/hierarchy.js +4 -3
  39. package/common/kirk.instance.json +1 -1
  40. package/common/latin.instance.json +10 -10
  41. package/common/latin.js +5 -5
  42. package/common/length.instance.json +20 -2
  43. package/common/length.test.json +2241 -1801
  44. package/common/math.instance.json +20 -20
  45. package/common/math.js +45 -44
  46. package/common/menus.instance.json +3 -3
  47. package/common/menus.js +1 -1
  48. package/common/meta.js +49 -33
  49. package/common/ordering.instance.json +20 -30
  50. package/common/ordering.js +1 -1
  51. package/common/ordering.test.json +354 -296
  52. package/common/people.instance.json +56 -258
  53. package/common/people.js +1 -1
  54. package/common/people.test.json +952 -681
  55. package/common/pipboy.instance.json +72 -16
  56. package/common/pokemon.instance.json +8 -8
  57. package/common/pokemon.js +1 -1
  58. package/common/pressure.instance.json +6 -2
  59. package/common/properties.instance.json +4 -12
  60. package/common/properties.js +16 -3
  61. package/common/reminders.js +1 -1
  62. package/common/reports.instance.json +3 -3
  63. package/common/reports.js +18 -16
  64. package/common/scorekeeper.js +4 -4
  65. package/common/sdefaults.js +22 -2
  66. package/common/spock.instance.json +1 -1
  67. package/common/stgame.js +1 -1
  68. package/common/stm.js +2 -2
  69. package/common/tell.js +1 -1
  70. package/common/temperature.instance.json +6 -2
  71. package/common/tester.js +3 -3
  72. package/common/time.js +3 -3
  73. package/common/tokenize.js +1 -1
  74. package/common/weight.instance.json +19 -2
  75. package/common/words.instance.json +9 -0
  76. package/common/words.js +53 -0
  77. package/common/words.test.json +2 -0
  78. package/common/wp.instance.json +320 -8
  79. package/common/wp.js +8 -4
  80. package/common/wp.test.json +3469 -0
  81. package/main.js +0 -2
  82. package/package.json +9 -5
  83. package/common/listener.js +0 -50
  84. package/common/listener.test.json +0 -142
@@ -284,7 +284,7 @@ const template = {
284
284
  ({ask, api}) => {
285
285
  // see if followup for drink is needed
286
286
 
287
- const hasDrink = (isA, item) => {
287
+ function hasDrink(isA, item) {
288
288
  let hasDrink = false
289
289
  for (const modification of (item.modifications || [])) {
290
290
  if (isA(modification.id, 'drink')) {
@@ -295,11 +295,11 @@ const template = {
295
295
  return hasDrink
296
296
  }
297
297
 
298
- const needsDrink = (item) => {
298
+ function needsDrink (item) {
299
299
  return item.needsDrink
300
300
  }
301
301
 
302
- const askAbout = ({api, isA}) => {
302
+ function askAbout({api, isA}) {
303
303
  const items = []
304
304
  for (const item of api.items()) {
305
305
  if (needsDrink(item) && !hasDrink(isA, item)) {
@@ -765,7 +765,7 @@ class State {
765
765
  return
766
766
  }
767
767
 
768
- const addSize = (item, data) => {
768
+ function addSize(item, data) {
769
769
  if (item.size) {
770
770
  data.size = item.size.value
771
771
  }
@@ -997,7 +997,7 @@
997
997
  "word": "formulas",
998
998
  "range": {
999
999
  "start": 0,
1000
- "end": 20
1000
+ "end": 7
1001
1001
  },
1002
1002
  "dead": true,
1003
1003
  "types": [
@@ -1,10 +1,10 @@
1
1
  const pluralize = require('pluralize')
2
- const { defaultContextCheck } = require('./helpers')
3
- const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheck, getValue, isMany } = require('./helpers')
3
+ const { knowledgeModule, where, flatten } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
+ const words = require('./words.js')
5
6
  const gdefaults_tests = require('./gdefaults.test.json')
6
7
  const englishHelpers = require('./english_helpers.js')
7
- const { getValue, isMany } = require('./helpers.js')
8
8
  const helpers = require('./helpers')
9
9
 
10
10
  const config = {
@@ -90,7 +90,7 @@ const config = {
90
90
  text.push(await g(m))
91
91
  }
92
92
  } else {
93
- text.push(await g(context[modifier], { isModifier: true }))
93
+ text.push(await g(context[modifier], { assumed: { isModifier: true } }))
94
94
  }
95
95
  }
96
96
  // text.push(context.word)
@@ -152,14 +152,47 @@ const config = {
152
152
  {
153
153
  where: where(),
154
154
  priority: -1,
155
- match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || context.number > 1),
155
+ // match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
156
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && !context.imperative && !context.interpolate,
157
+ apply: ({context}) => {
158
+ const infinitive = englishHelpers.getInfinitive(context.word)
159
+ if (context.form == 'infinitive') {
160
+ const cases = englishHelpers.conjugateVerb(infinitive)
161
+ const def = cases.find((def) => def.form == context.form)
162
+ return def.word
163
+ } else if (context.tense) {
164
+ const cases = englishHelpers.conjugateVerb(infinitive)
165
+ const def = cases.find((def) => def.tense == context.tense)
166
+ return def.word
167
+ } else {
168
+ return pluralize.plural(context.word)
169
+ }
170
+ },
171
+ },
172
+
173
+ /*
174
+ {
175
+ where: where(),
176
+ priority: -1,
177
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'many' && !context.imperative && !context.interpolate,
178
+ apply: ({context}) => {
179
+ const infinitive = englishHelpers.getInfinitive(context.word)
180
+ const cases = englishHelpers.conjugateVerb(infinitive)
181
+ return pluralize.singular(context.word)
182
+ },
183
+ },
184
+ */
185
+ {
186
+ where: where(),
187
+ priority: -1,
188
+ match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || context.number > 1) && !context.interpolate,
156
189
  apply: ({context}) => pluralize.plural(context.word),
157
190
  },
158
191
 
159
192
  {
160
193
  where: where(),
161
194
  priority: -1,
162
- match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative,
195
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
163
196
  apply: ({context}) => {
164
197
  const infinitive = englishHelpers.getInfinitive(context.word)
165
198
  const cases = englishHelpers.conjugateVerb(infinitive)
@@ -170,7 +203,7 @@ const config = {
170
203
  {
171
204
  where: where(),
172
205
  priority: -1,
173
- match: ({context}) => context.evaluateWord && context.paraphrase && context.word && context.number == 'one',
206
+ match: ({context}) => context.evaluateWord && context.paraphrase && context.word && context.number == 'one' && !context.interpolate,
174
207
  apply: ({context}) => {
175
208
  return pluralize.singular(context.word)
176
209
  },
@@ -242,9 +275,10 @@ const config = {
242
275
  ],
243
276
  };
244
277
 
245
- const initializer = ({config}) => {
278
+ function initializer({config}) {
246
279
  config.addArgs((args) => {
247
280
  return {
281
+ flatten,
248
282
  number: (context) => isMany(context) ? "many" : "one",
249
283
  // number/gender/person etc
250
284
  gw: (context, { number: numberContext }) => {
@@ -255,14 +289,14 @@ const initializer = ({config}) => {
255
289
  args.insert({ marker: 'verbatim', verbatim: text, isResponse: true })
256
290
  },
257
291
  interpolate: async (interpolate, context) => {
258
- const evaluator = async (key) => {
292
+ async function evaluator(key) {
259
293
  if (Array.isArray(context[key])) {
260
294
  return args.gsp(context[key])
261
295
  } else {
262
296
  return args.gp(context[key])
263
297
  }
264
298
  }
265
- const getValue = (keyOrValue) => {
299
+ function getValue(keyOrValue) {
266
300
  if (typeof keyOrValue == 'string' && context[keyOrValue]) {
267
301
  return context[keyOrValue]
268
302
  }
@@ -273,7 +307,15 @@ const initializer = ({config}) => {
273
307
  const strings = []
274
308
  let separator = ''
275
309
  for (const element of interpolate) {
276
- if (typeof element == 'string') {
310
+ // { "word": { "marker": "canPassive" } ie { word: <selectionCriteria> }
311
+ if (element.word) {
312
+ const word = args.getWordFromDictionary(element.word)
313
+ if (word) {
314
+ strings.push(separator)
315
+ strings.push(await args.gp(word))
316
+ separator = ' '
317
+ }
318
+ } else if (typeof element == 'string') {
277
319
  separator = element
278
320
  } else if (element.separator && element.values) {
279
321
  let ctr = 0
@@ -287,14 +329,43 @@ const initializer = ({config}) => {
287
329
  vstrings.push(getValue(value))
288
330
  }
289
331
  strings.push(await args.gsp(vstrings))
290
- } else {
291
- let value = element
332
+ } else if (element.semantic) {
333
+ const wordContext = {}
334
+ for (const term of element.semantic) {
335
+ if (term.property) {
336
+ Object.assign(wordContext, context[term.property])
337
+ } else if (term.overrides) {
338
+ Object.assign(wordContext, term.overrides)
339
+ }
340
+ }
341
+ const value = await args.gp(wordContext) //, { options: { debug: { apply: true } } })
342
+ if (value) {
343
+ strings.push(separator)
344
+ strings.push(await args.gp(value))
345
+ separator = ' '
346
+ }
347
+ } else if (element.property) {
348
+ value = context[element.property]
349
+ if (value) {
350
+ if (element.context) {
351
+ value = { ...value, ...element.context }
352
+ }
353
+ strings.push(separator)
354
+ strings.push(await args.gp(value))
355
+ separator = ' '
356
+ }
357
+ } else if (element.context) {
358
+ let value = element.context
292
359
  if (element.property) {
293
360
  value = context[element.property]
294
361
  if (element.context) {
295
362
  Object.assign(value, element.context)
296
363
  }
297
364
  }
365
+ // if (!value?.number && element.number) {
366
+ if (value?.form !== 'infinitive' && element.number) {
367
+ value.number = isMany(context[element.number]) ? "many": "one"
368
+ }
298
369
  if (value) {
299
370
  strings.push(separator)
300
371
  strings.push(await args.gp(value))
@@ -313,7 +384,7 @@ const initializer = ({config}) => {
313
384
 
314
385
  knowledgeModule({
315
386
  config,
316
- includes: [tokenize],
387
+ includes: [tokenize, words],
317
388
  initializer,
318
389
 
319
390
  module,
package/common/help.js CHANGED
@@ -4,7 +4,7 @@ const dialogues = require('./dialogues')
4
4
  const help_tests = require('./help.test.json')
5
5
  const helpers = require('./helpers')
6
6
 
7
- const getHelp = (config, indent=2) => {
7
+ function getHelp(config, indent=2) {
8
8
  indent = ' '.repeat(indent)
9
9
  let help = ''
10
10
  if (config.tests.length == 0) {
@@ -82,7 +82,7 @@ const config = {
82
82
  },
83
83
  };
84
84
 
85
- const initializer = ({ config, addWord, kms }) => {
85
+ function initializer({ config, addWord, kms }) {
86
86
  const names = new Set()
87
87
  for (const name in kms) {
88
88
  names.add(name);
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "contexts": [
54
54
  {
55
+ "context_id": 2,
55
56
  "context_index": 1,
56
57
  "dead": true,
57
58
  "default": true,
@@ -230,6 +231,8 @@
230
231
  ]
231
232
  },
232
233
  "objects": {
234
+ "associations": [
235
+ ],
233
236
  "nameToUUID": {
234
237
  "articles": "articles2",
235
238
  "asking": "asking2",
@@ -244,50 +247,71 @@
244
247
  "punctuation": "punctuation2",
245
248
  "sdefaults": "sdefaults2",
246
249
  "stm": "stm2",
247
- "tokenize": "tokenize2"
250
+ "tokenize": "tokenize2",
251
+ "words": "words2"
248
252
  },
249
253
  "namespaced": {
250
254
  "articles2": {
255
+ "km": "articles2"
251
256
  },
252
257
  "asking2": {
258
+ "km": "asking2"
253
259
  },
254
260
  "conjunction2": {
261
+ "km": "conjunction2"
255
262
  },
256
263
  "dialogues2": {
257
264
  "idSuffix": "",
265
+ "km": "dialogues2",
258
266
  "mentioned": [
259
267
  ],
260
268
  "variables": {
261
269
  }
262
270
  },
263
271
  "evaluate2": {
272
+ "km": "evaluate2"
264
273
  },
265
274
  "gdefaults2": {
275
+ "km": "gdefaults2"
266
276
  },
267
277
  "help1": {
278
+ "km": "help1"
268
279
  },
269
280
  "meta2": {
281
+ "km": "meta2"
270
282
  },
271
283
  "negation2": {
284
+ "km": "negation2"
272
285
  },
273
286
  "pos2": {
287
+ "km": "pos2"
274
288
  },
275
289
  "punctuation2": {
290
+ "km": "punctuation2"
276
291
  },
277
292
  "sdefaults2": {
293
+ "km": "sdefaults2"
278
294
  },
279
295
  "stm2": {
296
+ "km": "stm2",
280
297
  "mentioned": [
281
298
  ],
282
299
  "variables": {
283
300
  }
284
301
  },
285
302
  "tokenize2": {
303
+ "km": "tokenize2"
304
+ },
305
+ "words2": {
306
+ "km": "words2",
307
+ "words": [
308
+ ]
286
309
  }
287
310
  },
288
311
  "processed": [
289
312
  {
290
313
  "context": {
314
+ "context_id": 2,
291
315
  "context_index": 1,
292
316
  "dead": true,
293
317
  "default": true,
@@ -352,9 +376,12 @@
352
376
  "value": "help",
353
377
  "word": "help"
354
378
  },
355
- "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)",
356
- "paraphrases": "help",
357
- "paraphrasesParenthesized": "(help)",
379
+ "generatedParenthesized": [
380
+ ],
381
+ "paraphrases": [
382
+ ],
383
+ "paraphrasesParenthesized": [
384
+ ],
358
385
  "responses": [
359
386
  " 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"
360
387
  ]
@@ -626,6 +653,7 @@
626
653
  },
627
654
  "contexts": [
628
655
  {
656
+ "context_id": 2,
629
657
  "context_index": 1,
630
658
  "dead": true,
631
659
  "default": true,
@@ -645,7 +673,7 @@
645
673
  }
646
674
  ],
647
675
  "generatedParenthesized": [
648
- "( 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 every distributable\n each distributable\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)"
676
+ "( 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 every distributable\n each distributable\n\n\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)"
649
677
  ],
650
678
  "metadata": {
651
679
  "opChoices": [
@@ -665,6 +693,8 @@
665
693
  ]
666
694
  },
667
695
  "objects": {
696
+ "associations": [
697
+ ],
668
698
  "nameToUUID": {
669
699
  "articles": "articles2",
670
700
  "asking": "asking2",
@@ -679,50 +709,71 @@
679
709
  "punctuation": "punctuation2",
680
710
  "sdefaults": "sdefaults2",
681
711
  "stm": "stm2",
682
- "tokenize": "tokenize2"
712
+ "tokenize": "tokenize2",
713
+ "words": "words2"
683
714
  },
684
715
  "namespaced": {
685
716
  "articles2": {
717
+ "km": "articles2"
686
718
  },
687
719
  "asking2": {
720
+ "km": "asking2"
688
721
  },
689
722
  "conjunction2": {
723
+ "km": "conjunction2"
690
724
  },
691
725
  "dialogues2": {
692
726
  "idSuffix": "",
727
+ "km": "dialogues2",
693
728
  "mentioned": [
694
729
  ],
695
730
  "variables": {
696
731
  }
697
732
  },
698
733
  "evaluate2": {
734
+ "km": "evaluate2"
699
735
  },
700
736
  "gdefaults2": {
737
+ "km": "gdefaults2"
701
738
  },
702
739
  "help1": {
740
+ "km": "help1"
703
741
  },
704
742
  "meta2": {
743
+ "km": "meta2"
705
744
  },
706
745
  "negation2": {
746
+ "km": "negation2"
707
747
  },
708
748
  "pos2": {
749
+ "km": "pos2"
709
750
  },
710
751
  "punctuation2": {
752
+ "km": "punctuation2"
711
753
  },
712
754
  "sdefaults2": {
755
+ "km": "sdefaults2"
713
756
  },
714
757
  "stm2": {
758
+ "km": "stm2",
715
759
  "mentioned": [
716
760
  ],
717
761
  "variables": {
718
762
  }
719
763
  },
720
764
  "tokenize2": {
765
+ "km": "tokenize2"
766
+ },
767
+ "words2": {
768
+ "km": "words2",
769
+ "words": [
770
+ ]
721
771
  }
722
772
  },
723
773
  "processed": [
724
774
  {
725
775
  "context": {
776
+ "context_id": 2,
726
777
  "context_index": 1,
727
778
  "dead": true,
728
779
  "default": true,
@@ -740,11 +791,14 @@
740
791
  "value": "help",
741
792
  "word": "help"
742
793
  },
743
- "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 every distributable\n each distributable\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)",
744
- "paraphrases": "help",
745
- "paraphrasesParenthesized": "(help)",
794
+ "generatedParenthesized": [
795
+ ],
796
+ "paraphrases": [
797
+ ],
798
+ "paraphrasesParenthesized": [
799
+ ],
746
800
  "responses": [
747
- " 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 every distributable\n each distributable\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"
801
+ " 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 every distributable\n each distributable\n\n\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"
748
802
  ]
749
803
  }
750
804
  ]
@@ -757,7 +811,7 @@
757
811
  ],
758
812
  "query": "help",
759
813
  "responses": [
760
- " 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 every distributable\n each distributable\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"
814
+ " 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 every distributable\n each distributable\n\n\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"
761
815
  ],
762
816
  "summaries": [
763
817
  {
@@ -38,7 +38,7 @@ class API {
38
38
  const modifierIds = modifiers.map( (modifier) => this.args.kms.dialogues.api.toScopedId(modifier) )
39
39
  const modifiersObjectId = `${modifierIds.join("_")}_${objectId}`
40
40
 
41
- const toWord = (object) => {
41
+ function toWord(object) {
42
42
  if (typeof object == 'string') {
43
43
  return object
44
44
  }
@@ -1,7 +1,13 @@
1
1
  const { propertyToArray } = require('../helpers.js')
2
2
 
3
- const asList = (context) => {
4
- if (context.marker === 'list') {
3
+ function asList(context) {
4
+ if (Array.isArray(context)) {
5
+ return {
6
+ marker: 'list',
7
+ // types: [context.marker],
8
+ value: context
9
+ }
10
+ } else if (context.marker === 'list') {
5
11
  return context
6
12
  }
7
13
  return {
@@ -11,60 +17,64 @@ const asList = (context) => {
11
17
  }
12
18
  }
13
19
 
14
- const listable = (hierarchy) => (c, type) => {
15
- if (!c) {
16
- return false
17
- }
18
- if (hierarchy.isA(c.marker, type)) {
19
- return true
20
- }
21
- if (c.marker === 'list') {
22
- for (const t of c.types) {
23
- if (hierarchy.isA(t, type)) {
24
- return true
20
+ function listable(hierarchy) {
21
+ return (c, type) => {
22
+ if (!c) {
23
+ return false
24
+ }
25
+ if (hierarchy.isA(c.marker, type)) {
26
+ return true
27
+ }
28
+ if (c.marker === 'list') {
29
+ for (const t of c.types) {
30
+ if (hierarchy.isA(t, type)) {
31
+ return true
32
+ }
25
33
  }
26
34
  }
27
- }
28
- return false
29
- }
30
-
31
- const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
32
- if (!child || !parent) {
33
35
  return false
34
36
  }
37
+ }
35
38
 
36
- if (strict) {
37
- if (child.marker) {
38
- child = child.marker
39
- }
40
- if (parent.marker) {
41
- parent = parent.marker
39
+ function isA(hierarchy) {
40
+ return (child, parent, { strict=false } = {}) => {
41
+ if (!child || !parent) {
42
+ return false
42
43
  }
43
- return hierarchy.isA(child, parent)
44
- } else {
45
- const children = propertyToArray(child)
46
- for (const child of children) {
47
- let okay = false
48
- if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
49
- okay = true
50
- } else {
51
- for (const childT of child.types || [child]) {
52
- if (okay) {
53
- break
54
- }
55
- for (const parentT of parent.types || [parent]) {
56
- if (hierarchy.isA(childT, parentT)) {
57
- okay = true
44
+
45
+ if (strict) {
46
+ if (child.marker) {
47
+ child = child.marker
48
+ }
49
+ if (parent.marker) {
50
+ parent = parent.marker
51
+ }
52
+ return hierarchy.isA(child, parent)
53
+ } else {
54
+ const children = propertyToArray(child)
55
+ for (const child of children) {
56
+ let okay = false
57
+ if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
58
+ okay = true
59
+ } else {
60
+ for (const childT of child.types || [child]) {
61
+ if (okay) {
58
62
  break
59
63
  }
64
+ for (const parentT of parent.types || [parent]) {
65
+ if (hierarchy.isA(childT, parentT)) {
66
+ okay = true
67
+ break
68
+ }
69
+ }
60
70
  }
61
71
  }
72
+ if (!okay) {
73
+ return false
74
+ }
62
75
  }
63
- if (!okay) {
64
- return false
65
- }
76
+ return true
66
77
  }
67
- return true
68
78
  }
69
79
  }
70
80
 
@@ -86,8 +86,8 @@ function getTime(time) {
86
86
  return { hour, minute, second }
87
87
  }
88
88
 
89
- instantiate = (isA, now, context) => {
90
- const getType = (context, type) => {
89
+ function instantiate(isA, now, context) {
90
+ function getType(context, type) {
91
91
  if (context.marker == 'onDate_dates' && context.date?.marker == type) {
92
92
  return context.date
93
93
  } if (context.marker == type) {
@@ -92,7 +92,7 @@ class API {
92
92
  }
93
93
 
94
94
  // TODO handle the general case
95
- const fixUps = (concept) => {
95
+ function fixUps(concept) {
96
96
  if (concept == '*') {
97
97
  return '\\*'
98
98
  }