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
@@ -1,5 +1,6 @@
1
- const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, debug, unflatten, flattens } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheckProperties, defaultContextCheck, words } = require('./helpers')
3
+ const _ = require('lodash')
3
4
  const dialogues = require('./dialogues')
4
5
  const hierarchy = require('./hierarchy')
5
6
  const meta = require('./meta')
@@ -57,7 +58,7 @@ V2
57
58
  // [
58
59
  // ({objects, context, args, hierarchy}) =>
59
60
  // hierarchy.isA(context.marker, 'property') &&
60
- // args({ types: ['myObjectType'], properties: ['object'] }) && context.evaluate,
61
+ // args({ types: ['myObjectType'], properties: ['object'] }),
61
62
  // ({objects, context}) => {
62
63
  // context.value = "value" // set the value here somehow
63
64
  // }
@@ -83,9 +84,9 @@ function addPropertyMarker(args) {
83
84
  markerWords = [markerWords]
84
85
  }
85
86
 
86
- const { fragments, s, config } = args
87
+ const { fragments, e, config } = args
87
88
  const instance = await fragments("concept is a property", { concept: { marker: property, level: 0, value: property, word: property } })
88
- await s(instance)
89
+ await e(instance, where())
89
90
  const propertyMarker = `${property}Marker`
90
91
  config.addOperator(`((@<= 'quantity' && context.unit.dimension == ${dimension}) [${propertyMarker}|])`)
91
92
  config.addBridge({
@@ -94,8 +95,17 @@ function addPropertyMarker(args) {
94
95
  isA: ['adjective', 'propertyMarker', 'queryable'],
95
96
  enhanced_associations: true,
96
97
  initial: { markedProperty: property },
97
- check: defaultContextCheckProperties(['markedProperty']),
98
- bridge: `{ ...before[0], checks: append(before.checks, ['repeats']), propertyType: '${property}', : true, isPropertyValue: true, ${property}: operator, interpolate: append(before[0].interpolate, [{ property: '${property}' }]) }`,
98
+ check: defaultContextCheckProperties(['markedProperty', 'quantity']),
99
+ bridge: `{
100
+ ...next(operator),
101
+ quantity: before[0],
102
+ notConjunctableWith: ['quantity'],
103
+ checks: append(before.checks, ['repeats']),
104
+ propertyType: '${property}',
105
+ isPropertyValue: true,
106
+ ${property}: operator,
107
+ interpolate: append(map(before[0].interpolate, { inside: 'quantity', value: element }), [{ property: '${property}' }])
108
+ }`,
99
109
  })
100
110
  }
101
111
  }
@@ -127,60 +137,106 @@ const config = {
127
137
  // the plural of cat is cats what is the plural of cat?
128
138
  // does greg have ears (yes) greg does not have ears does greg have ears (no)
129
139
  // TODO fix @=unknown does not work?!??
130
- "((@<= object || @<=unknown) [hasPropertyValue|is] (context.isPropertyValue == true))",
140
+ "([isPropertyValue])",
141
+ "((@<= object || @<=unknown) [hasPropertyValue|is,are] (context.isPropertyValue == true))",
131
142
  ],
132
143
  // TODO remove these and use localHierarchy if needed
133
144
  hierarchy: [
134
145
  ['unknown', 'hierarchyAble'],
135
146
  ['what', 'object'],
147
+ ['who', 'object'],
136
148
  ],
