tpmkms 9.8.0 → 9.9.0

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 (95) hide show
  1. package/common/actions.instance.json +10 -8
  2. package/common/actions.js +13 -11
  3. package/common/angle.instance.json +25 -17
  4. package/common/animals.instance.json +54 -28
  5. package/common/askfor.instance.json +89 -192
  6. package/common/askfor.js +49 -12
  7. package/common/asking.js +13 -5
  8. package/common/avatar.js +3 -3
  9. package/common/can.instance.json +32 -20
  10. package/common/can.js +2 -2
  11. package/common/colors.instance.json +44 -16
  12. package/common/colors.js +1 -1
  13. package/common/comparable.instance.json +25 -22
  14. package/common/compass.instance.json +9 -3
  15. package/common/concept.instance.json +14 -6
  16. package/common/concept.js +2 -0
  17. package/common/conjunction.js +17 -9
  18. package/common/control.js +10 -18
  19. package/common/countable.js +4 -3
  20. package/common/crew.instance.json +95 -27
  21. package/common/dateTimeSelectors.instance.json +4 -4
  22. package/common/dateTimeSelectors.js +4 -7
  23. package/common/dates.instance.json +52 -28
  24. package/common/dates.js +16 -11
  25. package/common/debug.instance.json +48 -0
  26. package/common/debug.js +50 -0
  27. package/common/debug.test.json +1 -0
  28. package/common/dialogues.js +126 -70
  29. package/common/dimension.instance.json +239 -495
  30. package/common/dimension.js +51 -9
  31. package/common/drone.instance.json +395 -84
  32. package/common/drone.js +43 -50
  33. package/common/drone_v1.instance.json +36 -12
  34. package/common/drone_v1.js +14 -9
  35. package/common/edible.instance.json +96 -32
  36. package/common/emotions.instance.json +15 -1
  37. package/common/evaluate.js +10 -13
  38. package/common/fastfood.instance.json +282 -100
  39. package/common/fastfood.js +30 -15
  40. package/common/formulas.instance.json +162 -24
  41. package/common/formulas.js +18 -9
  42. package/common/gdefaults.js +20 -96
  43. package/common/helpers/concept.js +2 -9
  44. package/common/helpers/conjunction.js +11 -1
  45. package/common/helpers/dialogues.js +48 -24
  46. package/common/helpers/gdefaults.js +15 -5
  47. package/common/helpers/properties.js +125 -326
  48. package/common/helpers.js +28 -58
  49. package/common/hierarchy.js +71 -41
  50. package/common/kirk.instance.json +3 -1
  51. package/common/latin.instance.json +10 -10
  52. package/common/latin.js +5 -5
  53. package/common/length.instance.json +247 -61
  54. package/common/math.instance.json +144 -5
  55. package/common/math.js +18 -5
  56. package/common/menus.instance.json +29 -11
  57. package/common/menus.js +8 -5
  58. package/common/meta.js +14 -13
  59. package/common/nameable.js +9 -5
  60. package/common/numbers.instance.json +5 -3
  61. package/common/numbers.js +28 -28
  62. package/common/ordering.instance.json +53 -4
  63. package/common/ordinals.js +25 -25
  64. package/common/people.instance.json +66 -12
  65. package/common/percentages.js +4 -2
  66. package/common/pipboy.instance.json +89 -44
  67. package/common/pipboy.js +21 -14
  68. package/common/pokemon.instance.json +39 -13
  69. package/common/pressure.instance.json +14 -6
  70. package/common/properties.instance.json +2370 -511
  71. package/common/properties.js +496 -78
  72. package/common/punctuation.js +1 -0
  73. package/common/rates.instance.json +2 -2
  74. package/common/rates.js +3 -3
  75. package/common/reminders.instance.json +16 -0
  76. package/common/reminders.js +24 -20
  77. package/common/reports.instance.json +11 -12
  78. package/common/reports.js +12 -12
  79. package/common/scorekeeper.js +20 -10
  80. package/common/sdefaults.js +30 -9
  81. package/common/spock.instance.json +3 -1
  82. package/common/stm.js +16 -21
  83. package/common/temperature.instance.json +19 -11
  84. package/common/testing.js +2 -2
  85. package/common/time.instance.json +104 -47
  86. package/common/time.js +9 -8
  87. package/common/ui.instance.json +4 -2
  88. package/common/ui.js +5 -5
  89. package/common/weight.instance.json +86 -21
  90. package/common/weight.js +5 -1
  91. package/common/words.js +113 -2
  92. package/common/wp.instance.json +125 -18
  93. package/common/wp.js +6 -2
  94. package/main.js +2 -0
  95. package/package.json +7 -3
