ekms 9.8.0 → 9.9.0-beta.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.
- package/common/actions.instance.json +12 -10
- package/common/actions.js +14 -12
- package/common/angle.instance.json +37 -17
- package/common/animals.instance.json +54 -28
- package/common/askfor.instance.json +89 -192
- package/common/askfor.js +49 -12
- package/common/asking.js +13 -5
- package/common/avatar.js +3 -3
- package/common/can.instance.json +32 -20
- package/common/can.js +2 -2
- package/common/colors.instance.json +44 -16
- package/common/colors.js +1 -1
- package/common/comparable.instance.json +25 -22
- package/common/compass.instance.json +9 -3
- package/common/compass.js +1 -1
- package/common/concept.instance.json +14 -6
- package/common/concept.js +2 -0
- package/common/conjunction.js +20 -12
- package/common/control.js +10 -18
- package/common/countable.js +4 -3
- package/common/crew.instance.json +95 -27
- package/common/dateTimeSelectors.instance.json +4 -4
- package/common/dateTimeSelectors.js +4 -7
- package/common/dates.instance.json +52 -28
- package/common/dates.js +16 -11
- package/common/debug.instance.json +52 -0
- package/common/debug.js +52 -0
- package/common/debug.test.json +1 -0
- package/common/dialogues.js +126 -70
- package/common/dimension.instance.json +259 -492
- package/common/dimension.js +72 -12
- package/common/drone.instance.json +441 -84
- package/common/drone.js +57 -56
- package/common/drone_v1.instance.json +36 -12
- package/common/drone_v1.js +20 -15
- package/common/edible.instance.json +96 -32
- package/common/emotions.instance.json +15 -1
- package/common/evaluate.js +10 -13
- package/common/fastfood.instance.json +282 -100
- package/common/fastfood.js +30 -15
- package/common/formulas.instance.json +162 -24
- package/common/formulas.js +18 -9
- package/common/gdefaults.js +20 -96
- package/common/helpers/concept.js +2 -9
- package/common/helpers/conjunction.js +11 -1
- package/common/helpers/dialogues.js +48 -24
- package/common/helpers/gdefaults.js +15 -5
- package/common/helpers/properties.js +132 -326
- package/common/helpers.js +28 -58
- package/common/hierarchy.js +71 -41
- package/common/kirk.instance.json +3 -1
- package/common/latin.instance.json +14 -14
- package/common/latin.js +7 -7
- package/common/length.instance.json +331 -61
- package/common/linear_orderings.instance.json +1 -0
- package/common/linear_orderings.js +90 -0
- package/common/linear_orderings.test.json +1 -0
- package/common/math.instance.json +144 -5
- package/common/math.js +18 -7
- package/common/menus.instance.json +29 -11
- package/common/menus.js +8 -5
- package/common/meta.js +14 -13
- package/common/nameable.js +9 -5
- package/common/numbers.instance.json +8 -3
- package/common/numbers.js +59 -35
- package/common/ordering.instance.json +53 -4
- package/common/ordinals.js +25 -25
- package/common/people.instance.json +66 -12
- package/common/percentages.js +4 -2
- package/common/pipboy.instance.json +89 -44
- package/common/pipboy.js +21 -14
- package/common/pokemon.instance.json +39 -13
- package/common/pressure.instance.json +20 -6
- package/common/properties.instance.json +2648 -501
- package/common/properties.js +561 -82
- package/common/punctuation.js +1 -0
- package/common/rates.instance.json +2 -2
- package/common/rates.js +3 -3
- package/common/reminders.instance.json +16 -0
- package/common/reminders.js +24 -20
- package/common/reports.instance.json +11 -12
- package/common/reports.js +12 -12
- package/common/scorekeeper.js +20 -10
- package/common/sdefaults.js +30 -9
- package/common/spock.instance.json +3 -1
- package/common/stm.js +16 -21
- package/common/temperature.instance.json +40 -11
- package/common/testing.js +2 -2
- package/common/time.instance.json +149 -47
- package/common/time.js +9 -8
- package/common/ui.instance.json +4 -2
- package/common/ui.js +5 -5
- package/common/weight.instance.json +113 -21
- package/common/weight.js +5 -1
- package/common/words.js +113 -2
- package/common/wp.instance.json +125 -18
- package/common/wp.js +6 -2
- package/main.js +2 -0
- package/package.json +10 -3
package/common/properties.js
CHANGED
|
@@ -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'] })
|
|
61
|
+
// args({ types: ['myObjectType'], properties: ['object'] }),
|
|
61
62
|
// ({objects, context}) => {
|
|
62
63
|
// context.value = "value" // set the value here somehow
|
|
63
64
|
// }
|
|
@@ -83,19 +84,30 @@ function addPropertyMarker(args) {
|
|
|
83
84
|
markerWords = [markerWords]
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
const { fragments,
|
|
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
|
|
89
|
+
await e(instance, where())
|
|
89
90
|
const propertyMarker = `${property}Marker`
|
|
90
|
-
config.addOperator(`((@<=
|
|
91
|
+
config.addOperator(`(((@<= quantity && context.unit.dimension == ${dimension}) || (context.from @<= quantity && context.from.unit.dimension == ${dimension})) [${propertyMarker}|])`)
|
|
91
92
|
config.addBridge({
|
|
92
93
|
id: propertyMarker,
|
|
93
94
|
words: markerWords,
|
|
94
|
-
isA: ['adjective', 'propertyMarker', 'queryable'],
|
|
95
|
+
isA: ['adjective', 'propertyMarker', 'queryable', 'linearlyOrdered'],
|
|
95
96
|
enhanced_associations: true,
|
|
96
97
|
initial: { markedProperty: property },
|
|
97
|
-
check: defaultContextCheckProperties(['markedProperty']),
|
|
98
|
-
bridge: `{
|
|
98
|
+
check: defaultContextCheckProperties(['markedProperty', 'quantity']),
|
|
99
|
+
bridge: `{
|
|
100
|
+
...next(operator),
|
|
101
|
+
quantity: before[0],
|
|
102
|
+
notConjunctableWith: ['quantity'],
|
|
103
|
+
checks: append(before.checks, ['repeats']),
|
|
104
|
+
floaters: ['isPropertyValue'],
|
|
105
|
+
rangeableWith: ['${propertyMarker}'],
|
|
106
|
+
propertyType: '${property}',
|
|
107
|
+
isPropertyValue: true,
|
|
108
|
+
${property}: operator,
|
|
109
|
+
interpolate: append(map(before[0].interpolate, { inside: 'quantity', value: element }), [{ property: '${property}' }])
|
|
110
|
+
}`,
|
|
99
111
|
})
|
|
100
112
|
}
|
|
101
113
|
}
|
|
@@ -127,60 +139,137 @@ const config = {
|
|
|
127
139
|
// the plural of cat is cats what is the plural of cat?
|
|
128
140
|
// does greg have ears (yes) greg does not have ears does greg have ears (no)
|
|
129
141
|
// TODO fix @=unknown does not work?!??
|
|
130
|
-
"(
|
|
142
|
+
"([isPropertyValue])",
|
|
143
|
+
"((@<= object || @<=unknown) [hasPropertyValue|is,are] (context.isPropertyValue == true))",
|
|
131
144
|
],
|
|
132
145
|
// TODO remove these and use localHierarchy if needed
|
|
133
146
|
hierarchy: [
|
|
134
147
|
['unknown', 'hierarchyAble'],
|
|
135
148
|
['what', 'object'],
|
|
149
|
+
['who', 'object'],
|
|
136
150
|
],
|
|
137
151
|
bridges: [
|
|
138
152
|
{
|
|
153
|
+
where: where(),
|
|
139
154
|
id: 'howPropertyMarker',
|
|
140
155
|
bridge: "{ ...after[0], query: ['what'], how: operator, operator: after[0], interpolate: [ { property: 'how' }, { property: 'operator' } ] }",
|
|
141
156
|
},
|
|
142
157
|
{
|
|
158
|
+
where: where(),
|
|
159
|
+
id: 'isPropertyValue',
|
|
160
|
+
initial: { isPropertyValue: true },
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
where: where(),
|
|
143
164
|
id: 'hasPropertyValue',
|
|
144
165
|
isA: ['verb'],
|
|
145
166
|
preferOver: ['is'],
|
|
146
167
|
enhanced_associations: true,
|
|
147
|
-
bridge: "{ ...operator, object: before[0], flatten: true, operator: operator, propertyValue: after[0], interpolate: [{ property: 'object' }, { property: 'operator' }, { property: 'propertyValue' }] }",
|
|
148
|
-
semantic:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
bridge: "{ ...next(operator), object: before[0], flatten: true, operator: operator, propertyValue: after[0], interpolate: [{ property: 'object' }, { property: 'operator' }, { property: 'propertyValue' }] }",
|
|
169
|
+
semantic: {
|
|
170
|
+
match: ({context}) => context.level > 0,
|
|
171
|
+
apply: async ({gp, context, api, callId, e, debug, toArray, fragments, resolveEvaluate, getWordFromDictionary, isA}) => {
|
|
172
|
+
// TODO is there some way to make lookup up and setting the value into the same operation?
|
|
173
|
+
if (context.query) {
|
|
174
|
+
const object = context.object
|
|
175
|
+
let pattern, value
|
|
176
|
+
if (isA(context.propertyValue, 'linearOrderedRange') && context.propertyValue.isPropertyValue) {
|
|
177
|
+
const lor = { ...context.propertyValue }
|
|
178
|
+
lor.from = lor.from.quantity
|
|
179
|
+
lor.to = lor.to.quantity
|
|
180
|
+
value = lor
|
|
181
|
+
const propertyId = context.propertyValue.from[context.propertyValue.from.propertyType].markedProperty
|
|
182
|
+
pattern = {
|
|
183
|
+
marker: 'propertyRelation',
|
|
184
|
+
object,
|
|
185
|
+
property: { marker: propertyId, value: propertyId },
|
|
186
|
+
value,
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
value = context.propertyValue
|
|
190
|
+
const propertyId = context.propertyValue.markedProperty
|
|
191
|
+
pattern = {
|
|
192
|
+
marker: 'propertyRelation',
|
|
193
|
+
object,
|
|
194
|
+
property: { marker: propertyId, value: propertyId },
|
|
195
|
+
value,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
154
198
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
199
|
+
const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
|
|
200
|
+
|
|
201
|
+
if (relations.length == 0) {
|
|
202
|
+
const r = {
|
|
203
|
+
objectPropertyValueStyle: {
|
|
204
|
+
template: "nobody is isPropertyValue",
|
|
205
|
+
mapping: {
|
|
206
|
+
isPropertyValue: 'value',
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
value,
|
|
210
|
+
}
|
|
211
|
+
relations.push(r)
|
|
212
|
+
} else {
|
|
213
|
+
relations.forEach((r) => {
|
|
214
|
+
r.objectPropertyValueStyle = {
|
|
215
|
+
template: "object is isPropertyValue",
|
|
216
|
+
mapping: {
|
|
217
|
+
object: 'object',
|
|
218
|
+
isPropertyValue: 'value',
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
resolveEvaluate(context, relations)
|
|
225
|
+
} else {
|
|
226
|
+
const propertyType = {
|
|
227
|
+
marker: context.propertyValue.propertyType,
|
|
228
|
+
level: 0,
|
|
229
|
+
word: context.propertyValue.propertyType,
|
|
230
|
+
value: context.propertyValue.propertyType,
|
|
231
|
+
}
|
|
232
|
+
for (const object of toArray(context.object)) {
|
|
233
|
+
const instance = await fragments("the property of object is value", { property: propertyType, object, value: context.propertyValue })
|
|
234
|
+
const text = await gp(instance)
|
|
235
|
+
instance.query = context.query
|
|
236
|
+
await e(instance, where())
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
158
241
|
},
|
|
159
242
|
|
|
160
243
|
{
|
|
244
|
+
where: where(),
|
|
161
245
|
id: 'propertyRelation',
|
|
162
246
|
// scope: 'development',
|
|
163
247
|
words: words('propertyRelation'),
|
|
164
|
-
|
|
248
|
+
semantic: ({context, api, objects, toList}) => {
|
|
165
249
|
context.evalue = toList(objects.relations)
|
|
166
250
|
context.evalue.isResponse = true
|
|
167
251
|
context.evalue.paraphrase = false
|
|
168
252
|
}
|
|
169
253
|
},
|
|
170
254
|
{
|
|
255
|
+
where: where(),
|
|
171
256
|
id: 'propertyMarker',
|
|
172
257
|
},
|
|
173
258
|
{
|
|
259
|
+
where: where(),
|
|
174
260
|
id: 'xfx',
|
|
175
261
|
isA: ['queryable'],
|
|
176
262
|
},
|
|
177
263
|
{
|
|
264
|
+
where: where(),
|
|
178
265
|
id: 'between',
|
|
179
266
|
isA: ['preposition'],
|
|
180
267
|
enhanced_associations: false,
|
|
181
268
|
bridge: "{ ...next(operator), arguments: after[0] }"
|
|
182
269
|
},
|
|
183
|
-
{
|
|
270
|
+
{
|
|
271
|
+
where: where(),
|
|
272
|
+
id: 'between', level: 1, bridge: "{ ...before[0], arguments: operator.arguments }" },
|
|
184
273
|
|
|
185
274
|
{
|
|
186
275
|
id: 'hierarchyAble',
|
|
@@ -209,14 +298,6 @@ const config = {
|
|
|
209
298
|
localHierarchy: [['property', 'queryable'], ['property', 'theAble'], ['property', 'unknown']],
|
|
210
299
|
bridge: "{ ...next(operator) }"
|
|
211
300
|
},
|
|
212
|
-
/*
|
|
213
|
-
{
|
|
214
|
-
id: "property",
|
|
215
|
-
words: ['properties'],
|
|
216
|
-
isA: ['queryable', 'theAble'],
|
|
217
|
-
level: 0,
|
|
218
|
-
},
|
|
219
|
-
*/
|
|
220
301
|
{
|
|
221
302
|
id: "object",
|
|
222
303
|
isA: ['queryable', 'theAble', 'listable'],
|
|
@@ -317,6 +398,137 @@ const config = {
|
|
|
317
398
|
{ "context": [['what', 0], ['is', 0], ['objectPrefix', 0], ], "choose": [0] },
|
|
318
399
|
],
|
|
319
400
|
generators: [
|
|
401
|
+
{
|
|
402
|
+
where: where(),
|
|
403
|
+
match: ({context, hierarchy}) => context.objectPropertyValueStyle,
|
|
404
|
+
apply: async ({context, fragments, gp}) => {
|
|
405
|
+
const mapping = {}
|
|
406
|
+
for (const key of Object.keys(context.objectPropertyValueStyle.mapping)) {
|
|
407
|
+
mapping[key] = context[context.objectPropertyValueStyle.mapping[key]]
|
|
408
|
+
}
|
|
409
|
+
const fragment = await fragments(context.objectPropertyValueStyle.template, mapping)
|
|
410
|
+
return await gp(fragment)
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
where: where(),
|
|
415
|
+
// match: ({context}) => context.marker == 'propertyRelation' && !context.paraphrase,
|
|
416
|
+
// paraphrase: evaluate propertyrelation
|
|
417
|
+
// response: 23 years old of bob is 23 years old
|
|
418
|
+
match: ({context}) => context.marker == 'propertyRelation',
|
|
419
|
+
// paraphrase: evaluate object's property
|
|
420
|
+
// response: bob's age is 23 years old
|
|
421
|
+
match: ({context}) => context.marker == 'propertyRelation' && context.isResponse,
|
|
422
|
+
apply: async ({context, gp, fragments}) => {
|
|
423
|
+
const instance = await fragments("the property of object", {
|
|
424
|
+
// property: { ...context.property, interpolate: undefined },
|
|
425
|
+
property: context.property,
|
|
426
|
+
object: context.object
|
|
427
|
+
}, ['interpolate'])
|
|
428
|
+
return await gp(instance)
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
notes: 'ordering generator for response',
|
|
433
|
+
match: ({context}) => (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0) && context.evalue && context.isResponse,
|
|
434
|
+
apply: async ({context, e, g, km, flatten}) => {
|
|
435
|
+
const brief = km("dialogues").api.getBrief()
|
|
436
|
+
|
|
437
|
+
let { evalue } = context
|
|
438
|
+
let yesno = ''
|
|
439
|
+
let hasVariables = false
|
|
440
|
+
if (context.focusable) {
|
|
441
|
+
for (const f of context.focusable) {
|
|
442
|
+
if (context[f].query) {
|
|
443
|
+
hasVariables = true
|
|
444
|
+
break
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (evalue.truthValueOnly || context.truthValueOnly || context.wantsTruthValue || !hasVariables) {
|
|
450
|
+
function any(value, test) {
|
|
451
|
+
if (test(value)) {
|
|
452
|
+
return true
|
|
453
|
+
}
|
|
454
|
+
const values = flatten(['list'], value)
|
|
455
|
+
for (const value of values) {
|
|
456
|
+
if (test(value)) {
|
|
457
|
+
return true
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (any(evalue, (value) => value.truthValue)) {
|
|
462
|
+
yesno = 'yes'
|
|
463
|
+
} else if (evalue.truthValue === false || context.truthValueOnly) {
|
|
464
|
+
yesno = 'no'
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (evalue.truthValueOnly) {
|
|
468
|
+
return `${yesno}`
|
|
469
|
+
} else {
|
|
470
|
+
if (context.voice) {
|
|
471
|
+
evalue = await e({ ...evalue, toVoice: context.voice, flatten: false}, where())
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const details = await g(Object.assign({}, evalue, { paraphrase: true }))
|
|
475
|
+
if (yesno) {
|
|
476
|
+
return `${yesno} ${details}`
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
return details
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
{
|
|
486
|
+
match: ({context}) => {
|
|
487
|
+
if (context.do && context.paraphrase) {
|
|
488
|
+
const left = context['do'].left
|
|
489
|
+
if (context[left]) {
|
|
490
|
+
// who owns X should not be 'does who own x' but instead 'who owns x'
|
|
491
|
+
if (context[left].query) {
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return false;
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
apply: async ({context, g, gw}) => {
|
|
501
|
+
const chosen = await(gw({ number: context.number, word: context.word, isVerb: true}))
|
|
502
|
+
return `${await g(context[context.do.left])} ${chosen} ${await g(context[context.do.right])}`
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
{
|
|
507
|
+
match: ({context}) => context.isEd,
|
|
508
|
+
apply: async ({context, g}) => {
|
|
509
|
+
const chosen = chooseNumber(context[context.afterTag], 'is', 'are')
|
|
510
|
+
if (context[context.beforeTag].evalue && context[context.beforeTag].evalue.marker === 'undefined') {
|
|
511
|
+
return await g(context[context.beforeTag])
|
|
512
|
+
}
|
|
513
|
+
return `${await g(context[context.afterTag])} ${chosen} ${context.word} by ${await g(context[context.beforeTag])}`
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
|
|
517
|
+
{
|
|
518
|
+
notes: 'generator for constraint',
|
|
519
|
+
match: ({context}) => context.paraphrase && context.constrained,
|
|
520
|
+
apply: async ({callId, context, g}) => {
|
|
521
|
+
if (context[context.beforeTag].marker == 'by') {
|
|
522
|
+
// the cat wendy owned
|
|
523
|
+
return `${await g({...context[context.afterTag], paraphrase: true})} ${context.word} ${await g({...context[context.beforeTag], paraphrase: true})}`
|
|
524
|
+
} else {
|
|
525
|
+
// the cat owned by wendy
|
|
526
|
+
return `${await g({...context[context.afterTag], paraphrase: true})} ${context.word} ${['by', await g({...context[context.beforeTag], paraphrase: true})].filter((t) => t).join(' ')}`
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
|
|
531
|
+
|
|
320
532
|
{
|
|
321
533
|
notes: 'expression with constraints',
|
|
322
534
|
where: where(),
|
|
@@ -333,11 +545,7 @@ const config = {
|
|
|
333
545
|
const paraphrase = Object.assign({}, constraint.paraphrase)
|
|
334
546
|
paraphrase.paraphrase = true;
|
|
335
547
|
paraphrase[constraint.property] = property
|
|
336
|
-
|
|
337
|
-
return await g({...constraint.paraphrase, paraphrase: true})
|
|
338
|
-
} else {
|
|
339
|
-
return await g(constrained)
|
|
340
|
-
}
|
|
548
|
+
return await g(constrained)
|
|
341
549
|
},
|
|
342
550
|
},
|
|
343
551
|
{
|
|
@@ -437,9 +645,8 @@ const config = {
|
|
|
437
645
|
},
|
|
438
646
|
},
|
|
439
647
|
{
|
|
440
|
-
// ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
|
|
441
648
|
where: where(),
|
|
442
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession &&
|
|
649
|
+
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && context.paraphrase && !context.object.marker == 'objectPrefix',
|
|
443
650
|
apply: async ({context, g}) => {
|
|
444
651
|
const property = Object.assign({}, context, { object: undefined })
|
|
445
652
|
return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
|
|
@@ -451,7 +658,7 @@ const config = {
|
|
|
451
658
|
// match: ({context}) => context.paraphrase && !context.modifiers && context.object,
|
|
452
659
|
match: ({context}) => !context.modifiers && (context.object || context.objects) && !context.interpolate,
|
|
453
660
|
apply: async ({context, g, gs}) => {
|
|
454
|
-
if (context.evalue) {
|
|
661
|
+
if (context.evalue && !context.paraphrase) {
|
|
455
662
|
return await g(context.evalue)
|
|
456
663
|
} else if (context.objects) {
|
|
457
664
|
const objects = [ ...context.objects ]
|
|
@@ -477,12 +684,264 @@ const config = {
|
|
|
477
684
|
},
|
|
478
685
|
],
|
|
479
686
|
semantics: [
|
|
687
|
+
{
|
|
688
|
+
notes: 'unify for propertiesMarkers -> 23 years old is 22 to 50 years old',
|
|
689
|
+
where: where(),
|
|
690
|
+
match: ({context, isA, debug}) => {
|
|
691
|
+
return context.marker == 'unify' &&
|
|
692
|
+
context.terms[0].isPropertyValue &&
|
|
693
|
+
context.terms?.every((term) => term.marker == context.terms[0].marker)
|
|
694
|
+
},
|
|
695
|
+
apply: async ({ context, resolveEvaluate, unify }) => {
|
|
696
|
+
resolveEvaluate(context, await unify(...context.terms.map((term) => term.quantity)))
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
notes: 'unify for properties -> the age of who',
|
|
701
|
+
where: where(),
|
|
702
|
+
match: ({context, isA}) =>
|
|
703
|
+
context.marker == 'unify' &&
|
|
704
|
+
context.terms?.some((term) => {
|
|
705
|
+
return term.objects && isA(term.objects[0], 'property') && term.query
|
|
706
|
+
}),
|
|
707
|
+
apply: async (args) => {
|
|
708
|
+
const {context, km, callId, api, resolveEvaluate} = args
|
|
709
|
+
let value, property, object
|
|
710
|
+
if (context.terms[0].query) {
|
|
711
|
+
property = context.terms[0].objects[0]
|
|
712
|
+
object = context.terms[0].objects[1]
|
|
713
|
+
value = context.terms[1]
|
|
714
|
+
} else {
|
|
715
|
+
property = context.terms[1].objects[0]
|
|
716
|
+
object = context.terms[1].objects[1]
|
|
717
|
+
value = context.terms[0]
|
|
718
|
+
}
|
|
719
|
+
const pattern = {
|
|
720
|
+
marker: 'propertyRelation',
|
|
721
|
+
object,
|
|
722
|
+
property,
|
|
723
|
+
value,
|
|
724
|
+
}
|
|
725
|
+
const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
|
|
726
|
+
|
|
727
|
+
relations.forEach((r) => {
|
|
728
|
+
r.objectPropertyValueStyle = {
|
|
729
|
+
template: "the property of object",
|
|
730
|
+
mapping: {
|
|
731
|
+
object: 'object',
|
|
732
|
+
property: 'property',
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
resolveEvaluate(context, relations)
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
notes: 'unify for properties -> whose age',
|
|
742
|
+
where: where(),
|
|
743
|
+
match: ({context, isA}) => {
|
|
744
|
+
return context.marker == 'unify' && context.terms[0].whose && context.terms[1].markedProperty == context.terms[0].value
|
|
745
|
+
},
|
|
746
|
+
apply: async (args) => {
|
|
747
|
+
const {context, km, callId, api, fragments, resolveEvaluate} = args
|
|
748
|
+
let value, property, object
|
|
749
|
+
if (context.terms[0].query) {
|
|
750
|
+
property = { ...context.terms[0] },
|
|
751
|
+
object = { marker: 'who', value: 'who' }
|
|
752
|
+
value = context.terms[1]
|
|
753
|
+
} else {
|
|
754
|
+
property = { ...context.terms[1] }
|
|
755
|
+
object = { marker: 'who', value: 'who' }
|
|
756
|
+
value = context.terms[0]
|
|
757
|
+
}
|
|
758
|
+
property = await fragments("the property", { property }, ['interpolate'])
|
|
759
|
+
|
|
760
|
+
const pattern = {
|
|
761
|
+
marker: 'propertyRelation',
|
|
762
|
+
object,
|
|
763
|
+
property,
|
|
764
|
+
value,
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const relations = await api.relation_unify(pattern, ['object', 'property', 'value'])
|
|
768
|
+
relations.forEach((r) => {
|
|
769
|
+
r.objectPropertyValueStyle = {
|
|
770
|
+
template: "object's property",
|
|
771
|
+
mapping: {
|
|
772
|
+
object: 'object',
|
|
773
|
+
property: 'property',
|
|
774
|
+
value: 'value',
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
r.property = { ...r.property, determiner: null }
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
const text = await args.gp(relations[0]) // 'the age is 23 years old'
|
|
781
|
+
resolveEvaluate(context, relations)
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
notes: 'unify for propertiesMarker + property values',
|
|
786
|
+
where: where(),
|
|
787
|
+
match: ({context, isA, debug}) => context.marker == 'unify' && context.terms?.some((term) => term.isPropertyValue && term.quantity),
|
|
788
|
+
apply: async ({ context, resolveEvaluate, unify, callId }) => {
|
|
789
|
+
const toQuantity = (term) => {
|
|
790
|
+
// linearlyOrderedRanges dont have a quantity but can be for property values
|
|
791
|
+
if (term.isPropertyValue && term.quantity) {
|
|
792
|
+
return term.quantity
|
|
793
|
+
}
|
|
794
|
+
return term
|
|
795
|
+
}
|
|
796
|
+
resolveEvaluate(context, await unify(...context.terms.map(toQuantity)))
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
notes: 'getter for relation based verbs',
|
|
801
|
+
match: ({context}) => context.relationBacked && context.query,
|
|
802
|
+
apply: ({context, km, callId}) => {
|
|
803
|
+
const api = km('properties').api
|
|
804
|
+
context.evalue = {
|
|
805
|
+
marker: 'list',
|
|
806
|
+
listable: true,
|
|
807
|
+
value: unflatten(api.relation_get(context, context.relationArgs.map( (arg) => arg.tag ) ))
|
|
808
|
+
}
|
|
809
|
+
context.evalue.isResponse = true
|
|
810
|
+
context.isResponse = true
|
|
811
|
+
if (context.evalue.value.length == 0) {
|
|
812
|
+
context.evalue.marker = 'undefined';
|
|
813
|
+
context.evalue.listable = true
|
|
814
|
+
context.evalue.value = [];
|
|
815
|
+
} else {
|
|
816
|
+
// context.evalue.truthValue = true
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
|
|
821
|
+
{
|
|
822
|
+
notes: `setter for relation based verbs`,
|
|
823
|
+
match: ({context}) => context.relationBacked && !context.toVoice && context.isVerb,
|
|
824
|
+
apply: ({context, km, hierarchy, config}) => {
|
|
825
|
+
const api = km('properties').api
|
|
826
|
+
// add types for arguments
|
|
827
|
+
for (const argument of context.focusable || []) {
|
|
828
|
+
const value = api.toValue(context[argument])
|
|
829
|
+
if (value) {
|
|
830
|
+
const minimas = hierarchy.minima(context[argument].types)
|
|
831
|
+
for (const type of minimas) {
|
|
832
|
+
if (config.exists(value)) {
|
|
833
|
+
config.addHierarchy(value, type);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
api.relation_add(context)
|
|
839
|
+
}
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
notes: 'ordering query',
|
|
843
|
+
match: ({context}) => context.query && (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0),
|
|
844
|
+
apply: ({context, km}) => {
|
|
845
|
+
const api = km('ordering').api
|
|
846
|
+
const propertiesAPI = km('properties').api
|
|
847
|
+
context.ordering = context.orderingArgs.name
|
|
848
|
+
const matches = propertiesAPI.relation_get(context, ['ordering', context.orderingArgs.object, context.orderingArgs.category])
|
|
849
|
+
if (matches.length > 0 || (typeof context.query == 'boolean' && context.query)) {
|
|
850
|
+
// does greg like bananas
|
|
851
|
+
if (matches.length == 0) {
|
|
852
|
+
const response = _.clone(context)
|
|
853
|
+
response.isResponse = true
|
|
854
|
+
response.query = undefined
|
|
855
|
+
context.evalue = { marker: 'list', listable: true, value: [response] }
|
|
856
|
+
} else {
|
|
857
|
+
context.evalue = { marker: 'list', listable: true, value: unflatten(matches) }
|
|
858
|
+
context.evalue.isResponse = true
|
|
859
|
+
}
|
|
860
|
+
context.evalue.truthValue = matches.length > 0
|
|
861
|
+
context.evalue.truth = { marker: 'yesno', value: matches.length > 0, isResponse: true, focus: true }
|
|
862
|
+
context.evalue.focusable = ['truth']
|
|
863
|
+
if (!context.evalue.truthValue) {
|
|
864
|
+
context.evalue.truthValueOnly = true
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// ADD this line back and remove it to check
|
|
868
|
+
// context.response = { marker: 'list', listable: true, value: [response], isResponse: true }
|
|
869
|
+
// Object.assign(context, { marker: 'list', listable: true, value: responses, focusable: ['value'], paraphrase: true, truthValue: matches.length > 0 })
|
|
870
|
+
} else {
|
|
871
|
+
// see if anything is preferred greg
|
|
872
|
+
// what does greg like
|
|
873
|
+
const matches = propertiesAPI.relation_get(context, ['ordering', context.orderingArgs.object])
|
|
874
|
+
if (matches.length == 0) {
|
|
875
|
+
// Object.assign(context, { marker: 'idontknow', query: _.clone(context) })
|
|
876
|
+
context.evalue = { marker: 'idontknow', query: _.clone(context), isResponse: true }
|
|
877
|
+
} else {
|
|
878
|
+
context.evalue = { marker: 'list', listable: true, value: matches, isResponse: true }
|
|
879
|
+
}
|
|
880
|
+
context.isResponse = true
|
|
881
|
+
context.evalue.truthValue = matches.length > 0 && matches[0].marker == context.orderingArgs.marker
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
|
|
886
|
+
{
|
|
887
|
+
notes: 'ordering setter',
|
|
888
|
+
// TODO use hierarchy for operator
|
|
889
|
+
// match: ({context}) => context.marker == operator,
|
|
890
|
+
match: ({context}) => (context.orderingArgs && Object.keys(context.orderingArgs).length !== 0),
|
|
891
|
+
apply: ({context, km}) => {
|
|
892
|
+
const propertiesAPI = km('properties').api
|
|
893
|
+
context.ordering = context.orderingArgs.name
|
|
894
|
+
const fcontexts = flattens(['list'], [context])
|
|
895
|
+
for (const fcontext of fcontexts) {
|
|
896
|
+
fcontext.paraphrase = true
|
|
897
|
+
fcontext[context.orderingArgs.object].paraphrase = true
|
|
898
|
+
fcontext[context.orderingArgs.category].paraphrase = true
|
|
899
|
+
}
|
|
900
|
+
propertiesAPI.relation_add(fcontexts)
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
notes: 'semantic for setting value with constraint',
|
|
905
|
+
//match: ({context, isA}) => isA(context.marker, after[0].tag) && context.constraints,
|
|
906
|
+
match: ({context, isA}) => context.constraints,
|
|
907
|
+
apply: async ({km, context, e, log, isA}) => {
|
|
908
|
+
const constraint = context.constraints[0];
|
|
909
|
+
const value = constraint.constraint;
|
|
910
|
+
let property = constraint.property;
|
|
911
|
+
const properties = constraint.properties;
|
|
912
|
+
for (const p of properties) {
|
|
913
|
+
if (value[p].concept) {
|
|
914
|
+
property = p
|
|
915
|
+
// constraint.property = p; // set what is used
|
|
916
|
+
constraint.property = {...constraint.property, ...p}; // set what is used
|
|
917
|
+
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
// value.marker = 'owns'
|
|
921
|
+
// value.greg = true
|
|
922
|
+
// value.ownee.query = true
|
|
923
|
+
value.query = true
|
|
924
|
+
value.greg99 = 23
|
|
925
|
+
const instance = await e(value, where())
|
|
926
|
+
if (instance.verbatim) {
|
|
927
|
+
context.evalue = { verbatim: instance.verbatim }
|
|
928
|
+
return
|
|
929
|
+
}
|
|
930
|
+
if (instance.evalue.marker === 'undefined') {
|
|
931
|
+
context.evalue = instance.evalue
|
|
932
|
+
return
|
|
933
|
+
}
|
|
934
|
+
const selected = instance.evalue.value.map( (r) => r[property] )
|
|
935
|
+
context.constraints = undefined;
|
|
936
|
+
context.evalue = { marker: 'list', listable: true, value: selected }
|
|
937
|
+
},
|
|
938
|
+
},
|
|
480
939
|
{
|
|
481
940
|
where: where(),
|
|
482
941
|
notes: "how deep is the pool",
|
|
483
942
|
priority: -1,
|
|
484
943
|
match: ({context}) => context.marker == 'is' && (context.one.how || context.two.how),
|
|
485
|
-
apply: async ({
|
|
944
|
+
apply: async ({ resolveEvaluate, g, context, toArray, toList, fragments, kms, e, toEValue }) => {
|
|
486
945
|
const propertyMarkerContext = context.one
|
|
487
946
|
let object = context.two
|
|
488
947
|
if (context.two.how) {
|
|
@@ -496,20 +955,20 @@ const config = {
|
|
|
496
955
|
properties.push({ marker: property, value: property, word: property })
|
|
497
956
|
}
|
|
498
957
|
const propertyOfObject = await fragments("the property of object", { property: toList(properties, true), object })
|
|
499
|
-
const value = toEValue(await e(propertyOfObject))
|
|
958
|
+
const value = toEValue(await e(propertyOfObject, where()))
|
|
500
959
|
value.focusableForPhrase = true
|
|
501
960
|
propertyOfObject.focusableForPhrase = false
|
|
502
961
|
const response = await fragments("the property is value", { property: propertyOfObject, value })
|
|
503
962
|
response.isResponse = true
|
|
504
|
-
|
|
963
|
+
resolveEvaluate(context, response)
|
|
505
964
|
}
|
|
506
965
|
},
|
|
507
966
|
{
|
|
508
967
|
where: where(),
|
|
509
|
-
match: ({context}) => context.marker == '
|
|
968
|
+
match: ({context}) => context.marker == 'same' && context.one.marker == 'concept',
|
|
510
969
|
apply: async (args) => {
|
|
511
970
|
const {context} = args
|
|
512
|
-
await args.makeObject({ ...args, context: context.
|
|
971
|
+
await args.makeObject({ ...args, context: context.two})
|
|
513
972
|
context.sameWasProcessed = true
|
|
514
973
|
}
|
|
515
974
|
},
|
|
@@ -517,13 +976,14 @@ const config = {
|
|
|
517
976
|
// TODO maybe use the dialogue management to get params
|
|
518
977
|
notes: 'wants is xfx between wanter and wantee',
|
|
519
978
|
where: where(),
|
|
520
|
-
match: ({context}) => context.same && context.
|
|
979
|
+
match: ({context}) => context.marker == 'same' && context.two.marker == 'xfx',
|
|
521
980
|
// debug: 'call3',
|
|
522
981
|
apply: ({context, km, config}) => {
|
|
523
982
|
const papi = km('properties').api
|
|
524
|
-
const
|
|
525
|
-
const
|
|
526
|
-
const
|
|
983
|
+
const { one, two } = context
|
|
984
|
+
const singular = pluralize.singular(one.word)
|
|
985
|
+
const plural = pluralize.plural(one.word)
|
|
986
|
+
const args = two.arguments.value;
|
|
527
987
|
papi.createBinaryRelation(config, singular, [singular, plural], args[0].word, args[1].word)
|
|
528
988
|
},
|
|
529
989
|
priority: -1,
|
|
@@ -531,9 +991,9 @@ const config = {
|
|
|
531
991
|
{
|
|
532
992
|
notes: 'marking something as readonly',
|
|
533
993
|
where: where(),
|
|
534
|
-
match: ({context}) => context.same && context.
|
|
994
|
+
match: ({context}) => context.marker == 'same' && context.two.marker == 'readonly',
|
|
535
995
|
apply: ({context, km, objects}) => {
|
|
536
|
-
km('properties').api.setReadOnly([context.value])
|
|
996
|
+
km('properties').api.setReadOnly([context.one.value])
|
|
537
997
|
context.sameWasProcessed = true
|
|
538
998
|
}
|
|
539
999
|
},
|
|
@@ -556,19 +1016,15 @@ const config = {
|
|
|
556
1016
|
notes: 'crew members. evaluate a concepts to get instances',
|
|
557
1017
|
where: where(),
|
|
558
1018
|
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
1019
|
hierarchy.isA(context.marker, 'concept') && ((!context.propertyOf && !context.isProperty) || isA(context.objects[context.objects.length-1], 'dimension')) &&
|
|
563
1020
|
(!context.pullFromContext || context.number == 'many') &&
|
|
564
|
-
context.
|
|
1021
|
+
(context.pullFromContext || isA(context, 'type') || context.metaDefinition) &&
|
|
565
1022
|
!(context.types || []).includes('property') &&
|
|
566
1023
|
// !context.value && // greghere
|
|
567
1024
|
!context.ordinal &&
|
|
568
|
-
(!context.objects || context.objects.length !== 2 || !context.objects[1].
|
|
569
|
-
(api.objects && api.objects.children && api.objects.children[context.marker])
|
|
570
|
-
|
|
571
|
-
apply: ({context, hierarchy, objects, api, km}) => {
|
|
1025
|
+
(!context.objects || context.objects.length !== 2 || !context.objects[1].isInstance) &&
|
|
1026
|
+
(api.objects && api.objects.children && api.objects.children[context.marker]),
|
|
1027
|
+
apply: ({context, isA, contextHierarchy, hierarchy, objects, api, km}) => {
|
|
572
1028
|
const values = api.objects.children[context.marker]
|
|
573
1029
|
const phrases = values.map( (value) => km('concept').api.getWordForValue(value) )
|
|
574
1030
|
// context.focusableForPhrase = true
|
|
@@ -586,11 +1042,18 @@ const config = {
|
|
|
586
1042
|
where: where(),
|
|
587
1043
|
match: ({context}) => context.marker == 'have' && !context.query,
|
|
588
1044
|
apply: ({context, objects, api}) => {
|
|
1045
|
+
if (context.object.unknown) {
|
|
1046
|
+
context.object.value = pluralize.singular(context.object.value)
|
|
1047
|
+
}
|
|
1048
|
+
if (context.property.unknown) {
|
|
1049
|
+
context.property.value = pluralize.singular(context.property.value)
|
|
1050
|
+
}
|
|
589
1051
|
if (context.negation) {
|
|
590
|
-
api.setProperty(
|
|
1052
|
+
api.setProperty(context.object, context.property, null, false)
|
|
591
1053
|
} else {
|
|
592
|
-
api.setProperty(
|
|
1054
|
+
api.setProperty(context.object, context.property, null, true)
|
|
593
1055
|
}
|
|
1056
|
+
// TODO delete this?
|
|
594
1057
|
context.sameWasProcessed = true
|
|
595
1058
|
}
|
|
596
1059
|
},
|
|
@@ -598,12 +1061,13 @@ const config = {
|
|
|
598
1061
|
notes: 'greg has eyes?',
|
|
599
1062
|
where: where(),
|
|
600
1063
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
|
|
601
|
-
apply: async ({context, g, api, objects}) => {
|
|
1064
|
+
apply: async ({error, context, g, api, objects}) => {
|
|
602
1065
|
const object = pluralize.singular(context.object.value);
|
|
603
1066
|
const property = pluralize.singular(context.property.value);
|
|
604
1067
|
context.isResponse = true
|
|
605
1068
|
if (!await api.knownObject(object)) {
|
|
606
|
-
context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
|
|
1069
|
+
// context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
|
|
1070
|
+
error(`there is no object named ${await g({...context.object, paraphrase: true})}`)
|
|
607
1071
|
return
|
|
608
1072
|
}
|
|
609
1073
|
if (!await api.hasProperty(object, property)) {
|
|
@@ -623,26 +1087,31 @@ const config = {
|
|
|
623
1087
|
{
|
|
624
1088
|
notes: 'set the property of an object',
|
|
625
1089
|
where: where(),
|
|
626
|
-
|
|
627
|
-
|
|
1090
|
+
match: async (args) => await args.callOnce(args, 'properties.1', ({context, hierarchy, uuid}) =>
|
|
1091
|
+
context.marker == 'same' &&
|
|
1092
|
+
hierarchy.isA(context.one.marker, 'property') &&
|
|
1093
|
+
context.one.objects),
|
|
628
1094
|
apply: async (args) => {
|
|
629
1095
|
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
|
|
1096
|
+
const objectContext = context.one.objects[context.one.objects.length-1];
|
|
1097
|
+
const propertyContext = context.one.objects[0];
|
|
1098
|
+
// const propertyContext = context.one;
|
|
1099
|
+
if (objectContext.unknown) {
|
|
1100
|
+
objectContext.value = pluralize.singular(objectContext.value)
|
|
1101
|
+
}
|
|
1102
|
+
const objectId = objectContext.value
|
|
633
1103
|
|
|
634
1104
|
await api.makeObject({ ...args, context: objectContext })
|
|
635
1105
|
await api.makeObject({ ...args, context: propertyContext })
|
|
636
|
-
|
|
637
|
-
const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
|
|
1106
|
+
const propertyId = propertyContext.value
|
|
638
1107
|
try {
|
|
639
|
-
api.setProperty(
|
|
1108
|
+
api.setProperty(objectContext, propertyContext, context.two, true)
|
|
640
1109
|
context.sameWasProcessed = true
|
|
641
1110
|
} catch (e) {
|
|
642
1111
|
log(`Error processing set property of an object: ${e}`)
|
|
643
1112
|
const config = km('properties')
|
|
644
1113
|
const value = await api.getProperty(objectId, propertyId)
|
|
645
|
-
if (value?.value == context.
|
|
1114
|
+
if (value?.value == context.two?.value) {
|
|
646
1115
|
context.evalue = [
|
|
647
1116
|
{ marker: 'yesno', value: true, paraphrase: true },
|
|
648
1117
|
]
|
|
@@ -670,10 +1139,9 @@ const config = {
|
|
|
670
1139
|
notes: 'get/evaluate a property',
|
|
671
1140
|
where: where(),
|
|
672
1141
|
match: ({context, hierarchy, toArray}) => {
|
|
673
|
-
return (toArray(context).every((value) => hierarchy.isA(value.marker, 'property')) || (hierarchy.isA(context.marker, 'list') && context.possession)) && context.
|
|
1142
|
+
return (toArray(context).every((value) => hierarchy.isA(value.marker, 'property')) || (hierarchy.isA(context.marker, 'list') && context.possession)) && context.objects
|
|
674
1143
|
},
|
|
675
|
-
|
|
676
|
-
apply: async ({debug, isA, hierarchy, getWordFromDictionary, flatten, asList, context, api, kms, objects, g, s, log, recall}) => {
|
|
1144
|
+
apply: async ({stack, error, debug, isA, hierarchy, getWordFromDictionary, flatten, asList, context, api, kms, objects, g, gp, s, log, recall}) => {
|
|
677
1145
|
async function toValue(objectContext) {
|
|
678
1146
|
if (!objectContext.value) {
|
|
679
1147
|
return objectContext;
|
|
@@ -707,7 +1175,9 @@ const config = {
|
|
|
707
1175
|
|
|
708
1176
|
const propertyPhrase = await g({...nextContext, paraphrase: true})
|
|
709
1177
|
const objectPhrase = await g({...currentContext, paraphrase: true})
|
|
710
|
-
context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
|
|
1178
|
+
// context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
|
|
1179
|
+
error(`There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`)
|
|
1180
|
+
|
|
711
1181
|
return
|
|
712
1182
|
}
|
|
713
1183
|
|
|
@@ -725,7 +1195,13 @@ const config = {
|
|
|
725
1195
|
fromMentions = await recall({ context: nextContext, all: nextContext.number == 'many', frameOfReference: currentContext })
|
|
726
1196
|
}
|
|
727
1197
|
if (!fromMentions) {
|
|
728
|
-
|
|
1198
|
+
if (!currentValue && currentContext.unknown) {
|
|
1199
|
+
// context.verbatim = `What "${await gp(currentContext)}" means is unknown`
|
|
1200
|
+
context.verbatim = `What "${await gp(currentContext)}" means is unknown`
|
|
1201
|
+
} else {
|
|
1202
|
+
// context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
|
|
1203
|
+
error(`There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`)
|
|
1204
|
+
}
|
|
729
1205
|
return
|
|
730
1206
|
}
|
|
731
1207
|
}
|
|
@@ -733,7 +1209,7 @@ const config = {
|
|
|
733
1209
|
currentContext = fromMentions
|
|
734
1210
|
currentValue = fromMentions // TODO not sure what is right here so just do something and fix when actually needed SOP
|
|
735
1211
|
} else {
|
|
736
|
-
currentContext = await api.getProperty(currentValue, nextValue
|
|
1212
|
+
currentContext = await api.getProperty(currentValue, nextValue)
|
|
737
1213
|
currentValue = currentContext.value
|
|
738
1214
|
}
|
|
739
1215
|
}
|
|
@@ -756,7 +1232,7 @@ const config = {
|
|
|
756
1232
|
context.evalue = asList(results, true)
|
|
757
1233
|
context.object = undefined;
|
|
758
1234
|
} else {
|
|
759
|
-
context.evalue = { marker: '
|
|
1235
|
+
context.evalue = { marker: 'undefined' }
|
|
760
1236
|
context.object = undefined;
|
|
761
1237
|
}
|
|
762
1238
|
}
|
|
@@ -772,12 +1248,6 @@ function initializer({objects, config, isModule}) {
|
|
|
772
1248
|
}
|
|
773
1249
|
|
|
774
1250
|
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
1251
|
configs: [
|
|
782
1252
|
"property is a concept",
|
|
783
1253
|
{ query: "concept is a property", isFragment: true },
|
|
@@ -795,6 +1265,15 @@ const template = {
|
|
|
795
1265
|
},
|
|
796
1266
|
],
|
|
797
1267
|
},
|
|
1268
|
+
{ query: "the property1 of object1 is value1", isFragment: true },
|
|
1269
|
+
{ query: "the property of object is value", isFragment: true },
|
|
1270
|
+
{ query: "the property of object", isFragment: true, preserve: ['interpolate'] },
|
|
1271
|
+
{ query: "the property is value", isFragment: true },
|
|
1272
|
+
{ query: "object's property", isFragment: true, preserve: ['interpolate'] },
|
|
1273
|
+
{ query: "object's property is value", isFragment: true, preserve: ['one.interpolate'] },
|
|
1274
|
+
{ query: "object is isPropertyValue", isFragment: true }, // bob is 23 years old
|
|
1275
|
+
{ query: "nobody is isPropertyValue", isFragment: true }, // bob is 23 years old
|
|
1276
|
+
{ query: "the property", isFragment: true },
|
|
798
1277
|
],
|
|
799
1278
|
}
|
|
800
1279
|
|