137
149
  bridges: [
138
150
  {
151
+ where: where(),
139
152
  id: 'howPropertyMarker',
140
153
  bridge: "{ ...after[0], query: ['what'], how: operator, operator: after[0], interpolate: [ { property: 'how' }, { property: 'operator' } ] }",
141
154
  },
142
155
  {
156
+ where: where(),
157
+ id: 'isPropertyValue',
158
+ initial: { isPropertyValue: true },
159
+ },
160
+ {
161
+ where: where(),
143
162
  id: 'hasPropertyValue',
144
163
  isA: ['verb'],
145
164
  preferOver: ['is'],
146
165
  enhanced_associations: true,
147
166
  bridge: "{ ...operator, object: before[0], flatten: true, operator: operator, propertyValue: after[0], interpolate: [{ property: 'object' }, { property: 'operator' }, { property: 'propertyValue' }] }",
148
- semantic: async ({context, e, fragments}) => {
149
- const propertyType = {
150
- marker: context.propertyValue.propertyType,
151
- level: 0,
152
- value: context.propertyValue.propertyType,
153
- }
167
+ semantic: async ({gp, context, api, callId, e, debug, toArray, fragments, resolveEvaluate, getWordFromDictionary}) => {
168
+ // TODO is there some way to make lookup up and setting the value into the same operation?
169
+ if (context.query) {
170
+ const propertyId = context.propertyValue.markedProperty
171
+ const object = context.object
172
+ const value = context.propertyValue
173
+ const pattern = {
174
+ marker: 'propertyRelation',
175
+ object,
176
+ property: { marker: propertyId, value: propertyId },
177
+ value,
178
+ }
179
+
180
+ const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
181
+
182
+ relations.forEach((r) => {
183
+ r.objectPropertyValueStyle = {
184
+ template: "object is isPropertyValue",
185
+ mapping: {
186
+ object: 'object',
187
+ isPropertyValue: 'value',
188
+ }
189
+ }
190
+ })
154
191
 
155
- const instance = await fragments("the property of object is value", { property: propertyType, object: context.object, value: context.propertyValue })
156
- await e(instance)
192
+ resolveEvaluate(context, relations)
193
+ } else {
194
+ const propertyType = {
195
+ marker: context.propertyValue.propertyType,
196
+ level: 0,
197
+ word: context.propertyValue.propertyType,
198
+ value: context.propertyValue.propertyType,
199
+ }
200
+ for (const object of toArray(context.object)) {
201
+ const instance = await fragments("the property of object is value", { property: propertyType, object, value: context.propertyValue })
202
+ const text = await gp(instance)
203
+ instance.query = context.query
204
+ await e(instance, where())
205
+ }
206
+ }
157
207
  }
158
208
  },
159
209
 
160
210
  {
211
+ where: where(),
161
212
  id: 'propertyRelation',
162
213
  // scope: 'development',
163
214
  words: words('propertyRelation'),
164
- evaluator: ({context, api, objects, toList}) => {
215
+ semantic: ({context, api, objects, toList}) => {
165
216
  context.evalue = toList(objects.relations)
166
217
  context.evalue.isResponse = true
167
218
  context.evalue.paraphrase = false
168
219
  }
169
220
  },
170
221
  {
222
+ where: where(),
171
223
  id: 'propertyMarker',
172
224
  },
173
225
  {
226
+ where: where(),
174
227
  id: 'xfx',
175
228
  isA: ['queryable'],
176
229
  },
177
230
  {
231
+ where: where(),
178
232
  id: 'between',
179
233
  isA: ['preposition'],
180
234
  enhanced_associations: false,
181
235
  bridge: "{ ...next(operator), arguments: after[0] }"
182
236
  },
183
- { id: 'between', level: 1, bridge: "{ ...before[0], arguments: operator.arguments }" },
237
+ {
238
+ where: where(),
239
+ id: 'between', level: 1, bridge: "{ ...before[0], arguments: operator.arguments }" },
184
240
 
185
241
  {
186
242
  id: 'hierarchyAble',
@@ -209,14 +265,6 @@ const config = {
209
265
  localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
210
266
  bridge: "{ ...next(operator) }"
211
267
  },
212
- /*
213
- {
214
- id: "property",
215
- words: ['properties'],
216
- isA: ['queryable', 'theAble'],
217
- level: 0,
218
- },
219
- */
220
268
  {
221
269
  id: "object",
222
270
  isA: ['queryable', 'theAble', 'listable'],
@@ -317,6 +365,137 @@ const config = {
317
365
  { "context": [['what', 0], ['is', 0], ['objectPrefix', 0], ], "choose": [0] },
318
366
  ],
319
367
  generators: [
368
+ {
369
+ where: where(),
370
+ match: ({context, hierarchy}) => context.objectPropertyValueStyle,
371
+ apply: async ({context, fragments, gp}) => {
372
+ const mapping = {}
373
+ for (const key of Object.keys(context.objectPropertyValueStyle.mapping)) {
374
+ mapping[key] = context[context.objectPropertyValueStyle.mapping[key]]
375
+ }
376
+ const fragment = await fragments(context.objectPropertyValueStyle.template, mapping)
377
+ return await gp(fragment)
378
+ }
379
+ },
380
+ {
381
+ where: where(),
382
+ // match: ({context}) => context.marker == 'propertyRelation' && !context.paraphrase,
383
+ // paraphrase: evaluate propertyrelation
384
+ // response: 23 years old of bob is 23 years old
385
+ match: ({context}) => context.marker == 'propertyRelation',
386
+ // paraphrase: evaluate object's property
387
+ // response: bob's age is 23 years old
388
+ match: ({context}) => context.marker == 'propertyRelation' && context.isResponse,
389
+ apply: async ({context, gp, fragments}) => {
390
+ const instance = await fragments("the property of object", {
391
+ // property: { ...context.property, interpolate: undefined },
392
+ property: context.property,
393
+ object: context.object
394
+ }, ['interpolate'])
395
+ return await gp(instance)
396
+ }
397
+ },
398
+ {
399
+ notes: 'ordering generator for response',
400
+ match: ({context}) => (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0) && context.evalue && context.isResponse,
401
+ apply: async ({context, e, g, km, flatten}) => {
402
+ const brief = km("dialogues").api.getBrief()
403
+
404
+ let { evalue } = context
405
+ let yesno = ''
406
+ let hasVariables = false
407
+ if (context.focusable) {
408
+ for (const f of context.focusable) {
409
+ if (context[f].query) {
410
+ hasVariables = true
411
+ break
412
+ }
413
+ }
414
+ }
415
+
416
+ if (evalue.truthValueOnly || context.truthValueOnly || context.wantsTruthValue || !hasVariables) {
417
+ function any(value, test) {
418
+ if (test(value)) {
419
+ return true
420
+ }
421
+ const values = flatten(['list'], value)
422
+ for (const value of values) {
423
+ if (test(value)) {
424
+ return true
425
+ }
426
+ }
427
+ }
428
+ if (any(evalue, (value) => value.truthValue)) {
429
+ yesno = 'yes'
430
+ } else if (evalue.truthValue === false || context.truthValueOnly) {
431
+ yesno = 'no'
432
+ }
433
+ }
434
+ if (evalue.truthValueOnly) {
435
+ return `${yesno}`
436
+ } else {
437
+ if (context.voice) {
438
+ evalue = await e({ ...evalue, toVoice: context.voice, flatten: false}, where())
439
+ }
440
+
441
+ const details = await g(Object.assign({}, evalue, { paraphrase: true }))
442
+ if (yesno) {
443
+ return `${yesno} ${details}`
444
+ }
445
+ else {
446
+ return details
447
+ }
448
+ }
449
+ }
450
+ },
451
+
452
+ {
453
+ match: ({context}) => {
454
+ if (context.do && context.paraphrase) {
455
+ const left = context['do'].left
456
+ if (context[left]) {
457
+ // who owns X should not be 'does who own x' but instead 'who owns x'
458
+ if (context[left].query) {
459
+ return true;
460
+ }
461
+ }
462
+ }
463
+
464
+ return false;
465
+ },
466
+
467
+ apply: async ({context, g, gw}) => {
468
+ const chosen = await(gw({ number: context.number, word: context.word, isVerb: true}))
469
+ return `${await g(context[context.do.left])} ${chosen} ${await g(context[context.do.right])}`
470
+ }
471
+ },
472
+
473
+ {
474
+ match: ({context}) => context.isEd,
475
+ apply: async ({context, g}) => {
476
+ const chosen = chooseNumber(context[context.afterTag], 'is', 'are')
477
+ if (context[context.beforeTag].evalue && context[context.beforeTag].evalue.marker === 'undefined') {
478
+ return await g(context[context.beforeTag])
479
+ }
480
+ return `${await g(context[context.afterTag])} ${chosen} ${context.word} by ${await g(context[context.beforeTag])}`
481
+ }
482
+ },
483
+
484
+ {
485
+ notes: 'generator for constraint',
486
+ match: ({context}) => context.paraphrase && context.constrained,
487
+ apply: async ({callId, context, g}) => {
488
+ if (context[context.beforeTag].marker == 'by') {
489
+ // the cat wendy owned
490
+ return `${await g({...context[context.afterTag], paraphrase: true})} ${context.word} ${await g({...context[context.beforeTag], paraphrase: true})}`
491
+ } else {
492
+ // the cat owned by wendy
493
+ return `${await g({...context[context.afterTag], paraphrase: true})} ${context.word} ${['by', await g({...context[context.beforeTag], paraphrase: true})].filter((t) => t).join(' ')}`
494
+ }
495
+ },
496
+ },
497
+
498
+
320
499
  {
321
500
  notes: 'expression with constraints',
322
501
  where: where(),
@@ -333,11 +512,7 @@ const config = {
333
512
  const paraphrase = Object.assign({}, constraint.paraphrase)
334
513
  paraphrase.paraphrase = true;
335
514
  paraphrase[constraint.property] = property
336
- if (false && context.isResponse) {
337
- return await g({...constraint.paraphrase, paraphrase: true})
338
- } else {
339
- return await g(constrained)
340
- }
515
+ return await g(constrained)
341
516
  },
342
517
  },
343
518
  {
@@ -437,9 +612,8 @@ const config = {
437
612
  },
438
613
  },
439
614
  {
440
- // ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
441
615
  where: where(),
442
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && !context.evaluate && !context.object.marker == 'objectPrefix',
616
+ match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && context.paraphrase && !context.object.marker == 'objectPrefix',
443
617
  apply: async ({context, g}) => {
444
618
  const property = Object.assign({}, context, { object: undefined })
445
619
  return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
@@ -451,7 +625,7 @@ const config = {
451
625
  // match: ({context}) => context.paraphrase && !context.modifiers && context.object,
452
626
  match: ({context}) => !context.modifiers && (context.object || context.objects) && !context.interpolate,
453
627
  apply: async ({context, g, gs}) => {
454
- if (context.evalue) {
628
+ if (context.evalue && !context.paraphrase) {
455
629
  return await g(context.evalue)
456
630
  } else if (context.objects) {
457
631
  const objects = [ ...context.objects ]
@@ -477,12 +651,237 @@ const config = {
477
651
  },
478
652
  ],
479
653
  semantics: [
654
+ {
655
+ notes: 'unify for properties -> the age of who',
656
+ where: where(),
657
+ match: ({context, isA}) =>
658
+ context.marker == 'unify' &&
659
+ context.terms?.some((term) => {
660
+ return term.objects && isA(term.objects[0], 'property') && term.query
661
+ }),
662
+ apply: async (args) => {
663
+ const {context, km, callId, api, resolveEvaluate} = args
664
+ let value, property, object
665
+ if (context.terms[0].query) {
666
+ property = context.terms[0].objects[0]
667
+ object = context.terms[0].objects[1]
668
+ value = context.terms[1]
669
+ } else {
670
+ property = context.terms[1].objects[0]
671
+ object = context.terms[1].objects[1]
672
+ value = context.terms[0]
673
+ }
674
+ const pattern = {
675
+ marker: 'propertyRelation',
676
+ object,
677
+ property,
678
+ value,
679
+ }
680
+ const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
681
+
682
+ relations.forEach((r) => {
683
+ r.objectPropertyValueStyle = {
684
+ template: "the property of object",
685
+ mapping: {
686
+ object: 'object',
687
+ property: 'property',
688
+ }
689
+ }
690
+ })
691
+
692
+ resolveEvaluate(context, relations)
693
+ }
694
+ },
695
+ {
696
+ notes: 'unify for properties -> whose age',
697
+ where: where(),
698
+ match: ({context, isA}) => {
699
+ return context.marker == 'unify' && context.terms[0].whose && context.terms[1].markedProperty == context.terms[0].value
700
+ },
701
+ apply: async (args) => {
702
+ const {context, km, callId, api, fragments, resolveEvaluate} = args
703
+ let value, property, object
704
+ if (context.terms[0].query) {
705
+ property = { ...context.terms[0] },
706
+ object = { marker: 'who', value: 'who' }
707
+ value = context.terms[1]
708
+ } else {
709
+ property = { ...context.terms[1] }
710
+ object = { marker: 'who', value: 'who' }
711
+ value = context.terms[0]
712
+ }
713
+ property = await fragments("the property", { property }, ['interpolate'])
714
+
715
+ const pattern = {
716
+ marker: 'propertyRelation',
717
+ object,
718
+ property,
719
+ value,
720
+ }
721
+
722
+ const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
723
+ relations.forEach((r) => {
724
+ r.objectPropertyValueStyle = {
725
+ template: "object's property",
726
+ mapping: {
727
+ object: 'object',
728
+ property: 'property',
729
+ value: 'value',
730
+ }
731
+ }
732
+ r.property = { ...r.property, determiner: null }
733
+ })
734
+
735
+ const text = await args.gp(relations[0]) // 'the age is 23 years old'
736
+ resolveEvaluate(context, relations)
737
+ }
738
+ },
739
+ {
740
+ notes: 'getter for relation based verbs',
741
+ match: ({context}) => context.relationBacked && context.query,
742
+ apply: ({context, km, callId}) => {
743
+ const api = km('properties').api
744
+ context.evalue = {
745
+ marker: 'list',
746
+ listable: true,
747
+ value: unflatten(api.relation_get(context, context.relationArgs.map( (arg) => arg.tag ) ))
748
+ }
749
+ context.evalue.isResponse = true
750
+ context.isResponse = true
751
+ if (context.evalue.value.length == 0) {
752
+ context.evalue.marker = 'undefined';
753
+ context.evalue.listable = true
754
+ context.evalue.value = [];
755
+ } else {
756
+ // context.evalue.truthValue = true
757
+ }
758
+ }
759
+ },
760
+
761
+ {
762
+ notes: `setter for relation based verbs`,
763
+ match: ({context}) => context.relationBacked && !context.toVoice && context.isVerb,
764
+ apply: ({context, km, hierarchy, config}) => {
765
+ const api = km('properties').api
766
+ // add types for arguments
767
+ for (const argument of context.focusable || []) {
768
+ const value = api.toValue(context[argument])
769
+ if (value) {
770
+ const minimas = hierarchy.minima(context[argument].types)
771
+ for (const type of minimas) {
772
+ if (config.exists(value)) {
773
+ config.addHierarchy(value, type);
774
+ }
775
+ }
776
+ }
777
+ }
778
+ api.relation_add(context)
779
+ }
780
+ },
781
+ {
782
+ notes: 'ordering query',
783
+ match: ({context}) => context.query && (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0),
784
+ apply: ({context, km}) => {
785
+ const api = km('ordering').api
786
+ const propertiesAPI = km('properties').api
787
+ context.ordering = context.orderingArgs.name
788
+ const matches = propertiesAPI.relation_get(context, ['ordering', context.orderingArgs.object, context.orderingArgs.category])
789
+ if (matches.length > 0 || (typeof context.query == 'boolean' && context.query)) {
790
+ // does greg like bananas
791
+ if (matches.length == 0) {
792
+ const response = _.clone(context)
793
+ response.isResponse = true
794
+ response.query = undefined
795
+ context.evalue = { marker: 'list', listable: true, value: [response] }
796
+ } else {
797
+ context.evalue = { marker: 'list', listable: true, value: unflatten(matches) }
798
+ context.evalue.isResponse = true
799
+ }
800
+ context.evalue.truthValue = matches.length > 0
801
+ context.evalue.truth = { marker: 'yesno', value: matches.length > 0, isResponse: true, focus: true }
802
+ context.evalue.focusable = ['truth']
803
+ if (!context.evalue.truthValue) {
804
+ context.evalue.truthValueOnly = true
805
+ }
806
+
807
+ // ADD this line back and remove it to check
808
+ // context.response = { marker: 'list', listable: true, value: [response], isResponse: true }
809
+ // Object.assign(context, { marker: 'list', listable: true, value: responses, focusable: ['value'], paraphrase: true, truthValue: matches.length > 0 })
810
+ } else {
811
+ // see if anything is preferred greg
812
+ // what does greg like
813
+ const matches = propertiesAPI.relation_get(context, ['ordering', context.orderingArgs.object])
814
+ if (matches.length == 0) {
815
+ // Object.assign(context, { marker: 'idontknow', query: _.clone(context) })
816
+ context.evalue = { marker: 'idontknow', query: _.clone(context), isResponse: true }
817
+ } else {
818
+ context.evalue = { marker: 'list', listable: true, value: matches, isResponse: true }
819
+ }
820
+ context.isResponse = true
821
+ context.evalue.truthValue = matches.length > 0 && matches[0].marker == context.orderingArgs.marker
822
+ }
823
+ }
824
+ },
825
+
826
+ {
827
+ notes: 'ordering setter',
828
+ // TODO use hierarchy for operator
829
+ // match: ({context}) => context.marker == operator,
830
+ match: ({context}) => (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0),
831
+ apply: ({context, km}) => {
832
+ const propertiesAPI = km('properties').api
833
+ context.ordering = context.orderingArgs.name
834
+ const fcontexts = flattens(['list'], [context])
835
+ for (const fcontext of fcontexts) {
836
+ fcontext.paraphrase = true
837
+ fcontext[context.orderingArgs.object].paraphrase = true
838
+ fcontext[context.orderingArgs.category].paraphrase = true
839
+ }
840
+ propertiesAPI.relation_add(fcontexts)
841
+ }
842
+ },
843
+ {
844
+ notes: 'semantic for setting value with constraint',
845
+ //match: ({context, isA}) => isA(context.marker, after[0].tag) && context.constraints,
846
+ match: ({context, isA}) => context.constraints,
847
+ apply: async ({km, context, e, log, isA}) => {
848
+ const constraint = context.constraints[0];
849
+ const value = constraint.constraint;
850
+ let property = constraint.property;
851
+ const properties = constraint.properties;
852
+ for (const p of properties) {
853
+ if (value[p].concept) {
854
+ property = p
855
+ // constraint.property = p; // set what is used
856
+ constraint.property = {...constraint.property, ...p}; // set what is used
857
+
858
+ }
859
+ }
860
+ // value.marker = 'owns'
861
+ // value.greg = true
862
+ // value.ownee.query = true
863
+ value.query = true
864
+ value.greg99 = 23
865
+ const instance = await e(value, where())
866
+ if (instance.verbatim) {
867
+ context.evalue = { verbatim: instance.verbatim }
868
+ return
869
+ }
870
+ if (instance.evalue.marker === 'undefined') {
871
+ context.evalue = instance.evalue
872
+ return
873
+ }
874
+ const selected = instance.evalue.value.map( (r) => r[property] )
875
+ context.constraints = undefined;
876
+ context.evalue = { marker: 'list', listable: true, value: selected }
877
+ },
878
+ },
480
879
  {
481
880
  where: where(),
482
881
  notes: "how deep is the pool",
483
882
  priority: -1,
484
883
  match: ({context}) => context.marker == 'is' && (context.one.how || context.two.how),
485
- apply: async ({ resolveResponse, g, context, toArray, toList, fragments, kms, e, toEValue }) => {
884
+ apply: async ({ resolveEvaluate, g, context, toArray, toList, fragments, kms, e, toEValue }) => {
486
885
  const propertyMarkerContext = context.one
487
886
  let object = context.two
488
887
  if (context.two.how) {
@@ -496,20 +895,20 @@ const config = {
496
895
  properties.push({ marker: property, value: property, word: property })
497
896
  }
498
897
  const propertyOfObject = await fragments("the property of object", { property: toList(properties, true), object })
499
- const value = toEValue(await e(propertyOfObject))
898
+ const value = toEValue(await e(propertyOfObject, where()))
500
899
  value.focusableForPhrase = true
501
900
  propertyOfObject.focusableForPhrase = false
502
901
  const response = await fragments("the property is value", { property: propertyOfObject, value })
503
902
  response.isResponse = true
504
- resolveResponse(context, response)
903
+ resolveEvaluate(context, response)
505
904
  }
506
905
  },
507
906
  {
508
907
  where: where(),
509
- match: ({context}) => context.marker == 'concept' && context.same,
908
+ match: ({context}) => context.marker == 'same' && context.one.marker == 'concept',
510
909
  apply: async (args) => {
511
910
  const {context} = args
512
- await args.makeObject({ ...args, context: context.same })
911
+ await args.makeObject({ ...args, context: context.two})
513
912
  context.sameWasProcessed = true
514
913
  }
515
914
  },
@@ -517,13 +916,14 @@ const config = {
517
916
  // TODO maybe use the dialogue management to get params
518
917
  notes: 'wants is xfx between wanter and wantee',
519
918
  where: where(),
520
- match: ({context}) => context.same && context.same.marker == 'xfx',
919
+ match: ({context}) => context.marker == 'same' && context.two.marker == 'xfx',
521
920
  // debug: 'call3',
522
921
  apply: ({context, km, config}) => {
523
922
  const papi = km('properties').api
524
- const singular = pluralize.singular(context.word)
525
- const plural = pluralize.plural(context.word)
526
- const args = context.same.arguments.value;
923
+ const { one, two } = context
924
+ const singular = pluralize.singular(one.word)
925
+ const plural = pluralize.plural(one.word)
926
+ const args = two.arguments.value;
527
927
  papi.createBinaryRelation(config, singular, [singular, plural], args[0].word, args[1].word)
528
928
  },
529
929
  priority: -1,
@@ -531,9 +931,9 @@ const config = {
531
931
  {
532
932
  notes: 'marking something as readonly',
533
933
  where: where(),
534
- match: ({context}) => context.same && context.same.marker == 'readonly',
934
+ match: ({context}) => context.marker == 'same' && context.two.marker == 'readonly',
535
935
  apply: ({context, km, objects}) => {
536
- km('properties').api.setReadOnly([context.value])
936
+ km('properties').api.setReadOnly([context.one.value])
537
937
  context.sameWasProcessed = true
538
938
  }
539
939
  },
@@ -556,19 +956,15 @@ const config = {
556
956
  notes: 'crew members. evaluate a concepts to get instances',
557
957
  where: where(),
558
958
  match: ({context, hierarchy, api, isA}) =>
559
- // (hierarchy.isA(context.marker, 'concept') && !hierarchy.isA(context.marker, 'property')) &&
560
- // concept unless its a property then use the property handler unless its a dimension "unit of dimension" acts like hierarchy
561
- // hierarchy.isA(context.marker, 'concept') && ((!context.propertyOf && !context.isProperty) || isA(context.object, 'dimension')) &&
562
959
  hierarchy.isA(context.marker, 'concept') && ((!context.propertyOf && !context.isProperty) || isA(context.objects[context.objects.length-1], 'dimension')) &&
563
960
  (!context.pullFromContext || context.number == 'many') &&
564
- context.evaluate &&
961
+ (context.pullFromContext || isA(context, 'type') || context.metaDefinition) &&
565
962
  !(context.types || []).includes('property') &&
566
963
  // !context.value && // greghere
567
964
  !context.ordinal &&
568
- (!context.objects || context.objects.length !== 2 || !context.objects[1].instance) &&
569
- (api.objects && api.objects.children && api.objects.children[context.marker]) &&
570
- !context.evaluate.toConcept,
571
- apply: ({context, hierarchy, objects, api, km}) => {
965
+ (!context.objects || context.objects.length !== 2 || !context.objects[1].isInstance) &&
966
+ (api.objects && api.objects.children && api.objects.children[context.marker]),
967
+ apply: ({context, isA, contextHierarchy, hierarchy, objects, api, km}) => {
572
968
  const values = api.objects.children[context.marker]
573
969
  const phrases = values.map( (value) => km('concept').api.getWordForValue(value) )
574
970
  // context.focusableForPhrase = true
@@ -586,11 +982,18 @@ const config = {
586
982
  where: where(),
587
983
  match: ({context}) => context.marker == 'have' && !context.query,
588
984
  apply: ({context, objects, api}) => {
985
+ if (context.object.unknown) {
986
+ context.object.value = pluralize.singular(context.object.value)
987
+ }
988
+ if (context.property.unknown) {
989
+ context.property.value = pluralize.singular(context.property.value)
990
+ }
589
991
  if (context.negation) {
590
- api.setProperty(pluralize.singular(context.object.value), pluralize.singular(context.property.value), null, false)
992
+ api.setProperty(context.object, context.property, null, false)
591
993
  } else {
592
- api.setProperty(pluralize.singular(context.object.value), pluralize.singular(context.property.value), null, true)
994
+ api.setProperty(context.object, context.property, null, true)
593
995
  }
996
+ // TODO delete this?
594
997
  context.sameWasProcessed = true
595
998
  }
596
999
  },
@@ -598,12 +1001,13 @@ const config = {
598
1001
  notes: 'greg has eyes?',
599
1002
  where: where(),
600
1003
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
601
- apply: async ({context, g, api, objects}) => {
1004
+ apply: async ({error, context, g, api, objects}) => {
602
1005
  const object = pluralize.singular(context.object.value);
603
1006
  const property = pluralize.singular(context.property.value);
604
1007
  context.isResponse = true
605
1008
  if (!await api.knownObject(object)) {
606
- context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
1009
+ // context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
1010
+ error(`there is no object named ${await g({...context.object, paraphrase: true})}`)
607
1011
  return
608
1012
  }
609
1013
  if (!await api.hasProperty(object, property)) {
@@ -623,26 +1027,31 @@ const config = {
623
1027
  {
624
1028
  notes: 'set the property of an object',
625
1029
  where: where(),
626
- // match: ({context}) => context.marker == 'property' && context.same && context.object,
627
- match: ({context, hierarchy, uuid}) => hierarchy.isA(context.marker, 'property') && context.same && context.objects && !context[`disable${uuid}`],
1030
+ match: async (args) => await args.callOnce(args, 'properties.1', ({context, hierarchy, uuid}) =>
1031
+ context.marker == 'same' &&
1032
+ hierarchy.isA(context.one.marker, 'property') &&
1033
+ context.one.objects),
628
1034
  apply: async (args) => {
629
1035
  const {context, fragments, objects, km, api, log, s, uuid} = args
630
- const objectContext = context.objects[context.objects.length-1];
631
- const propertyContext = context;
632
- const objectId = objectContext.unknown ? pluralize.singular(objectContext.value) : objectContext.value
1036
+ const objectContext = context.one.objects[context.one.objects.length-1];
1037
+ const propertyContext = context.one.objects[0];
1038
+ // const propertyContext = context.one;
1039
+ if (objectContext.unknown) {
1040
+ objectContext.value = pluralize.singular(objectContext.value)
1041
+ }
1042
+ const objectId = objectContext.value
633
1043
 
634
1044
  await api.makeObject({ ...args, context: objectContext })
635
1045
  await api.makeObject({ ...args, context: propertyContext })
636
- propertyContext[`disable${uuid}`] = true
637
- const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
1046
+ const propertyId = propertyContext.value
638
1047
  try {
639
- api.setProperty(objectId, propertyId, context.same, true)
1048
+ api.setProperty(objectContext, propertyContext, context.two, true)
640
1049
  context.sameWasProcessed = true
641
1050
  } catch (e) {
642
1051
  log(`Error processing set property of an object: ${e}`)
643
1052
  const config = km('properties')
644
1053
  const value = await api.getProperty(objectId, propertyId)
645
- if (value?.value == context.same?.value) {
1054
+ if (value?.value == context.two?.value) {
646
1055
  context.evalue = [
647
1056
  { marker: 'yesno', value: true, paraphrase: true },
648
1057
  ]
@@ -670,10 +1079,9 @@ const config = {
670
1079
  notes: 'get/evaluate a property',
671
1080
  where: where(),
672
1081
  match: ({context, hierarchy, toArray}) => {
673
- return (toArray(context).every((value) => hierarchy.isA(value.marker, 'property')) || (hierarchy.isA(context.marker, 'list') && context.possession)) && context.evaluate && context.objects && !context.evaluate.toConcept
1082
+ return (toArray(context).every((value) => hierarchy.isA(value.marker, 'property')) || (hierarchy.isA(context.marker, 'list') && context.possession)) && context.objects
674
1083
  },
675
- // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
676
- apply: async ({debug, isA, hierarchy, getWordFromDictionary, flatten, asList, context, api, kms, objects, g, s, log, recall}) => {
1084
+ apply: async ({stack, error, debug, isA, hierarchy, getWordFromDictionary, flatten, asList, context, api, kms, objects, g, gp, s, log, recall}) => {
677
1085
  async function toValue(objectContext) {
678
1086
  if (!objectContext.value) {
679
1087
  return objectContext;
@@ -707,7 +1115,9 @@ const config = {
707
1115
 
708
1116
  const propertyPhrase = await g({...nextContext, paraphrase: true})
709
1117
  const objectPhrase = await g({...currentContext, paraphrase: true})
710
- context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
1118
+ // context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
1119
+ error(`There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`)
1120
+
711
1121
  return
712
1122
  }
713
1123
 
@@ -725,7 +1135,13 @@ const config = {
725
1135
  fromMentions = await recall({ context: nextContext, all: nextContext.number == 'many', frameOfReference: currentContext })
726
1136
  }
727
1137
  if (!fromMentions) {
728
- context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
1138
+ if (!currentValue && currentContext.unknown) {
1139
+ // context.verbatim = `What "${await gp(currentContext)}" means is unknown`
1140
+ context.verbatim = `What "${await gp(currentContext)}" means is unknown`
1141
+ } else {
1142
+ // context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
1143
+ error(`There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`)
1144
+ }
729
1145
  return
730
1146
  }
731
1147
  }
@@ -733,7 +1149,7 @@ const config = {
733
1149
  currentContext = fromMentions
734
1150
  currentValue = fromMentions // TODO not sure what is right here so just do something and fix when actually needed SOP
735
1151
  } else {
736
- currentContext = await api.getProperty(currentValue, nextValue, g)
1152
+ currentContext = await api.getProperty(currentValue, nextValue)
737
1153
  currentValue = currentContext.value
738
1154
  }
739
1155
  }
@@ -756,7 +1172,7 @@ const config = {
756
1172
  context.evalue = asList(results, true)
757
1173
  context.object = undefined;
758
1174
  } else {
759
- context.evalue = { marker: 'answerNotKnown' }
1175
+ context.evalue = { marker: 'undefined' }
760
1176
  context.object = undefined;
761
1177
  }
762
1178
  }
@@ -772,12 +1188,6 @@ function initializer({objects, config, isModule}) {
772
1188
  }
773
1189
 
774
1190
  const template = {
775
- fragments: [
776
- "the property1 of object1 is value1",
777
- "the property of object is value",
778
- "the property of object",
779
- "the property is value",
780
- ],
781
1191
  configs: [
782
1192
  "property is a concept",
783
1193
  { query: "concept is a property", isFragment: true },
@@ -795,6 +1205,14 @@ const template = {
795
1205
  },
796
1206
  ],
797
1207
  },
1208
+ { query: "the property1 of object1 is value1", isFragment: true },
1209
+ { query: "the property of object is value", isFragment: true },
1210
+ { query: "the property of object", isFragment: true, preserve: ['interpolate'] },
1211
+ { query: "the property is value", isFragment: true },
1212
+ { query: "object's property", isFragment: true, preserve: ['interpolate'] },
1213
+ { query: "object's property is value", isFragment: true, preserve: ['one.interpolate'] },
1214
+ { query: "object is isPropertyValue", isFragment: true }, // bob is 23 years old
1215
+ { query: "the property", isFragment: true },
798
1216
  ],
799
1217
  }
800
1218