@@ -10,10 +10,10 @@ const negation = require('./negation.js')
10
10
  const punctuation = require('./punctuation.js')
11
11
  const stm = require('./stm.js')
12
12
  const _ = require('lodash')
13
- const { API } = require('./helpers/dialogues')
13
+ const { API, focus } = require('./helpers/dialogues')
14
14
  const { isMany, propertyToArray, words } = require('./helpers')
15
15
  const dialogues_tests = require('./dialogues.test.json')
16
- const { defaultObjectCheck, defaultContextCheck, indent, focus } = require('./helpers')
16
+ const { defaultObjectCheck, defaultContextCheck, indent } = require('./helpers')
17
17
  const pluralize = require('pluralize')
18
18
 
19
19
  function warningIsANotImplemented(log, context) {
@@ -57,6 +57,7 @@ const config = {
57
57
 
58
58
  "(<what> ([whatAble|]))",
59
59
  "([what:optional])",
60
+ "([who])",
60
61
 
61
62
  "([be] ([briefOrWordy|]))",
62
63
 
@@ -71,7 +72,6 @@ const config = {
71
72
  //"arm them, what, the phasers"
72
73
  //greg is a first name
73
74
  "([yesno|])",
74
- { pattern: "([debug23])" },
75
75
 
76
76
  "([to] ([toAble|]))",
77
77
  ],
@@ -111,6 +111,7 @@ const config = {
111
111
  },
112
112
  {
113
113
  id: 'makeObject',
114
+ where: where(),
114
115
  bridge: "{ ...next(operator), object: after[0] }",
115
116
  enhanced_associations: false,
116
117
  generatorp: async ({context, gp}) => `${context.word} ${await gp(context.object)}`,
@@ -120,6 +121,7 @@ const config = {
120
121
  },
121
122
  {
122
123
  id: 'setIdSuffix',
124
+ where: where(),
123
125
  enhanced_associations: false,
124
126
  bridge: "{ ...next(operator), suffix: after[0] }",
125
127
  generatorp: async ({context, gp}) => `${context.word} ${await gp(context.suffix)}`,
@@ -129,6 +131,7 @@ const config = {
129
131
  },
130
132
  {
131
133
  id: 'resetIdSuffix',
134
+ where: where(),
132
135
  semantic: ({context, api}) => {
133
136
  api.setIdSuffix('')
134
137
  }
@@ -141,15 +144,20 @@ const config = {
141
144
  optional: { 1: "{ marker: 'unknown', implicit: true, concept: true }", },
142
145
  },
143
146
 
144
- { id: "debug23" },
145
147
  {
146
148
  id: "what",
147
- optional: "{ ...next(operator), query: ['what'], determined: true }",
148
- bridge: "{ ...after, query: ['what'], modifiers: ['what'], what: operator }"
149
+ isA: ['queryable'],
150
+ optional: "{ ...next(operator), query: ['what'], determined: true, isVariable: true }",
151
+ bridge: "{ ...after, query: ['what'], modifiers: ['what'], what: operator, isVariable: true }"
152
+ },
153
+ {
154
+ id: "who",
155
+ isA: ['queryable'],
156
+ initial: { query: true, isVariable: true },
149
157
  },
150
158
  { id: "whatAble" },
151
159
 
152
- // context.instance == variables.instance (unification)
160
+ // context.isInstance == variables.isInstance (unification)
153
161
  {
154
162
  where: where(),
155
163
  id: "to",
@@ -227,7 +235,8 @@ const config = {
227
235
  words: {
228
236
  "literals": {
229
237
  "?": [{"id": "questionMark", "initial": "{}" }],
230
- "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
238
+ // TODO make who its own concept
239
+ // "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
231
240
  "yes": [{"id": "yesno", "initial": "{ value: true }" }],
232
241
  "no": [{"id": "yesno", "initial": "{ value: false }" }],
233
242
  "brief": [{"id": "briefOrWordy", "initial": "{ value: 'brief' }" }],
@@ -267,7 +276,6 @@ const config = {
267
276
  ['the', 'article'],
268
277
  ['theAble', 'queryable'],
269
278
  ['it', 'queryable'],
270
- ['what', 'queryable'],
271
279
  ['whatAble', 'queryable'],
272
280
  ['negatable', 'queryable'],
273
281
  ['is', 'canBeQuestion'],
@@ -282,12 +290,13 @@ const config = {
282
290
  {
283
291
  where: where(),
284
292
  notes: "handle making responses brief",
285
- match: ({context, objects, callId}) => (context.topLevel || context.isResponse) && objects.brief && !context.briefWasRun,
286
- apply: async ({context, g}) => {
287
- const focussed = focus(context)
288
- context.briefWasRun = true
293
+ // TODO make this use callOnce
294
+ match: ({context, objects, callId}) => (context.topLevel || context.isResponse) && objects.brief && !context.briefWasRun && !context.paraphrase,
295
+ apply: async ({context, g, toEValue}) => {
296
+ const focussed = focus(toEValue(context))
297
+ focussed.briefWasRun = true
289
298
  const result = await g(focussed)
290
- context.briefWasRun = false
299
+ focussed.briefWasRun = false
291
300
  return result
292
301
  },
293
302
  priority: -2,
@@ -301,13 +310,13 @@ const config = {
301
310
  {
302
311
  where: where(),
303
312
  notes: "unknown answer default response",
304
- match: ({context, namespaced}) => context.marker == 'answerNotKnown' && context.brief,
313
+ match: ({context, namespaced}) => context.marker === 'undefined' && context.brief,
305
314
  apply: ({context}) => `not known`,
306
315
  },
307
316
  {
308
317
  where: where(),
309
318
  notes: "unknown answer default response",
310
- match: ({context}) => context.marker == 'answerNotKnown',
319
+ match: ({context}) => context.marker === 'undefined',
311
320
  apply: ({context}) => `that is not known`,
312
321
  },
313
322
  {
@@ -405,7 +414,9 @@ const config = {
405
414
  },
406
415
  {
407
416
  where: where(),
408
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query,
417
+ match: ({context, hierarchy, debug}) => {
418
+ return hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query
419
+ },
409
420
  apply: async ({context, gp}) => {
410
421
  return `${await gp({...context, topLevel: undefined})}?`
411
422
  },
@@ -422,15 +433,16 @@ const config = {
422
433
  {
423
434
  where: where(),
424
435
  notes: 'is with a response defined',
425
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.evalue,
426
- apply: async ({context, g, gs}) => {
436
+ // TODO change concept to be isConcept for the boolean case to avoid this confusion
437
+ match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.evalue && typeof context.evalue.concept !== 'boolean',
438
+ apply: async ({context, debug, g, gs}) => {
427
439
  const response = context.evalue;
428
440
  const concept = response.concept;
429
441
  if (concept) {
430
442
  concept.paraphrase = true
431
443
  concept.isSelf = true
432
- const instance = await g(response.instance)
433
- return `${await g(concept)} ${context.word} ${instance}`
444
+ const isInstance = await g(response.isInstance)
445
+ return `${await g(concept)} ${context.word} ${isInstance}`
434
446
  } else {
435
447
  if (Array.isArray(response)) {
436
448
  return `${await gs(response)}`
@@ -444,8 +456,8 @@ const config = {
444
456
  where: where(),
445
457
  notes: 'x is y',
446
458
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && !context.evalue,
447
- apply: async ({context, g, gp, debug, gr, callId}) => {
448
- if ((context.two.evalue || {}).marker == 'answerNotKnown') {
459
+ apply: async ({isA, context, g, gp, debug, gr, callId}) => {
460
+ if ((context.two.evalue || {}).marker === 'undefined') {
449
461
  return await g(context.two.evalue)
450
462
  }
451
463
 
@@ -453,8 +465,8 @@ const config = {
453
465
  return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
454
466
  }
455
467
 
456
- if (context.response) {
457
- context = context.response
468
+ if (context.evalue) {
469
+ context = context.evalue
458
470
  }
459
471
 
460
472
  function hasFocus(property) {
@@ -477,6 +489,17 @@ const config = {
477
489
  } else {
478
490
  focus = 'one'
479
491
  }
492
+ const other = focus == 'one' ? 'two' : 'one'
493
+ if (!isMany(context[focus]) && isMany(context[other])) {
494
+ focus = other
495
+ }
496
+ // idiom: dont say the name is it. say it is the name
497
+ if (focus == 'one' && isA(context[focus], 'thisitthat')) {
498
+ focus = other
499
+ }
500
+ if (focus == 'two' && context[other].isPropertyValue) {
501
+ focus = other
502
+ }
480
503
  // greg101
481
504
  if (focus == 'one') {
482
505
  let number = 'one'
@@ -487,7 +510,7 @@ const config = {
487
510
  } else {
488
511
  // TODO fix this using the assumed and that whole mess. change isResponse to useValue
489
512
  if (context.isResponse) {
490
- return `${await gp(context.one, { assumed: { responding: true } })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
513
+ return `${await gp(context.one, { assumed: { responding: true } })} ${isMany(context.one) ? "are" : "is"} ${await g(context.two)}`
491
514
  } else {
492
515
  return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gr(context.two)}`
493
516
  }
@@ -499,12 +522,14 @@ const config = {
499
522
  semantics: [
500
523
  {
501
524
  where: where(),
502
- todo: 'debug23',
503
- match: ({context}) => context.marker == 'debug23',
504
- apply: ({context, hierarchy}) => {
505
- debugger // eslint-disable-line no-debugger
506
- debugger // eslint-disable-line no-debugger
525
+ match: ({context}) => {
526
+ return context.marker == 'unify' && context.terms.some((term) => ['what', 'who'].includes(term.marker))
507
527
  },
528
+ apply: async ({context, resolveEvaluate, e, toFinalValue}) => {
529
+ const value = context.terms.find((term) => !['what', 'who'].includes(term.marker))
530
+ instance = await e(value, where())
531
+ await resolveEvaluate(context, instance)
532
+ }
508
533
  },
509
534
  {
510
535
  where: where(),
@@ -518,9 +543,10 @@ const config = {
518
543
  where: where(),
519
544
  match: ({context}) => context.marker === 'error',
520
545
  apply: async ({context, g, gp}) => {
521
- context.evalue = "That is not known"
522
546
  if (context.reason) {
523
- context.evalue += ` because ${await g(context.reason)}`
547
+ context.evalue = `${await g(context.reason)}`
548
+ } else {
549
+ context.evalue = "That is not known"
524
550
  }
525
551
  context.isResponse = true
526
552
  }
@@ -534,52 +560,83 @@ const config = {
534
560
  object is a type (is greg a human) // handled by queryBridge
535
561
  */
536
562
 
563
+ /*
564
+ what is the age of bob
565
+ the age of who is 30 years old
566
+
567
+ both are the sameA
568
+
569
+
570
+ what == the age
571
+ the age == 30 years old
572
+
573
+
574
+ resolve "the age of bob" + "30 years old"
575
+
576
+ what == "the age of bob" -> then resolve "the age of bob"
577
+ the age of who is 30 years old -> 30 years (age) of who
578
+
579
+
580
+
581
+ a b
582
+ one side is query so resolve the other one
583
+ a = "what" | "the age of who"
584
+ b = "the age of bob" | 30 years old
585
+ replace the main
586
+ "the age of bob" | 30 years old is who
587
+ resolve
588
+ 30 years old | bob
589
+ */
537
590
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query,
538
- apply: async ({context, s, log, km, objects, e}) => {
591
+ apply: async ({context, s, log, km, objects, e, toEValue}) => {
539
592
  const one = context.one;
540
593
  const two = context.two;
541
- let concept, value;
594
+
595
+ let query, value;
542
596
  if (one.query) {
543
- concept = one;
597
+ query = one;
544
598
  value = two;
545
599
  } else {
546
- concept = two;
600
+ query = two;
547
601
  value = one;
548
602
  }
549
- // km('dialogues').api.remember(concept)
550
- // TODO wtf is the next line?
551
- value = JSON.parse(JSON.stringify(value))
552
- const instance = await e(value)
553
- if (false && instance.evalue) {
554
- km('stm').api.remember({ context: value })
555
- }
603
+
604
+ const unification = await e({
605
+ marker: 'unify',
606
+ terms: [query, value],
607
+ }, where())
608
+ instance = unification.evalue || { marker: 'undefined' }
609
+
556
610
  if (instance.verbatim) {
557
611
  context.evalue = { verbatim: instance.verbatim }
558
612
  context.isResponse = true
559
613
  return
560
614
  }
561
- // instance.focusable = ['one', 'two']
562
- // concept = JSON.parse(JSON.stringify(value))
563
- concept = _.cloneDeep(value)
615
+
616
+ if (toEValue(instance)?.marker === 'undefined') {
617
+ context.evalue = instance
618
+ context.isResponse = true
619
+ return
620
+ }
621
+
622
+ const concept = _.cloneDeep(value)
564
623
  concept.isQuery = undefined
565
- // greg101
566
- // instance.focusableForPhrase = true
567
624
  instance.focus = true
568
625
  if (concept.hierarchy) {
569
626
  concept.focusableForPhrase = true
570
627
  }
571
- // concept.focus = true
572
628
 
573
629
  const many = isMany(concept) || isMany(instance)
574
630
  const evalue = {
575
- "default": true,
576
- "marker": "is",
577
- "one": concept,
578
- "two": instance,
579
- "focusable": ['two', 'one'],
580
- "word": many ? "are" : "is",
581
- "number": many ? "many" : undefined,
631
+ default: true,
632
+ marker: "is",
633
+ one: concept,
634
+ two: instance,
635
+ focusable: ['two', 'one'],
636
+ word: many ? "are" : "is",
637
+ number: many ? "many" : undefined,
582
638
  }
639
+
583
640
  context.evalue = evalue
584
641
  context.isResponse = true
585
642
  }
@@ -613,7 +670,7 @@ const config = {
613
670
  where: where(),
614
671
  notes: 'x is y. handles x is a kind of y or x = y in the stm',
615
672
  match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
616
- apply: async ({_continue, context, s, debug, log, api, kms, config}) => {
673
+ apply: async ({_continue, context, e, debug, log, api, kms, config}) => {
617
674
  function warningSameNotEvaluated(log, one) {
618
675
  const description = 'WARNING from Dialogues KM: For the "X is Y" type phrase implement a same handler.'
619
676
  const match = `({context}) => context.marker == '${one.marker}' && context.same && <other conditions as you like>`
@@ -625,8 +682,7 @@ const config = {
625
682
 
626
683
  const one = context.one;
627
684
  const two = context.two;
628
- one.same = two;
629
- const onePrime = await s(one)
685
+ const onePrime = await e({ marker: 'same', one: one, two: two }, where())
630
686
  if (!onePrime.sameWasProcessed) {
631
687
  warningSameNotEvaluated(log, one)
632
688
  } else {
@@ -635,7 +691,6 @@ const config = {
635
691
  context.isResponse = true
636
692
  }
637
693
  }
638
- one.same = undefined
639
694
  if (!onePrime.sameWasProcessed) {
640
695
  _continue()
641
696
  }
@@ -659,14 +714,13 @@ const config = {
659
714
  {
660
715
  where: where(),
661
716
  notes: 'get variable from stm',
662
- match: ({context, kms}) => context.evaluate && kms.stm.api.getVariable(context),
663
- // match: ({context, kms}) => context.evaluate,
717
+ match: ({context, kms}) => kms.stm.api.getVariable(context),
664
718
  priority: -1,
665
719
  apply: async ({context, kms, e}) => {
666
720
  const api = kms.stm.api
667
721
  context.value = api.getVariable(context)
668
722
  if (context.value && context.value.marker) {
669
- context.evalue = await e(context.value)
723
+ context.evalue = await e(context.value, where())
670
724
  }
671
725
  context.focusableForPhrase = true
672
726
  }
@@ -675,12 +729,7 @@ const config = {
675
729
  };
676
730
 
677
731
  function initializer({objects, config, isModule}) {
678
- /* TODO add this beck in. some stuff from config needs to be here
679
- config.addArgs((args) => ({
680
- e: (context) => config.api.getEvaluator(args.s, args.log, context),
681
- }))
682
- */
683
- config.addArgs(({config, api, isA}) => ({
732
+ config.addArgs(({config, api, isA, e}) => ({
684
733
  toScopedId: (context) => {
685
734
  return api('dialogues').toScopedId(context)
686
735
  },
@@ -690,6 +739,13 @@ function initializer({objects, config, isModule}) {
690
739
  }
691
740
  },
692
741
  values: propertyToArray,
742
+ unify: async (term1, term2) => {
743
+ const unification = await e({
744
+ marker: 'unify',
745
+ terms: [term1, term2],
746
+ }, where())
747
+ return unification?.evalue
748
+ }
693
749
  }))
694
750
  objects.mentioned = []
695
751
  objects.variables = {