tpmkms 8.0.0-beta.5 → 8.0.0-beta.50

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 (99) hide show
  1. package/common/animals.instance.json +2855 -1363
  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/avatar.js +5 -9
  6. package/common/characters.js +22 -28
  7. package/common/colors.instance.json +6978 -3493
  8. package/common/colors.js +4 -8
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.js +5 -22
  11. package/common/concept.js +120 -118
  12. package/common/countable.js +18 -12
  13. package/common/countable.test.json +1050 -0
  14. package/common/crew.instance.json +13032 -6570
  15. package/common/crew.js +36 -41
  16. package/common/crew.test.json +714 -452
  17. package/common/currency.js +27 -45
  18. package/common/dialogues.js +158 -282
  19. package/common/dimension.instance.json +273 -272
  20. package/common/dimension.js +16 -22
  21. package/common/dimension.test.json +446 -1640
  22. package/common/edible.instance.json +19911 -9877
  23. package/common/edible.js +3 -8
  24. package/common/emotions.instance.json +146 -128
  25. package/common/emotions.js +35 -38
  26. package/common/evaluate.instance.json +2 -0
  27. package/common/evaluate.js +49 -0
  28. package/common/evaluate.test.json +574 -0
  29. package/common/events.js +9 -13
  30. package/common/fastfood.instance.json +221141 -111240
  31. package/common/fastfood.js +70 -80
  32. package/common/formulas.instance.json +251 -265
  33. package/common/formulas.js +17 -24
  34. package/common/gdefaults.js +24 -26
  35. package/common/help.js +7 -12
  36. package/common/help.test.json +22 -22
  37. package/common/helpers/concept.js +9 -6
  38. package/common/helpers/dialogues.js +2 -3
  39. package/common/helpers/properties.js +52 -58
  40. package/common/helpers.js +1 -1
  41. package/common/hierarchy.js +16 -24
  42. package/common/javascript.js +11 -18
  43. package/common/kirk.instance.json +583 -289
  44. package/common/kirk.js +5 -8
  45. package/common/length.instance.json +5530 -4754
  46. package/common/length.js +4 -8
  47. package/common/listener.js +48 -0
  48. package/common/listener.test.json +104 -0
  49. package/common/math.instance.json +192 -1184
  50. package/common/math.js +15 -19
  51. package/common/meta.js +23 -47
  52. package/common/nameable.instance.json +2 -0
  53. package/common/nameable.js +135 -0
  54. package/common/nameable.test.json +2121 -0
  55. package/common/negation.instance.json +2 -0
  56. package/common/negation.js +38 -0
  57. package/common/negation.test.json +308 -0
  58. package/common/numbers.js +6 -10
  59. package/common/ordering.instance.json +340 -160
  60. package/common/ordering.js +80 -86
  61. package/common/people.instance.json +2066 -1014
  62. package/common/people.js +8 -13
  63. package/common/percentages.instance.json +2 -0
  64. package/common/percentages.js +53 -0
  65. package/common/percentages.test.json +751 -0
  66. package/common/pipboy.instance.json +7999 -6269
  67. package/common/pipboy.js +32 -43
  68. package/common/pokemon.instance.json +4207 -2069
  69. package/common/pokemon.js +7 -20
  70. package/common/pos.js +4 -5
  71. package/common/pressure.instance.json +1341 -1189
  72. package/common/pressure.js +4 -8
  73. package/common/properties.instance.json +130 -60
  74. package/common/properties.js +56 -133
  75. package/common/punctuation.js +6 -6
  76. package/common/reports.instance.json +595 -557
  77. package/common/reports.js +64 -89
  78. package/common/scorekeeper.js +18 -30
  79. package/common/sdefaults.js +16 -7
  80. package/common/sizeable.js +5 -9
  81. package/common/spock.instance.json +583 -289
  82. package/common/spock.js +5 -8
  83. package/common/stgame.js +19 -19
  84. package/common/stm.js +163 -26
  85. package/common/stm.test.json +1734 -1
  86. package/common/tell.js +14 -18
  87. package/common/temperature.instance.json +1461 -1293
  88. package/common/temperature.js +4 -8
  89. package/common/tester.js +3 -3
  90. package/common/testing.js +8 -12
  91. package/common/time.js +20 -25
  92. package/common/tokenize.js +4 -5
  93. package/common/ui.instance.json +257 -258
  94. package/common/ui.js +11 -17
  95. package/common/weight.instance.json +5212 -4233
  96. package/common/weight.js +4 -8
  97. package/common/yesno.js +5 -5
  98. package/main.js +59 -46
  99. package/package.json +27 -5
