tpmkms 8.0.0-beta.21 → 8.0.0-beta.22

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 (45) hide show
  1. package/common/colors.instance.json +0 -28
  2. package/common/comparable.js +0 -13
  3. package/common/concept.js +9 -5
  4. package/common/countable.js +3 -3
  5. package/common/crew.js +1 -1
  6. package/common/currency.js +3 -3
  7. package/common/dialogues.js +48 -117
  8. package/common/dimension.instance.json +4 -4
  9. package/common/dimension.js +8 -8
  10. package/common/dimension.test.json +242 -1248
  11. package/common/edible.instance.json +30 -58
  12. package/common/emotions.js +1 -1
  13. package/common/events.js +3 -3
  14. package/common/fastfood.instance.json +873 -1072
  15. package/common/fastfood.js +20 -20
  16. package/common/formulas.instance.json +6 -6
  17. package/common/formulas.js +8 -8
  18. package/common/gdefaults.js +11 -11
  19. package/common/help.js +1 -1
  20. package/common/helpers/dialogues.js +2 -3
  21. package/common/helpers/properties.js +48 -58
  22. package/common/hierarchy.js +9 -13
  23. package/common/javascript.js +5 -5
  24. package/common/math.instance.json +12 -12
  25. package/common/math.js +5 -5
  26. package/common/meta.js +19 -26
  27. package/common/ordering.js +1 -1
  28. package/common/people.js +1 -2
  29. package/common/percentages.js +2 -2
  30. package/common/pipboy.instance.json +30 -86
  31. package/common/pipboy.js +25 -28
  32. package/common/pokemon.js +1 -1
  33. package/common/properties.js +48 -121
  34. package/common/punctuation.js +1 -1
  35. package/common/reports.instance.json +1 -1
  36. package/common/reports.js +48 -65
  37. package/common/scorekeeper.js +10 -18
  38. package/common/sdefaults.js +4 -4
  39. package/common/stm.js +1 -1
  40. package/common/tell.js +6 -6
  41. package/common/temperature.instance.json +0 -84
  42. package/common/testing.js +3 -3
  43. package/common/time.js +3 -3
  44. package/common/ui.js +5 -5
  45. package/package.json +2 -2
@@ -3135,20 +3135,6 @@
3135
3135
  1
3136
3136
  ]
3137
3137
  ],
3138
- [
3139
- [
3140
- "is",
3141
- 0
3142
- ],
3143
- [
3144
- "list",
3145
- 1
3146
- ],
3147
- [
3148
- "unknown",
3149
- 1
3150
- ]
3151
- ],
3152
3138
  [
3153
3139
  [
3154
3140
  "is",
@@ -25226,20 +25212,6 @@
25226
25212
  1
25227
25213
  ]
25228
25214
  ],
25229
- [
25230
- [
25231
- "is",
25232
- 0
25233
- ],
25234
- [
25235
- "list",
25236
- 1
25237
- ],
25238
- [
25239
- "unknown",
25240
- 1
25241
- ]
25242
- ],
25243
25215
  [
25244
25216
  [
25245
25217
  "is",
@@ -45,19 +45,6 @@ let configStruct = {
45
45
  bridge: "{ ...next(operator) }"
46
46
  },
47
47
  ],
48
-
49
- /*
50
- generators: [
51
- {
52
- where: where(),
53
- match: ({context}) => false && context.quantity,
54
- apply: ({context, g}) => {
55
- const countable = g({ ...context, quantity: undefined, number: context.quanity == 1 ? 'one' : 'many' })
56
- return `${g(context.quantity)} ${countable}`
57
- }
58
- },
59
- ]
60
- */
61
48
  };
62
49
 
63
50
  const createConfig = async () => {
package/common/concept.js CHANGED
@@ -85,7 +85,7 @@ const createConfig = async () => {
85
85
  }
86
86
  return true
87
87
  },
88
- apply: ({g, context}) => {
88
+ apply: async ({g, context}) => {
89
89
  const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
90
90
  context.word = context.value[0].word
91
91
  context.value = null
@@ -96,17 +96,21 @@ const createConfig = async () => {
96
96
  value: modifiers
97
97
  }
98
98
  context.paraphrase = true
99
- return g(context)
99
+ return await g(context)
100
100
  }
101
101
  },
102
102
  {
103
103
  where: where(),
104
104
  match: ({context}) => context.marker == 'modifies' && context.paraphrase,
105
- apply: ({context, gp, gw}) => {
105
+ apply: async ({context, gp, gw}) => {
106
+ const modifiers = []
107
+ for (modifier of context.modifiers) {
108
+ modifiers.push(await gp(modifier))
109
+ }
106
110
  if (context.literally) {
107
- return `${context.modifiers.map(gp).join(" ")} literally ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
111
+ return `${modifiers.join(" ")} literally ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
108
112
  } else {
109
- return `${context.modifiers.map(gp).join(" ")} ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
113
+ return `${modifiers.join(" ")} ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
110
114
  }
111
115
  }
112
116
  // const chosen = chooseNumber(context, word.singular, word.plural)
@@ -63,13 +63,13 @@ let configStruct = {
63
63
  {
64
64
  where: where(),
65
65
  match: ({context}) => false && context.quantity,
66
- apply: ({context, g}) => {
66
+ apply: async ({context, g}) => {
67
67
  let number = context.quantity.number || 'one'
68
68
  if (context.quantity.value > 1) {
69
69
  number = 'many'
70
70
  }
71
- const countable = g({ ...context, quantity: undefined, number})
72
- return `${g(context.quantity)} ${countable}`
71
+ const countable = await g({ ...context, quantity: undefined, number})
72
+ return `${await g(context.quantity)} ${countable}`
73
73
  }
74
74
  },
75
75
  ]
package/common/crew.js CHANGED
@@ -42,7 +42,7 @@ const createConfig = async () => {
42
42
  config.stop_auto_rebuild()
43
43
  await config.add(avatar, animals)
44
44
  crew_instance.base = 'avatar'
45
- config.initializer( ({config, apis}) => {
45
+ await config.initializer( ({config, apis}) => {
46
46
  const api = apis('properties')
47
47
  const conceptApi = apis('concept')
48
48
  // conceptApi.kindOfConcept({ config, modifiers: ['photon'], object: 'torpedo' })
@@ -60,14 +60,14 @@ let configStruct = {
60
60
  {
61
61
  where: where(),
62
62
  match: ({context}) => context.marker == 'currency' && !context.isAbstract,
63
- apply: ({context, g}) => {
63
+ apply: async ({context, g}) => {
64
64
  word = Object.assign({}, context.amount)
65
65
  word.isAbstract = true
66
66
  word.marker = 'currency'
67
67
  word.units = context.units
68
68
  word.value = context.amount.value
69
69
  // generator = [({context}) => context.marker == 'currency' && context.units == words.units && context.value > 1 && context.isAbstract, ({context, g}) => words.many ]
70
- return `${g(context.amount.value)} ${g(word)}`
70
+ return `${await g(context.amount.value)} ${await g(word)}`
71
71
  }
72
72
  },
73
73
  ],
@@ -95,7 +95,7 @@ const createConfig = async () => {
95
95
  config.stop_auto_rebuild()
96
96
  await config.add(numbersKM)
97
97
  await config.setApi(api)
98
- config.initializer( ({config, objects, apis, addWord, addGenerator, baseConfig, uuid}) => {
98
+ await config.initializer( ({config, objects, apis, addWord, addGenerator, baseConfig, uuid}) => {
99
99
  // const api = config.km('currency').api
100
100
  // const api = kms.currency.api
101
101
  const api = apis('currency')
@@ -105,7 +105,7 @@ let configStruct = {
105
105
  {
106
106
  id: 'makeObject',
107
107
  bridge: "{ ...next(operator), object: after[0] }",
108
- generatorp: ({context, gp}) => `${context.word} ${gp(context.object)}`,
108
+ generatorp: async ({context, gp}) => `${context.word} ${await gp(context.object)}`,
109
109
  semantic: ({config, context, api}) => {
110
110
  api.makeObject({ context: context.object, config, types: [] })
111
111
  }
@@ -113,7 +113,7 @@ let configStruct = {
113
113
  {
114
114
  id: 'setIdSuffix',
115
115
  bridge: "{ ...next(operator), suffix: after[0] }",
116
- generatorp: ({context, gp}) => `${context.word} ${gp(context.suffix)}`,
116
+ generatorp: async ({context, gp}) => `${context.word} ${await gp(context.suffix)}`,
117
117
  semantic: ({context, api}) => {
118
118
  api.setIdSuffix(context.suffix.text)
119
119
  }
@@ -163,8 +163,8 @@ let configStruct = {
163
163
  level: 0,
164
164
  isA: ['preposition'],
165
165
  bridge: "{ ...next(operator), toObject: after[0] }",
166
- generatorp: ({context, gp}) => {
167
- return `to ${gp(context.toObject)}`
166
+ generatorp: async ({context, gp}) => {
167
+ return `to ${await gp(context.toObject)}`
168
168
  },
169
169
  },
170
170
  { id: "toAble", level: 0, bridge: "{ ...next(operator) }" },
@@ -350,10 +350,10 @@ let configStruct = {
350
350
  where: where(),
351
351
  notes: "handle making responses brief",
352
352
  match: ({context, objects}) => (context.topLevel || context.isResponse) && objects.brief && !context.briefWasRun,
353
- apply: ({context, g}) => {
353
+ apply: async ({context, g}) => {
354
354
  const focussed = focus(context)
355
355
  context.briefWasRun = true
356
- return g(focussed)
356
+ return await g(focussed)
357
357
  },
358
358
  priority: -2,
359
359
  },
@@ -414,8 +414,8 @@ let configStruct = {
414
414
  // ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
415
415
  // ({context, hierarchy}) => context.marker == 'list' && context.value,
416
416
  match: ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value && context.value.length > 0 && context.value[0].marker == 'yesno',
417
- apply: ({context, g, gs}) => {
418
- return `${g(context.value[0])} ${gs(context.value.slice(1), ', ', ' and ')}`
417
+ apply: async ({context, g, gs}) => {
418
+ return `${await g(context.value[0])} ${await gs(context.value.slice(1), ', ', ' and ')}`
419
419
  }
420
420
  },
421
421
 
@@ -425,11 +425,11 @@ let configStruct = {
425
425
  // ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
426
426
  // ({context, hierarchy}) => context.marker == 'list' && context.value,
427
427
  match: ({context, hierarchy}) => context.marker == 'list' && context.value,
428
- apply: ({context, gs}) => {
428
+ apply: async ({context, gs}) => {
429
429
  if (context.newLinesOnly) {
430
- return gs(context.value, '\n')
430
+ return await gs(context.value, '\n')
431
431
  } else {
432
- return gs(context.value, ', ', ' and ')
432
+ return await gs(context.value, ', ', ' and ')
433
433
  }
434
434
  }
435
435
  },
@@ -439,23 +439,10 @@ let configStruct = {
439
439
  notes: 'paraphrase a queryable response',
440
440
  // || context.evalue.paraphrase -> when the evalue acts as a paraphrase value
441
441
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.evalue && (!context.paraphrase || context.evalue.paraphrase),
442
- apply: ({context, g}) => {
443
- return g(context.evalue)
442
+ apply: async ({context, g}) => {
443
+ return await g(context.evalue)
444
444
  }
445
445
  },
446
- /* dup of one above
447
- {
448
- where: where(),
449
- notes: 'paraphrase a queryable',
450
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && !context.paraphrase && context.evalue,
451
- apply: ({context, g}) => {
452
- const oldValue = context.evalue.paraphrase
453
- const result = g(context.evalue)
454
- context.evalue.paraphrase = oldValue
455
- return result
456
- }
457
- },
458
- */
459
446
  {
460
447
  where: where(),
461
448
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.isSelf && context.subject == 'my',
@@ -464,7 +451,7 @@ let configStruct = {
464
451
  {
465
452
  where: where(),
466
453
  match: ({context, hierarchy}) => ['it', 'what'].includes(context.marker) && context.paraphrase,
467
- apply: ({g, context}) => `${context.word}`
454
+ apply: ({context}) => `${context.word}`
468
455
  },
469
456
  {
470
457
  where: where(),
@@ -474,15 +461,8 @@ let configStruct = {
474
461
  {
475
462
  where: where(),
476
463
  match: ({context, hierarchy}) => ['my', 'your'].includes(context.subject) && hierarchy.isA(context.marker, 'queryable') && context.paraphrase,
477
- apply: ({g, context}) => `${context.subject} ${context.marker}`
478
- },
479
- /*
480
- {
481
- where: where(),
482
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'theAble') && context.paraphrase && context.wantsValue && !context.pullFromContext,
483
- apply: ({g, context}) => `a ${context.word}`
464
+ apply: ({context}) => `${context.subject} ${context.marker}`
484
465
  },
485
- */
486
466
  {
487
467
  where: where(),
488
468
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.subject,
@@ -507,8 +487,8 @@ let configStruct = {
507
487
  {
508
488
  where: where(),
509
489
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query,
510
- apply: ({context, gp}) => {
511
- return `${gp({...context, topLevel: undefined})}?`
490
+ apply: async ({context, gp}) => {
491
+ return `${await gp({...context, topLevel: undefined})}?`
512
492
  },
513
493
  priority: -1,
514
494
  },
@@ -516,27 +496,27 @@ let configStruct = {
516
496
  where: where(),
517
497
  notes: "x is y",
518
498
  match: ({context, hierarchy}) => { return hierarchy.isA(context.marker, 'is') && context.paraphrase },
519
- apply: ({context, g, gp}) => {
520
- return `${g({ ...context.one, paraphrase: true })} ${context.word} ${gp(context.two)}`
499
+ apply: async ({context, g, gp}) => {
500
+ return `${await g({ ...context.one, paraphrase: true })} ${context.word} ${await gp(context.two)}`
521
501
  }
522
502
  },
523
503
  {
524
504
  where: where(),
525
505
  notes: 'is with a response defined',
526
506
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.evalue,
527
- apply: ({context, g, gs}) => {
507
+ apply: async ({context, g, gs}) => {
528
508
  const response = context.evalue;
529
509
  const concept = response.concept;
530
510
  if (concept) {
531
511
  concept.paraphrase = true
532
512
  concept.isSelf = true
533
- const instance = g(response.instance)
534
- return `${g(concept)} ${context.word} ${instance}`
513
+ const instance = await g(response.instance)
514
+ return `${await g(concept)} ${context.word} ${instance}`
535
515
  } else {
536
516
  if (Array.isArray(response)) {
537
- return `${gs(response)}`
517
+ return `${await gs(response)}`
538
518
  } else {
539
- return `${g(response)}`
519
+ return `${await g(response)}`
540
520
  }
541
521
  }
542
522
  }
@@ -545,13 +525,13 @@ let configStruct = {
545
525
  where: where(),
546
526
  notes: 'x is y (not a response)',
547
527
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && !context.evalue,
548
- apply: ({context, g, gp, gr, callId}) => {
528
+ apply: async ({context, g, gp, gr, callId}) => {
549
529
  if ((context.two.evalue || {}).marker == 'answerNotKnown') {
550
- return g(context.two.evalue)
530
+ return await g(context.two.evalue)
551
531
  }
552
532
 
553
533
  if (!context.isResponse) {
554
- return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
534
+ return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
555
535
  }
556
536
 
557
537
  const hasFocus = (property) => {
@@ -576,17 +556,15 @@ let configStruct = {
576
556
  }
577
557
  // greg101
578
558
  if (focus == 'one') {
579
- return `${g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gp(context.one)}`
559
+ return `${await g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gp(context.one)}`
580
560
  } else {
581
561
  // TODO fix this using the assumed and that whole mess. change isResponse to useValue
582
562
  if (context.isResponse) {
583
- return `${gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
563
+ return `${await gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
584
564
  } else {
585
- return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gr(context.two)}`
565
+ return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gr(context.two)}`
586
566
  }
587
- // return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
588
567
  }
589
- // return `${g({...context.one})} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
590
568
  },
591
569
  },
592
570
  ],
@@ -612,10 +590,10 @@ let configStruct = {
612
590
  {
613
591
  where: where(),
614
592
  match: ({context}) => context.marker === 'error',
615
- apply: ({context, gp}) => {
593
+ apply: async ({context, gp}) => {
616
594
  context.evalue = "That is not known"
617
595
  if (context.reason) {
618
- context.evalue += ` because ${gp(context.reason)}`
596
+ context.evalue += ` because ${await gp(context.reason)}`
619
597
  }
620
598
  context.isResponse = true
621
599
  }
@@ -625,7 +603,7 @@ let configStruct = {
625
603
  notes: 'pull from context',
626
604
  // match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
627
605
  match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
628
- apply: ({callId, context, s, kms, e, log, retry}) => {
606
+ apply: async ({callId, context, kms, e, log, retry}) => {
629
607
  if (true) {
630
608
  /*
631
609
  {
@@ -659,7 +637,7 @@ let configStruct = {
659
637
  return
660
638
  }
661
639
 
662
- const instance = e(context.value)
640
+ const instance = await e(context.value)
663
641
  if (instance.evalue && !instance.edefault) {
664
642
  context.value = instance.evalue
665
643
  }
@@ -701,7 +679,7 @@ let configStruct = {
701
679
  // avoid loops
702
680
  if (context.marker != 'unknown') {
703
681
  if (context.value.marker != context.marker) {
704
- const instance = e(context.value)
682
+ const instance = await e(context.value)
705
683
  if (instance.evalue && !instance.edefault) {
706
684
  context.value = instance.evalue
707
685
  }
@@ -723,7 +701,7 @@ let configStruct = {
723
701
  */
724
702
 
725
703
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query,
726
- apply: ({context, s, log, km, objects, e}) => {
704
+ apply: async ({context, s, log, km, objects, e}) => {
727
705
  const one = context.one;
728
706
  const two = context.two;
729
707
  let concept, value;
@@ -737,7 +715,7 @@ let configStruct = {
737
715
  // km('dialogues').api.mentioned(concept)
738
716
  // TODO wtf is the next line?
739
717
  value = JSON.parse(JSON.stringify(value))
740
- let instance = e(value)
718
+ let instance = await e(value)
741
719
  if (false && instance.evalue) {
742
720
  km('stm').api.mentioned(value)
743
721
  }
@@ -801,14 +779,14 @@ let configStruct = {
801
779
  where: where(),
802
780
  notes: 'x is y. handles x is a kind of y or x = y in the stm',
803
781
  match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
804
- apply: ({context, s, log, api, kms, config}) => {
782
+ apply: async ({context, s, log, api, kms, config}) => {
805
783
  // const oneZero = { ...context.one }
806
784
  // const twoZero = { ...context.two }
807
785
 
808
786
  const one = context.one;
809
787
  const two = context.two;
810
788
  one.same = two;
811
- const onePrime = s(one)
789
+ const onePrime = await s(one)
812
790
  if (!onePrime.sameWasProcessed) {
813
791
  warningSameNotEvaluated(log, one)
814
792
  } else {
@@ -821,7 +799,7 @@ let configStruct = {
821
799
  let twoPrime;
822
800
  if (!onePrime.sameWasProcessed) {
823
801
  two.same = one
824
- twoPrime = s(two)
802
+ twoPrime = await s(two)
825
803
  if (!twoPrime.sameWasProcessed) {
826
804
  warningSameNotEvaluated(log, two)
827
805
  } else {
@@ -840,20 +818,6 @@ let configStruct = {
840
818
  }
841
819
  }
842
820
  },
843
- /*
844
- {
845
- where: where(),
846
- notes: 'x = y in the stm',
847
- match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
848
- apply: ({context, s, log, api, kms, config}) => {
849
- const one = context.one;
850
- const two = context.two;
851
- api.makeObject({ context: one, config, types: context.two.types || [] })
852
- kms.stm.api.setVariable(one.value, two)
853
- kms.stm.api.mentioned(one, two)
854
- }
855
- },
856
- */
857
821
  {
858
822
  where: where(),
859
823
  notes: 'get variable from stm',
@@ -861,48 +825,15 @@ let configStruct = {
861
825
  match: ({context, kms}) => context.evaluate && kms.stm.api.getVariable(context.value) != context.value,
862
826
  // match: ({context, kms}) => context.evaluate,
863
827
  priority: -1,
864
- apply: ({context, kms, e}) => {
828
+ apply: async ({context, kms, e}) => {
865
829
  const api = kms.stm.api
866
830
  context.value = api.getVariable(context.value)
867
- /*
868
- if (!context.value && context.marker !== 'unknown') {
869
- context.value = api.getVariable(context.marker)
870
- }
871
- */
872
831
  if (context.value && context.value.marker) {
873
- context.evalue = e(context.value)
832
+ context.evalue = await e(context.value)
874
833
  }
875
834
  context.focusableForPhrase = true
876
835
  }
877
836
  },
878
- /*
879
- {
880
- where: where(),
881
- notes: 'default handle evaluate',
882
- match: ({context, kms}) => context.evaluate && context.value,
883
- // match: ({context, kms}) => context.evaluate,
884
- // priority: -1,
885
- apply: ({context, kms, e}) => {
886
- if (context.value && context.value.marker) {
887
- context.evalue = e(context.value)
888
- }
889
- }
890
- },
891
- */
892
- /*
893
- {
894
- priority: 2,
895
- notes: 'evaluate top level not already done',
896
- match: ({context}) => false && context.topLevel && !context.evalue,
897
- apply: ({context, e}) => {
898
- const instance = e({ ...context, value: undefined, topLevel: undefined })
899
- if (instance.evalue && !instance.edefault) {
900
- context.evalue = instance
901
- context.isResponse = true
902
- }
903
- }
904
- },
905
- */
906
837
  ],
907
838
  };
908
839
 
@@ -947,9 +878,9 @@ const getAsk = (config) => (uuid) => {
947
878
  where: semantic.where || ask.where || where(2),
948
879
  source: 'response',
949
880
  match: (args) => semantic.match(args),
950
- apply: (args) => {
881
+ apply: async (args) => {
951
882
  setWasApplied(true)
952
- semantic.apply(args)
883
+ await semantic.apply(args)
953
884
  },
954
885
  })
955
886
  }
@@ -966,7 +897,7 @@ const getAsk = (config) => (uuid) => {
966
897
  onNevermind: ask.onNevermind,
967
898
  source: 'question',
968
899
  match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
969
- apply: (args) => {
900
+ apply: async (args) => {
970
901
  let matchq = ask.matchq
971
902
  let applyq = ask.applyq
972
903
  if (!matchq) {
@@ -977,11 +908,11 @@ const getAsk = (config) => (uuid) => {
977
908
  return ask.applyq(args)
978
909
  }
979
910
  }
980
- if (matchq(args)) {
911
+ if (await matchq(args)) {
981
912
  setWasAsked(true)
982
913
  setWasApplied(false)
983
914
  // args.context.motivationKeep = true
984
- args.verbatim(applyq(args))
915
+ args.verbatim(await applyq(args))
985
916
  /*
986
917
  args.context.verbatim = applyq(args)
987
918
  args.context.isResponse = true;
@@ -1007,7 +938,7 @@ const createConfig = async () => {
1007
938
  config.stop_auto_rebuild()
1008
939
  await config.setApi(api)
1009
940
  await config.add(gdefaults, sdefaults, pos, negation, stm, meta, punctuation)
1010
- config.initializer( ({objects, config, isModule}) => {
941
+ await config.initializer( ({objects, config, isModule}) => {
1011
942
  /* TODO add this beck in. some stuff from config needs to be here
1012
943
  config.addArgs((args) => ({
1013
944
  e: (context) => config.api.getEvaluator(args.s, args.log, context),
@@ -43,7 +43,7 @@
43
43
  {
44
44
  "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:77",
45
45
  "match": "({context}) => context.marker == 'noconversion'",
46
- "apply": "({context, gp}) => `there is no conversion between ${gp(context.from)} and ${gp(context.to)}`"
46
+ "apply": "async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`"
47
47
  }
48
48
  ],
49
49
  "bridges": [
@@ -75,7 +75,7 @@
75
75
  "isA": [
76
76
  "amount"
77
77
  ],
78
- "generatorp": "({context, g}) => (context.amount) ? `${g(context.amount)} ${context.word}` : context.word",
78
+ "generatorp": "async ({context, g}) => (context.amount) ? `${await g(context.amount)} ${context.word}` : context.word",
79
79
  "bridge": "{ ...next(operator), value: before[0].value, amount: before[0] }"
80
80
  },
81
81
  {
@@ -101,8 +101,8 @@
101
101
  1
102
102
  ]
103
103
  ],
104
- "generatorp": "({context, g}) => `${g(context.from)} ${context.word} ${g(context.to)}`",
105
- "evaluator": "({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = e(from).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned(reason)\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
104
+ "generatorp": "async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`",
105
+ "evaluator": "async ({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = (await e(from)).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned(reason)\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = await e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
106
106
  },
107
107
  {
108
108
  "id": "unit"
@@ -36,7 +36,7 @@ class API {
36
36
  config.addBridge({
37
37
  id: dimension,
38
38
  isA: ['dimension'],
39
- generatorp: ({context, g}) => context.amount ? `${g(context.amount)} ${g(context.unit)}` : context.word,
39
+ generatorp: async ({context, g}) => context.amount ? `${await g(context.amount)} ${await g(context.unit)}` : context.word,
40
40
  })
41
41
 
42
42
  // for example, celcius and fahrenheit
@@ -76,7 +76,7 @@ let configStruct = {
76
76
  {
77
77
  where: where(),
78
78
  match: ({context}) => context.marker == 'noconversion',
79
- apply: ({context, gp}) => `there is no conversion between ${gp(context.from)} and ${gp(context.to)}`,
79
+ apply: async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`,
80
80
  },
81
81
  ],
82
82
  bridges: [
@@ -86,7 +86,7 @@ let configStruct = {
86
86
  isA: [],
87
87
  generatorpr: {
88
88
  match: ({context}) => context.amount,
89
- apply: ({context, g, gp, gr}) => `${gr(context.amount)} ${gp(context.unit)}`,
89
+ apply: async ({context, gp, gr}) => `${await gr(context.amount)} ${await gp(context.unit)}`,
90
90
  },
91
91
  },
92
92
  { id: "length", isA: ['dimension'], development: true },
@@ -105,7 +105,7 @@ let configStruct = {
105
105
  id: "degree",
106
106
  words: [{ word: 'degrees', number: 'many' }],
107
107
  isA: ['amount'],
108
- generatorp: ({context, g}) => (context.amount) ? `${g(context.amount)} ${context.word}` : context.word,
108
+ generatorp: async ({context, g}) => (context.amount) ? `${await g(context.amount)} ${context.word}` : context.word,
109
109
  bridge: "{ ...next(operator), value: before[0].value, amount: before[0] }",
110
110
  },
111
111
  {
@@ -119,9 +119,9 @@ let configStruct = {
119
119
  bridge: "{ ...next(operator), from: before[0], to: after[0] }",
120
120
  isA: ['expression', 'queryable'],
121
121
  after: [['possession', 0], ['possession', 1]],
122
- generatorp: ({context, g}) => `${g(context.from)} ${context.word} ${g(context.to)}`,
122
+ generatorp: async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`,
123
123
  // evaluator: ({context, kms, error}) => {
124
- evaluator: ({context, kms, e, error}) => {
124
+ evaluator: async ({context, kms, e, error}) => {
125
125
  /*
126
126
  error(({context, e}) => {
127
127
  context.evalue = 'dont know...'
@@ -132,7 +132,7 @@ let configStruct = {
132
132
  let evalue;
133
133
  let efrom = from
134
134
  if (!from.unit) {
135
- efrom = e(from).evalue
135
+ efrom = (await e(from)).evalue
136
136
  }
137
137
  if (to.value == efrom.unit.value) {
138
138
  evalue = efrom.amount
@@ -144,7 +144,7 @@ let configStruct = {
144
144
  error(reason)
145
145
  }
146
146
  kms.stm.api.setVariable(efrom.unit.value, efrom.amount)
147
- evalue = e(formula)
147
+ evalue = await e(formula)
148
148
  }
149
149
  /*
150
150
  '{