package/common/reports.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const currencyKM = require('./currency.js')
4
4
  const events = require('./events.js')
@@ -38,7 +38,7 @@ const compareValue = (property, v1, v2) => {
38
38
  const newReport = ({km, objects}) => {
39
39
  objects.tempReportId += 1
40
40
  const reportId = `tempReport${objects.tempReportId}`
41
- km('stm').api.mentioned({ marker: "report", text: reportId, types: [ "report" ], value: reportId, word: reportId })
41
+ km('stm').api.mentioned({ context: { marker: "report", text: reportId, types: [ "report" ], value: reportId, word: reportId } })
42
42
  // name to listing
43
43
  objects.listings[reportId] = {
44
44
  columns: ['name', 'supplier'],
@@ -100,7 +100,7 @@ const apiTemplate = (marker, testData) => {
100
100
  },
101
101
  productGenerator: {
102
102
  match: ({context}) => context.marker == marker && context.isInstance,
103
- apply: ({g, context}) => `${context.name}`,
103
+ apply: ({context}) => `${context.name}`,
104
104
  }
105
105
  }
106
106
  }
@@ -110,7 +110,7 @@ const apiTemplate = (marker, testData) => {
110
110
  const api1 = apiTemplate('models', testData2)
111
111
  const api2 = apiTemplate('clothes', testData)
112
112
 
113
- let configStruct = {
113
+ let config = {
114
114
  name: 'reports',
115
115
  operators: [
116
116
  //"(([type]) [([(<less> ([than]))] ([amount]))])",
@@ -190,9 +190,9 @@ let configStruct = {
190
190
  bridge: "{ ...next(operator), on: { marker: 'report', pullFromContext: true }, from: after[0], to: after[1] }",
191
191
  directionBridge: "{ ...next(operator), on: { marker: 'report', pullFromContext: true }, directionBridge: true, from: after[0], to: after[1] }",
192
192
 
193
- generatorp: ({context, gp}) => `move ${gp(context.from)} ${gp(context.to)}`,
194
- semantic: ({context, e, objects, kms, insert}) => {
195
- const report = e(context.on)
193
+ generatorp: async ({context, gp}) => `move ${await gp(context.from)} ${await gp(context.to)}`,
194
+ semantic: async ({context, e, objects, kms, insert}) => {
195
+ const report = await e(context.on)
196
196
  const id = report.value.value
197
197
  const listing = objects.listings[id]
198
198
 
@@ -218,9 +218,9 @@ let configStruct = {
218
218
  where: where(),
219
219
  id: "remove", level: 0,
220
220
  bridge: "{ ...next(operator), on: { marker: 'report', pullFromContext: true }, removee: after[0] }",
221
- generatorp: ({context, gp}) => `remove ${gp(context.removee)}`,
222
- semantic: ({context, e, kms, insert, objects}) => {
223
- const report = e(context.on)
221
+ generatorp: async ({context, gp}) => `remove ${await gp(context.removee)}`,
222
+ semantic: async ({context, e, kms, insert, objects}) => {
223
+ const report = await e(context.on)
224
224
  const id = report.value.value
225
225
  const listing = objects.listings[id]
226
226
  const column = context.removee.index.value
@@ -232,7 +232,7 @@ let configStruct = {
232
232
  where: where(),
233
233
  id: "column", level: 0,
234
234
  bridge: "{ ...next(operator), index: after[0] }",
235
- generatorp: ({context, gp}) => `column ${gp(context.index)}`,
235
+ generatorp: async ({context, gp}) => `column ${await gp(context.index)}`,
236
236
  },
237
237
  { id: "ordering", level: 0, bridge: "{ ...next(operator) }" },
238
238
  { id: "direction", level: 0, bridge: "{ ...next(operator) }" },
@@ -248,10 +248,10 @@ let configStruct = {
248
248
  {
249
249
  where: where(),
250
250
  match: ({context}) => context.marker == 'report' && context.describe,
251
- apply: ({context, apis, gp, gs, objects}) => {
251
+ apply: async ({context, apis, gs, objects}) => {
252
252
  const listings = objects.listings[context.value]
253
253
  // {"type":"tables","columns":["name"],"ordering":[]}
254
- return `for ${listings.api}, showing the ${wordNumber('property', listings.columns.length > 1)} ${gs(listings.columns, ' ', ' and ')} as ${listings.type}`
254
+ return `for ${listings.api}, showing the ${wordNumber('property', listings.columns.length > 1)} ${await gs(listings.columns, ' ', ' and ')} as ${listings.type}`
255
255
  }
256
256
  },
257
257
  {
@@ -297,8 +297,8 @@ let configStruct = {
297
297
  level: 0,
298
298
  isA: ['verby'],
299
299
  bridge: "{ ...next(operator), report: after[0] }",
300
- "generatorp": ({g, context}) => `describe ${g(context.report)}`,
301
- "generatorr": ({gp, context, apis, objects, config}) => {
300
+ "generatorp": async ({g, context}) => `describe ${await g(context.report)}`,
301
+ "generatorr": async ({gp, context, apis, objects, config}) => {
302
302
  const reports = propertyToArray(context.report)
303
303
  let response = ''
304
304
  for (let report of reports) {
@@ -308,11 +308,11 @@ let configStruct = {
308
308
  continue
309
309
  }
310
310
  const description = {describe: true, word: reportId, types:["report"], value: reportId, text: reportId, marker: "report"}
311
- response += `${reportId}: ${gp(description)}\n`
311
+ response += `${reportId}: ${await gp(description)}\n`
312
312
  }
313
313
  } else {
314
314
  // response += `${gp(report)}: ${describe(report.value)}\n`
315
- response += `${gp(report)}: ${gp({ ...report, describe: true })}\n`
315
+ response += `${await gp(report)}: ${await gp({ ...report, describe: true })}\n`
316
316
  }
317
317
  }
318
318
  return response
@@ -327,21 +327,23 @@ let configStruct = {
327
327
  id: "call",
328
328
  level: 0,
329
329
  bridge: "{ ...next(operator), namee: after[0], name: after[1] }",
330
- generatorp: ({g, context}) => `call ${g(context.namee)} ${g(context.name)}`,
331
- semantic: ({g, context, objects, e, config, km}) => {
332
- const namee = e(context.namee).evalue
330
+ generatorp: async ({g, context}) => `call ${await g(context.namee)} ${await g(context.name)}`,
331
+ semantic: async ({context, objects, e, config, km}) => {
332
+ const namee = (await e(context.namee)).evalue
333
333
  const id = namee.value
334
334
  const listing = objects.listings[id]
335
335
  const name = context.name.text
336
336
  objects.listings[name] = {...listing}
337
337
  config.addWord(`${name}`, { id: 'report', initial: `{ value: "${name}" }` })
338
338
  km('stm').api.mentioned({
339
+ context: {
339
340
  marker: "report",
340
341
  text: name,
341
342
  types: [ "report" ],
342
343
  value: id,
343
344
  word: name
344
- })
345
+ }
346
+ })
345
347
  }
346
348
  },
347
349
  ],
@@ -375,49 +377,28 @@ let configStruct = {
375
377
  "literals": {
376
378
  "tables": [{"id": "listingType", "initial": "{ value: 'tables' }" }],
377
379
  "sentences": [{"id": "listingType", "initial": "{ value: 'sentences' }" }],
378
- //"product1": [{"id": "reportObject", "initial": "{ value: 'api1' }" }],
379
- //"api2": [{"id": "reportObject", "initial": "{ value: 'api2' }" }],
380
- //" ([0-9]+)": [{"id": "amount", "initial": "{ value: int(group[0]) }" }],
381
380
  }
382
381
  },
383
382
 
384
383
  priorities: [
385
384
  { "context": [['ordering', 0], ['articlePOS', 0], ], "choose": [0] },
386
- /*
387
- [['the', 0], ['ordering', 0]],
388
- [['listAction', 0], ['cost', 1]],
389
- [['answer', 0], ['listAction', 0], ['the', 0]],
390
- [['answer', 0], ['listAction', 0], ['the', 0], ['with', 0]],
391
- */
392
385
  ],
393
386
  generators: [
394
387
  {
395
388
  notes: 'paraphrase show',
396
389
  where: where(),
397
390
  match: ({context, objects}) => context.marker == 'show' && context.paraphrase,
398
- apply: ({gs, gsp, gp, e, apis, objects, context}) => {
391
+ apply: async ({gs, gp, e, apis, objects, context}) => {
399
392
  if (context.report) {
400
- return `show ${gp(context.report)}`
393
+ return `show ${await gp(context.report)}`
401
394
  } else {
402
- const report = e(context.on)
395
+ const report = await e(context.on)
403
396
  const id = report.value.value
404
397
  const listing = objects.listings[id]
405
- return `the properties being shown are ${gs(listing.columns, ', ', ' and ')}`
398
+ return `the properties being shown are ${await gs(listing.columns, ', ', ' and ')}`
406
399
  }
407
400
  }
408
401
  },
409
- /*
410
- {
411
- where: where(),
412
- match: ({context, isA}) => isA(context.marker, 'reportAction') && context.on && context.isResponse,
413
- apply: ({context, g}) => `${g({...context, on: undefined})} on ${g(context.on)}`
414
- },
415
- {
416
- where: where(),
417
- match: ({context, isA}) => isA(context.marker, 'reportAction') && context.on && context.paraphrase,
418
- apply: ({context, g}) => `${g({...context, on: undefined})} on ${g(context.on)}`
419
- },
420
- */
421
402
  {
422
403
  where: where(),
423
404
  match: ({context}) => context.marker == 'product' && !context.isInstance,
@@ -426,12 +407,12 @@ let configStruct = {
426
407
  {
427
408
  where: where(),
428
409
  match: ({context}) => context.marker == 'listAction' && context.paraphrase,
429
- apply: ({g, context}) => `list ${g(context.what)}`
410
+ apply: async ({g, context}) => `list ${await g(context.what)}`
430
411
  },
431
412
  {
432
413
  notes: 'show the results as a sentence',
433
414
  where: where(),
434
- match: ({context, objects, apis}) => {
415
+ match: ({context, objects}) => {
435
416
  if (!(context.marker == 'listAction' && context.isResponse)) {
436
417
  return false
437
418
  }
@@ -439,15 +420,15 @@ let configStruct = {
439
420
  return true
440
421
  }
441
422
  },
442
- apply: ({g, gs, context, objects}) => {
423
+ apply: async ({g, gs, context, objects}) => {
443
424
  const listing = objects.listings[context.id]
444
- return `the ${g(listing.api)} are ${gs(context.listing, ' ', ' and ')}`
425
+ return `the ${await g(listing.api)} are ${await gs(context.listing, ' ', ' and ')}`
445
426
  }
446
427
  },
447
428
  {
448
429
  notes: 'show the results as a table',
449
430
  where: where(),
450
- match: ({context, objects, apis}) => {
431
+ match: ({context, objects}) => {
451
432
  if (!(context.marker == 'listAction' && context.isResponse && !context.paraphrase)) {
452
433
  return false
453
434
  }
@@ -455,7 +436,7 @@ let configStruct = {
455
436
  return true
456
437
  }
457
438
  },
458
- apply: ({g, gs, objects, context, e, kms, apis}) => {
439
+ apply: async ({objects, context, e, kms}) => {
459
440
  let report = '';
460
441
  const products = context.listing
461
442
  const columns = objects.listings[context.id].columns
@@ -463,21 +444,21 @@ let configStruct = {
463
444
  kms.stm.api.setVariable('price', { marker: 'price', value: 23 })
464
445
  kms.stm.api.setVariable('quantity', { marker: 'quantity', value: 3 })
465
446
  const c1 = { marker: 'worth', value: 'worth' }
466
- r1 = toEValue(e(c1));
467
- r2 = e({ marker: 'supplier', value: 'supplier' })
468
- // api.listing.api = context.what.api
447
+ r1 = toEValue(await e(c1));
448
+ r2 = await e({ marker: 'supplier', value: 'supplier' })
469
449
  }
470
- const data = products.map( (product) => {
450
+ const data = []
451
+ for (const product of products) {
471
452
  const row = []
472
453
  for (let p of Object.keys(product)) {
473
454
  kms.stm.api.setVariable(p, { marker: p, value: product[p] })
474
455
  }
475
456
  for (let property of columns) {
476
- const value = toEValue(e({ marker: property, value: property }));
457
+ const value = toEValue(await e({ marker: property, value: property }));
477
458
  row.push(value)
478
459
  }
479
- return row
480
- });
460
+ data.push(row)
461
+ };
481
462
  report += table([columns].concat(data))
482
463
  return report
483
464
  }
@@ -485,12 +466,12 @@ let configStruct = {
485
466
  {
486
467
  where: where(),
487
468
  match: ({context}) => context.marker == 'answer' && context.paraphrase,
488
- apply: ({g, context}) => `answer with ${context.type}`
469
+ apply: ({context}) => `answer with ${context.type}`
489
470
  },
490
471
  {
491
472
  where: where(),
492
473
  match: ({context}) => context.marker == 'answer' && !context.paraphrase,
493
- apply: ({g, context}) => `answering with ${context.type}`
474
+ apply: ({context}) => `answering with ${context.type}`
494
475
  },
495
476
  ],
496
477
 
@@ -499,13 +480,13 @@ let configStruct = {
499
480
  where: where(),
500
481
  notes: 'handle show semantic',
501
482
  match: ({context}) => context.marker == 'show',
502
- apply: ({context, e, km, kms, apis, insert, config, objects}) => {
483
+ apply: async ({context, e, km, kms, apis, insert, config, objects}) => {
503
484
  if (context.report) {
504
485
  const values = propertyToArray(context.report)
505
486
  const responses = []
506
487
  for (let value of values) {
507
488
  if (!value.value || value.pullFromContext) {
508
- value = e(value)
489
+ value = await e(value)
509
490
  }
510
491
  let id = value.value
511
492
  if (value.evalue) {
@@ -528,7 +509,7 @@ let configStruct = {
528
509
  }
529
510
  context.isResponse = true
530
511
  } else {
531
- const report = e(context.on)
512
+ const report = await e(context.on)
532
513
  const id = report.value.value
533
514
  const listing = objects.listings[id]
534
515
  const values = propertyToArray(context.properties)
@@ -551,11 +532,11 @@ let configStruct = {
551
532
  notes: 'get the report data',
552
533
  where: where(),
553
534
  match: ({context}) => context.marker == 'listAction',
554
- apply: ({context, e, objects, apis, km, config}) => {
535
+ apply: async ({context, e, objects, apis, km, config}) => {
555
536
  //const name = '***current***'
556
537
  if (context.api) {
557
538
  // id = newReport({km, objects})
558
- const report = e({ marker: 'report', pullFromContext: true })
539
+ const report = await e({ marker: 'report', pullFromContext: true })
559
540
  const id = report.value.value
560
541
  const listing = objects.listings[id]
561
542
  listing.api = context.api
@@ -563,7 +544,7 @@ let configStruct = {
563
544
  context.id = id
564
545
  context.listing = apis[listing.api].getAllProducts(listing)
565
546
  } else {
566
- const report = e({ marker: 'report', pullFromContext: true })
547
+ const report = await e({ marker: 'report', pullFromContext: true })
567
548
  const id = report.evalue.value
568
549
  const listing = objects.listings[id]
569
550
  const api = apis[listing.api]
@@ -573,20 +554,20 @@ let configStruct = {
573
554
  context.isResponse = true
574
555
  },
575
556
  },
576
- [
577
- ({context}) => context.marker == 'answer',
578
- ({e, context, objects, kms, insert}) => {
579
- const report = e({ marker: 'report', pullFromContext: true })
557
+ {
558
+ match: ({context}) => context.marker == 'answer',
559
+ apply: async ({e, context, objects, kms, insert}) => {
560
+ const report = await e({ marker: 'report', pullFromContext: true })
580
561
  const id = report.value.value
581
562
  const listing = objects.listings[id]
582
563
  listing.type = context.type
583
564
  kms.events.api.happens(insert, { marker: "changes", level: 1, changeable: { marker: 'report', pullFromContext: true } })
584
565
  }
585
- ],
566
+ },
586
567
  ],
587
568
  };
588
569
 
589
- const initializeApi = (config, api, km) => {
570
+ const initializeApi = (config, api) => {
590
571
  const type = api.getName();
591
572
  config.addWord(type, {"id": "product", "initial": "{ value: '" + type + `', api: '${type}'}` })
592
573
  /*
@@ -604,18 +585,11 @@ const initializeApi = (config, api, km) => {
604
585
  // config.addWord(type, {"id": "report", "initial": `${open} value: '${type}' ${close}` })
605
586
  }
606
587
 
607
- const createConfig = () => {
608
- const config = new Config(configStruct, module)
609
- config.stop_auto_rebuild()
610
- config.add(currencyKM(), helpKM(), math(), events())
611
- config.multiApi = initializeApi
612
- // mode this to non-module init only
613
- config.initializer(({config, objects, km, isModule}) => {
588
+ const initializer = async ({config, objects, km, kms, isModule}) => {
614
589
  if (!isModule) {
615
- km('reports').addAPI(api1)
616
- km('reports').addAPI(api2)
617
- // config.addAPI(api1)
618
- // config.addAPI(api2)
590
+ debugger
591
+ await kms.reports.addAPI(api1)
592
+ await kms.reports.addAPI(api2)
619
593
  }
620
594
  objects.tempReportId = 0
621
595
  objects.listings = {
@@ -624,15 +598,16 @@ const createConfig = () => {
624
598
  if (!isModule) {
625
599
  objects.listings[id].api = 'clothes'
626
600
  }
627
- })
628
- config.restart_auto_rebuild()
629
- return config
630
- }
601
+ }
631
602
 
632
603
  knowledgeModule({
604
+ config,
605
+ includes: [currencyKM, helpKM, math, events],
606
+ multiApiInitializer: initializeApi,
607
+ initializer,
608
+
633
609
  module,
634
610
  description: 'this module is for getting info about a concept with properties',
635
- createConfig,
636
611
  test: {
637
612
  name: './reports.test.json',
638
613
  contents: reports_tests,
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require('./dialogues')
4
4
  const numbers = require('./numbers')
@@ -43,7 +43,7 @@ const setNextPlayer = (km, objects) => {
43
43
  word: "turn"
44
44
  }
45
45
  const api = km('stm').api
46
- api.mentioned(turn)
46
+ api.mentioned({ context: turn })
47
47
  }
48
48
 
49
49
  const addPlayer = (objects, config, player) => {
@@ -51,7 +51,7 @@ const addPlayer = (objects, config, player) => {
51
51
  objects.players.push(player);
52
52
  }
53
53
 
54
- let configStruct = {
54
+ let config = {
55
55
  name: 'scorekeeper',
56
56
  operators: [
57
57
  "([next])",
@@ -122,36 +122,29 @@ let configStruct = {
122
122
  {
123
123
  where: where(),
124
124
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.isResponse && context.two && context.two.marker == 'next',
125
- apply: ({context, g}) => {
125
+ apply: async ({context, g}) => {
126
126
  const response = context.evalue;
127
127
  const concept = response.two;
128
128
  concept.paraphrase = true
129
129
  concept.isSelf = true
130
- const instance = g(concept.evalue)
130
+ const instance = await g(concept.evalue)
131
131
  return instance
132
132
  }
133
133
  },
134
134
  {
135
135
  where: where(),
136
136
  match: ({context}) => context.marker == 'point' && context.isResponse && context.amount,
137
- apply: ({context, g}) => `${g(context.amount)} points`
137
+ apply: async ({context, g}) => `${await g(context.amount)} points`
138
138
  },
139
139
  {
140
140
  where: where(),
141
141
  match: ({context}) => context.marker == 'scored' && context.paraphrase,
142
- apply: ({context, g}) => `${g(context.player)} got ${g(context.points)}`
142
+ apply: async ({context, g}) => `${await g(context.player)} got ${await g(context.points)}`
143
143
  },
144
- /*
145
- {
146
- where: where(),
147
- match: ({context}) => context.marker == 'enumeration' && context.paraphrase,
148
- apply: ({context, g}) => `${g(context.concept)} are ${g(context.items)}`
149
- },
150
- */
151
144
  {
152
145
  where: where(),
153
146
  match: ({context}) => context.marker == 'start' && context.paraphrase,
154
- apply: ({context, g}) => `start ${g(context.arg)}`
147
+ apply: async ({context, g}) => `start ${await g(context.arg)}`
155
148
  },
156
149
 
157
150
  ],
@@ -161,7 +154,6 @@ let configStruct = {
161
154
  where: where(),
162
155
  match: ({context}) => context.marker == 'player' && context.same,
163
156
  apply: ({context, objects, config, km}) => {
164
- //objects.players = context.same.value.map( (props) => props.value )
165
157
  const players = context.same.value.map( (props) => props.value )
166
158
  setPlayers(objects, config, players)
167
159
  for (let player of objects.players) {
@@ -205,11 +197,11 @@ let configStruct = {
205
197
  matchq: ({objects}) => objects.players.length == 0,
206
198
  applyq: () => 'who are the players?',
207
199
  matchr: ({context}) => context.marker == 'list',
208
- applyr: ({context, gs, objects, config}) => {
200
+ applyr: async ({context, gs, objects, config}) => {
209
201
  const players = context.value.map( (player) => player.value )
210
202
  setPlayers(objects, config, players)
211
203
  objects.allPlayersAreKnown = true;
212
- context.verbatim = `The players are ${gs(objects.players, ' ', ' and ')}`
204
+ context.verbatim = `The players are ${await gs(objects.players, ' ', ' and ')}`
213
205
  context.isResponse = true;
214
206
  }
215
207
  }
@@ -242,12 +234,12 @@ let configStruct = {
242
234
  {
243
235
  where: where(),
244
236
  match: ({context}) => context.marker == 'player' && context.evaluate && context.pullFromContext,
245
- apply: ({context, objects, gs}) => {
237
+ apply: async ({context, objects, gs}) => {
246
238
  const players = objects.players
247
239
  if (players.length == 0) {
248
240
  context.evalue = 'no one'
249
241
  } else {
250
- context.evalue = gs(players, ' ', ' and ')
242
+ context.evalue = await gs(players, ' ', ' and ')
251
243
  }
252
244
  }
253
245
  },
@@ -350,21 +342,14 @@ let configStruct = {
350
342
  ],
351
343
  };
352
344
 
353
- const createConfig = () => {
354
- const config = new Config(configStruct, module)
355
- config.stop_auto_rebuild()
356
- config.add(dialogues(), numbers(), properties())
357
- config.initializer( ({objects, km, isModule}) => {
345
+ const initializer = ({objects, km, isModule}) => {
358
346
  objects.players = []
359
347
  objects.nextPlayer = undefined;
360
348
  setNextPlayer(km, objects);
361
349
  objects.scores = {};
362
350
  objects.winningScore = null
363
351
  objects.allPlayersAreKnown = false;
364
- })
365
- config.restart_auto_rebuild()
366
- return config
367
- }
352
+ }
368
353
 
369
354
  startWithDefault20 = [
370
355
  "greg got 1 point alice got 2 points greg got 1 point start a new game who is next",
@@ -382,9 +367,12 @@ startWithDefault20 = [
382
367
  ]
383
368
 
384
369
  knowledgeModule( {
370
+ config,
371
+ includes: [dialogues, numbers, properties],
372
+ initializer,
373
+
385
374
  module,
386
375
  description: 'scorekeeper for card or dice games',
387
- createConfig,
388
376
  test: {
389
377
  name: './scorekeeper.test.json',
390
378
  contents: scorekeeper_tests,
@@ -1,8 +1,8 @@
1
- const { Config, flatten, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { flatten, knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const sdefaults_tests = require('./sdefaults.test.json')
4
4
 
5
- let configStruct = {
5
+ let config = {
6
6
  name: 'sdefaults',
7
7
  semantics: [
8
8
  {
@@ -12,22 +12,31 @@ let configStruct = {
12
12
  // match: ({context}) => context.flatten || context.listable && context.value[0].flatten,
13
13
  match: ({context}) => context.flatten || context.listable && context.value.some((value) => value.flatten),
14
14
  // match: ({context}) => context.flatten || context.listable || (Array.isArray(context.value) && context.value.some((value) => value.flatten)),
15
- apply: ({config, km, context, s}) => {
15
+ apply: async ({config, km, context, s}) => {
16
16
  const [flats, wf] = flatten(['list'], context)
17
17
  for (let flat of flats) {
18
- s({ ...flat, flatten: false })
18
+ await s({ ...flat, flatten: false })
19
19
  }
20
20
  }
21
21
  },
22
+ {
23
+ notes: 'semanticIsEvaluate',
24
+ where: where(),
25
+ priority: -1,
26
+ match: ({context}) => context.semanticIsEvaluate,
27
+ apply: async ({context, e}) => {
28
+ context.value = await e({ ...context, semanticIsEvaluate: false })
29
+ context.isResponse
30
+ }
31
+ },
22
32
  ],
23
33
  };
24
34
 
25
- const createConfig = () => new Config(configStruct, module)
26
-
27
35
  knowledgeModule({
36
+ config,
37
+
28
38
  module,
29
39
  description: 'defaults for semantics',
30
- createConfig,
31
40
  test: {
32
41
  name: './sdefaults.test.json',
33
42
  contents: sdefaults_tests,
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require("./hierarchy")
4
4
  const numbers = require("./numbers")
@@ -6,7 +6,7 @@ const sizeable_tests = require('./sizeable.test.json')
6
6
 
7
7
  // TODO 1 to 2 sizeables
8
8
 
9
- let configStruct = {
9
+ let config = {
10
10
  name: 'sizeable',
11
11
  operators: [
12
12
  "(([size|]) [sizing] ([sizeable]))",
@@ -52,16 +52,12 @@ let configStruct = {
52
52
  ]
53
53
  };
54
54
 
55
- const createConfig = () => {
56
- const config = new Config(configStruct, module)
57
- config.add(dialogues(), numbers())
58
- return config
59
- }
60
-
61
55
  knowledgeModule({
56
+ config,
57
+ includes: [dialogues, numbers],
58
+
62
59
  module,
63
60
  description: 'Sizeable things',
64
- createConfig,
65
61
  test: {
66
62
  name: './sizeable.test.json',
67
63
  contents: sizeable_tests,