tpmkms 9.8.0-beta.8 → 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.
- package/common/actions.instance.json +4 -4
- package/common/actions.js +9 -9
- package/common/askfor.instance.json +12 -184
- package/common/askfor.js +19 -11
- package/common/asking.js +13 -5
- package/common/can.instance.json +2 -18
- package/common/can.js +2 -2
- package/common/comparable.instance.json +6 -12
- package/common/concept.instance.json +8 -4
- package/common/concept.js +2 -0
- package/common/conjunction.js +6 -4
- package/common/control.js +5 -5
- package/common/countable.js +1 -0
- package/common/dateTimeSelectors.instance.json +1 -1
- package/common/dateTimeSelectors.js +1 -1
- package/common/dates.instance.json +11 -1
- package/common/dates.js +6 -1
- package/common/debug.instance.json +5 -1
- package/common/debug.js +2 -0
- package/common/dialogues.js +37 -35
- package/common/dimension.instance.json +144 -446
- package/common/dimension.js +14 -8
- package/common/drone.instance.json +43 -19
- package/common/drone.js +29 -35
- package/common/drone_v1.instance.json +13 -3
- package/common/drone_v1.js +14 -9
- package/common/evaluate.js +2 -2
- package/common/fastfood.instance.json +12 -4
- package/common/fastfood.js +27 -12
- package/common/formulas.instance.json +138 -12
- package/common/formulas.js +15 -6
- package/common/gdefaults.js +2 -71
- package/common/helpers/dialogues.js +1 -10
- package/common/helpers/properties.js +6 -10
- package/common/helpers.js +5 -2
- package/common/hierarchy.js +11 -7
- package/common/math.instance.json +141 -4
- package/common/math.js +18 -5
- package/common/menus.instance.json +6 -2
- package/common/menus.js +5 -2
- package/common/meta.js +12 -12
- package/common/nameable.js +6 -2
- package/common/ordering.instance.json +1 -2
- package/common/percentages.js +4 -2
- package/common/pipboy.instance.json +38 -27
- package/common/pipboy.js +21 -14
- package/common/properties.instance.json +2319 -560
- package/common/properties.js +146 -37
- package/common/punctuation.js +1 -0
- package/common/rates.instance.json +1 -1
- package/common/rates.js +2 -2
- package/common/reminders.instance.json +16 -0
- package/common/reminders.js +23 -19
- package/common/reports.instance.json +4 -6
- package/common/reports.js +12 -12
- package/common/sdefaults.js +11 -9
- package/common/stm.js +11 -14
- package/common/testing.js +2 -2
- package/common/time.instance.json +42 -15
- package/common/time.js +7 -6
- package/common/ui.js +5 -5
- package/common/words.js +106 -1
- package/common/wp.instance.json +10 -3
- package/common/wp.js +5 -1
- package/package.json +2 -2
package/common/fastfood.js
CHANGED
|
@@ -196,6 +196,7 @@ const template = {
|
|
|
196
196
|
{ id: 'modification' },
|
|
197
197
|
{
|
|
198
198
|
id: 'withModification',
|
|
199
|
+
where: where(),
|
|
199
200
|
level: 0,
|
|
200
201
|
before: ['preposition'],
|
|
201
202
|
generatorp: async ({context, gp}) => `with ${await gp(context.modifications)}`,
|
|
@@ -260,7 +261,7 @@ const template = {
|
|
|
260
261
|
{
|
|
261
262
|
// split "sprite and fanta" into separate things so the ask will pick them up
|
|
262
263
|
match: ({context}) => context.marker == 'list' && context.topLevel && !context.flatten,
|
|
263
|
-
apply: async ({context,
|
|
264
|
+
apply: async ({context, e}) => await e({...context, flatten: true}, where()),
|
|
264
265
|
},
|
|
265
266
|
{
|
|
266
267
|
where: where(),
|
|
@@ -386,13 +387,14 @@ const template = {
|
|
|
386
387
|
bridges: [
|
|
387
388
|
{
|
|
388
389
|
id: "change",
|
|
390
|
+
where: where(),
|
|
389
391
|
isA: ['verb'],
|
|
390
392
|
localHierarchy: [ ['thisitthat', 'meal'], ['thisitthat', 'drink'] ],
|
|
391
393
|
generatorp: async ({context, gp}) => `change ${await gp(context.from)} to ${await gp(context.to)}`,
|
|
392
394
|
bridge: "{ ...next(operator), from: after[0], to: after[1].toObject }",
|
|
393
|
-
semantic: async ({context, api, e}) => {
|
|
395
|
+
semantic: async ({callId, context, api, e, toEValue}) => {
|
|
394
396
|
const state = api.state
|
|
395
|
-
const eFrom = (await e(context.from))
|
|
397
|
+
const eFrom = toEValue(await e(context.from, where()))
|
|
396
398
|
const from = state.getIdCombo(eFrom.fromSTM ? eFrom : context.from)
|
|
397
399
|
const to = state.getIdCombo(context.to)
|
|
398
400
|
for (const item of api.items()) {
|
|
@@ -426,6 +428,7 @@ const template = {
|
|
|
426
428
|
bridges: [
|
|
427
429
|
{
|
|
428
430
|
id: 'remove',
|
|
431
|
+
where: where(),
|
|
429
432
|
isA: ['verb'],
|
|
430
433
|
bridge: "{ ...next(operator), remove: after[0], postModifiers: ['remove'] }",
|
|
431
434
|
semantic: ({context, api}) => {
|
|
@@ -439,6 +442,7 @@ const template = {
|
|
|
439
442
|
},
|
|
440
443
|
{
|
|
441
444
|
id: 'reset',
|
|
445
|
+
where: where(),
|
|
442
446
|
isA: ['verb'],
|
|
443
447
|
bridge: "{ ...next(operator) }",
|
|
444
448
|
semantic: ({context, api}) => {
|
|
@@ -885,9 +889,9 @@ class State {
|
|
|
885
889
|
},
|
|
886
890
|
{
|
|
887
891
|
where: where(),
|
|
888
|
-
match: ({context, isA}) => isA(context.marker, 'number')
|
|
892
|
+
match: ({context, isA}) => isA(context.marker, 'number'),
|
|
889
893
|
apply: async ({context, e}) => {
|
|
890
|
-
food.comboNumber = { value: (await e(context)).value }
|
|
894
|
+
food.comboNumber = { value: (await e(context, where())).value }
|
|
891
895
|
this.add(Object.assign(food, context))
|
|
892
896
|
}
|
|
893
897
|
},
|
|
@@ -947,15 +951,15 @@ const config = {
|
|
|
947
951
|
where: where(),
|
|
948
952
|
priority: -10,
|
|
949
953
|
match: ({context}) => context.marker == 'compound_operator',
|
|
950
|
-
apply: async ({context,
|
|
954
|
+
apply: async ({context, e}) => {
|
|
951
955
|
context.marker = 'list'
|
|
952
956
|
context.flatten = true
|
|
953
|
-
await
|
|
957
|
+
await e(context, where())
|
|
954
958
|
}
|
|
955
959
|
},
|
|
956
960
|
{
|
|
957
961
|
where: where(),
|
|
958
|
-
match: ({context, isAListable}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !
|
|
962
|
+
match: ({context, contextHierarchy, isAListable, stack}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !contextHierarchy.under('change'),
|
|
959
963
|
apply: ({context, km, api, instance}) => {
|
|
960
964
|
for (const element of propertyToArray(context)) {
|
|
961
965
|
km('fastfood').api.state.add(element)
|
|
@@ -967,14 +971,16 @@ const config = {
|
|
|
967
971
|
bridges: [
|
|
968
972
|
{
|
|
969
973
|
id: 'orderNoun',
|
|
974
|
+
where: where(),
|
|
970
975
|
parents: ['noun', 'queryable'],
|
|
971
|
-
|
|
976
|
+
semantic: ({context, api}) => {
|
|
972
977
|
context.evalue = { marker: 'list', value: api.objects.items }
|
|
973
978
|
api.show()
|
|
974
979
|
}
|
|
975
980
|
},
|
|
976
981
|
{
|
|
977
982
|
id: 'showOrder',
|
|
983
|
+
where: where(),
|
|
978
984
|
parents: ['verb'],
|
|
979
985
|
bridge: "{ ...next(operator), order: after[0] }",
|
|
980
986
|
generatorp: async ({context, g}) => `show ${await g(context.order)}`,
|
|
@@ -1001,7 +1007,9 @@ knowledgeModule( {
|
|
|
1001
1007
|
'show',
|
|
1002
1008
|
{
|
|
1003
1009
|
property: 'items',
|
|
1004
|
-
check: [
|
|
1010
|
+
check: [{
|
|
1011
|
+
property: (key) => typeof key == 'number',
|
|
1012
|
+
check: [
|
|
1005
1013
|
'combo',
|
|
1006
1014
|
'pieces',
|
|
1007
1015
|
'size',
|
|
@@ -1009,8 +1017,9 @@ knowledgeModule( {
|
|
|
1009
1017
|
'id',
|
|
1010
1018
|
{ property: 'food', check: [ 'marker', 'value', 'text' ] },
|
|
1011
1019
|
{ property: 'modifications', check: [ 'id', 'item_id', 'food' ] },
|
|
1012
|
-
'needsDrink'
|
|
1013
|
-
|
|
1020
|
+
'needsDrink',
|
|
1021
|
+
]
|
|
1022
|
+
}],
|
|
1014
1023
|
},
|
|
1015
1024
|
'changes',
|
|
1016
1025
|
'response',
|
|
@@ -1021,6 +1030,12 @@ knowledgeModule( {
|
|
|
1021
1030
|
],
|
|
1022
1031
|
context: [
|
|
1023
1032
|
defaultContextCheck({ extra: ['comboNumber'] }),
|
|
1033
|
+
defaultContextCheck({ marker: 'combo', exported: true, extra: ['comboNumber'] }),
|
|
1034
|
+
{
|
|
1035
|
+
match: ({context}) => context.combo,
|
|
1036
|
+
apply: () => ['food', 'needsDrink'],
|
|
1037
|
+
},
|
|
1038
|
+
|
|
1024
1039
|
],
|
|
1025
1040
|
},
|
|
1026
1041
|
},
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"semantics": [
|
|
31
31
|
{
|
|
32
|
-
"match": "({context, api}) => context.
|
|
33
|
-
"apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n context.evalue = await e(formula) \n }"
|
|
32
|
+
"match": "({context, api, stack}) => !context.topLevel && api.get(context)",
|
|
33
|
+
"apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n context.evalue = await e(formula, where()) \n }"
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"bridges": [
|
|
@@ -44,14 +44,46 @@
|
|
|
44
44
|
],
|
|
45
45
|
"convolution": true,
|
|
46
46
|
"bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
|
|
47
|
+
"check": [
|
|
48
|
+
"marker",
|
|
49
|
+
"text",
|
|
50
|
+
"verbatim",
|
|
51
|
+
"value",
|
|
52
|
+
"evalue",
|
|
53
|
+
"isResponse",
|
|
54
|
+
{
|
|
55
|
+
"properties": "modifiers"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"properties": "postModifiers"
|
|
59
|
+
},
|
|
60
|
+
"equality",
|
|
61
|
+
"variable"
|
|
62
|
+
],
|
|
47
63
|
"generatorp": "async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`",
|
|
48
|
-
"
|
|
64
|
+
"semantic": "({context, api, objects, verbatim}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n if (formulas.length > 0) {\n context.evalue = { marker: 'list', value: formulas }\n } else {\n context.evalue = { marker: 'undefined' }\n }\n }"
|
|
49
65
|
},
|
|
50
66
|
{
|
|
51
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
67
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:101",
|
|
52
68
|
"id": "solve",
|
|
53
69
|
"enhanced_associations": false,
|
|
54
70
|
"bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
|
|
71
|
+
"check": [
|
|
72
|
+
"marker",
|
|
73
|
+
"text",
|
|
74
|
+
"verbatim",
|
|
75
|
+
"value",
|
|
76
|
+
"evalue",
|
|
77
|
+
"isResponse",
|
|
78
|
+
{
|
|
79
|
+
"properties": "modifiers"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"properties": "postModifiers"
|
|
83
|
+
},
|
|
84
|
+
"equality",
|
|
85
|
+
"variable"
|
|
86
|
+
],
|
|
55
87
|
"generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`",
|
|
56
88
|
"semantic": "async ({api, context, fragments}) => {\n try {\n context.evalue = await api.solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n } catch( e ) {\n }\n if (!context.evalue) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }"
|
|
57
89
|
},
|
|
@@ -75,12 +107,27 @@
|
|
|
75
107
|
]
|
|
76
108
|
},
|
|
77
109
|
{
|
|
78
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
110
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:133",
|
|
79
111
|
"id": "calculate",
|
|
80
112
|
"isA": [
|
|
81
113
|
"verb"
|
|
82
114
|
],
|
|
83
115
|
"bridge": "{ ...next(operator), expression: after[0] }",
|
|
116
|
+
"check": [
|
|
117
|
+
"marker",
|
|
118
|
+
"text",
|
|
119
|
+
"verbatim",
|
|
120
|
+
"value",
|
|
121
|
+
"evalue",
|
|
122
|
+
"isResponse",
|
|
123
|
+
{
|
|
124
|
+
"properties": "modifiers"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"properties": "postModifiers"
|
|
128
|
+
},
|
|
129
|
+
"expression"
|
|
130
|
+
],
|
|
84
131
|
"generatorp": "async ({context, g}) => `${context.word} ${await g(context.expression)}`",
|
|
85
132
|
"localHierarchy": [
|
|
86
133
|
[
|
|
@@ -88,12 +135,28 @@
|
|
|
88
135
|
"expression"
|
|
89
136
|
]
|
|
90
137
|
],
|
|
91
|
-
"semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression)\n context.isResponse = true\n }"
|
|
138
|
+
"semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression, where())\n context.isResponse = true\n }"
|
|
92
139
|
},
|
|
93
140
|
{
|
|
94
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
141
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:146",
|
|
95
142
|
"id": "equals",
|
|
96
143
|
"bridge": "{ ...next(operator), left: before[0], right: after[0] }",
|
|
144
|
+
"check": [
|
|
145
|
+
"marker",
|
|
146
|
+
"text",
|
|
147
|
+
"verbatim",
|
|
148
|
+
"value",
|
|
149
|
+
"evalue",
|
|
150
|
+
"isResponse",
|
|
151
|
+
{
|
|
152
|
+
"properties": "modifiers"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"properties": "postModifiers"
|
|
156
|
+
},
|
|
157
|
+
"left",
|
|
158
|
+
"right"
|
|
159
|
+
],
|
|
97
160
|
"words": [
|
|
98
161
|
"="
|
|
99
162
|
],
|
|
@@ -440,13 +503,45 @@
|
|
|
440
503
|
"queryable"
|
|
441
504
|
],
|
|
442
505
|
"convolution": true,
|
|
443
|
-
"bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }"
|
|
506
|
+
"bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
|
|
507
|
+
"check": [
|
|
508
|
+
"marker",
|
|
509
|
+
"text",
|
|
510
|
+
"verbatim",
|
|
511
|
+
"value",
|
|
512
|
+
"evalue",
|
|
513
|
+
"isResponse",
|
|
514
|
+
{
|
|
515
|
+
"properties": "modifiers"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"properties": "postModifiers"
|
|
519
|
+
},
|
|
520
|
+
"equality",
|
|
521
|
+
"variable"
|
|
522
|
+
]
|
|
444
523
|
},
|
|
445
524
|
{
|
|
446
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
525
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:101",
|
|
447
526
|
"id": "solve",
|
|
448
527
|
"enhanced_associations": false,
|
|
449
|
-
"bridge": "{ ...next(operator), equality: after[0], variable: after[2] }"
|
|
528
|
+
"bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
|
|
529
|
+
"check": [
|
|
530
|
+
"marker",
|
|
531
|
+
"text",
|
|
532
|
+
"verbatim",
|
|
533
|
+
"value",
|
|
534
|
+
"evalue",
|
|
535
|
+
"isResponse",
|
|
536
|
+
{
|
|
537
|
+
"properties": "modifiers"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"properties": "postModifiers"
|
|
541
|
+
},
|
|
542
|
+
"equality",
|
|
543
|
+
"variable"
|
|
544
|
+
]
|
|
450
545
|
},
|
|
451
546
|
{
|
|
452
547
|
"id": "forVariable",
|
|
@@ -468,12 +563,27 @@
|
|
|
468
563
|
]
|
|
469
564
|
},
|
|
470
565
|
{
|
|
471
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
566
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:133",
|
|
472
567
|
"id": "calculate",
|
|
473
568
|
"isA": [
|
|
474
569
|
"verb"
|
|
475
570
|
],
|
|
476
571
|
"bridge": "{ ...next(operator), expression: after[0] }",
|
|
572
|
+
"check": [
|
|
573
|
+
"marker",
|
|
574
|
+
"text",
|
|
575
|
+
"verbatim",
|
|
576
|
+
"value",
|
|
577
|
+
"evalue",
|
|
578
|
+
"isResponse",
|
|
579
|
+
{
|
|
580
|
+
"properties": "modifiers"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
"properties": "postModifiers"
|
|
584
|
+
},
|
|
585
|
+
"expression"
|
|
586
|
+
],
|
|
477
587
|
"localHierarchy": [
|
|
478
588
|
[
|
|
479
589
|
"unknown",
|
|
@@ -482,9 +592,25 @@
|
|
|
482
592
|
]
|
|
483
593
|
},
|
|
484
594
|
{
|
|
485
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:
|
|
595
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:146",
|
|
486
596
|
"id": "equals",
|
|
487
597
|
"bridge": "{ ...next(operator), left: before[0], right: after[0] }",
|
|
598
|
+
"check": [
|
|
599
|
+
"marker",
|
|
600
|
+
"text",
|
|
601
|
+
"verbatim",
|
|
602
|
+
"value",
|
|
603
|
+
"evalue",
|
|
604
|
+
"isResponse",
|
|
605
|
+
{
|
|
606
|
+
"properties": "modifiers"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"properties": "postModifiers"
|
|
610
|
+
},
|
|
611
|
+
"left",
|
|
612
|
+
"right"
|
|
613
|
+
],
|
|
488
614
|
"words": [
|
|
489
615
|
"="
|
|
490
616
|
],
|
package/common/formulas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { knowledgeModule, where, Digraph, debug } = require('./runtime').theprogrammablemind
|
|
2
|
-
const { defaultContextCheck } = require('./helpers')
|
|
2
|
+
const { defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
|
|
3
3
|
const dialogues = require('./dialogues.js')
|
|
4
4
|
const pos = require('./pos.js')
|
|
5
5
|
const math = require('./math.js')
|
|
@@ -71,10 +71,10 @@ const config = {
|
|
|
71
71
|
semantics: [
|
|
72
72
|
{
|
|
73
73
|
where: where(),
|
|
74
|
-
match: ({context, api}) => context.
|
|
74
|
+
match: ({context, api, stack}) => !context.topLevel && api.get(context),
|
|
75
75
|
apply: async ({context, api, e}) => {
|
|
76
76
|
const { formula } = api.get(context)
|
|
77
|
-
context.evalue = await e(formula)
|
|
77
|
+
context.evalue = await e(formula, where())
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
],
|
|
@@ -86,8 +86,9 @@ const config = {
|
|
|
86
86
|
isA: ['preposition', 'queryable'],
|
|
87
87
|
convolution: true,
|
|
88
88
|
bridge: "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }",
|
|
89
|
+
check: defaultContextCheckProperties(['equality', 'variable']),
|
|
89
90
|
generatorp: async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`,
|
|
90
|
-
|
|
91
|
+
semantic: ({context, api, objects, verbatim}) => {
|
|
91
92
|
const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })
|
|
92
93
|
if (formulas.length > 0) {
|
|
93
94
|
context.evalue = { marker: 'list', value: formulas }
|
|
@@ -101,6 +102,7 @@ const config = {
|
|
|
101
102
|
id: 'solve',
|
|
102
103
|
enhanced_associations: false,
|
|
103
104
|
bridge: "{ ...next(operator), equality: after[0], variable: after[2] }",
|
|
105
|
+
check: defaultContextCheckProperties(['equality', 'variable']),
|
|
104
106
|
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`,
|
|
105
107
|
semantic: async ({api, context, fragments}) => {
|
|
106
108
|
try {
|
|
@@ -132,10 +134,11 @@ const config = {
|
|
|
132
134
|
id: 'calculate',
|
|
133
135
|
isA: ['verb'],
|
|
134
136
|
bridge: "{ ...next(operator), expression: after[0] }",
|
|
137
|
+
check: defaultContextCheckProperties(['expression']),
|
|
135
138
|
generatorp: async ({context, g}) => `${context.word} ${await g(context.expression)}`,
|
|
136
139
|
localHierarchy: [ ['unknown', 'expression'] ],
|
|
137
140
|
semantic: async ({context, e}) => {
|
|
138
|
-
context.evalue = await e(context.expression)
|
|
141
|
+
context.evalue = await e(context.expression, where())
|
|
139
142
|
context.isResponse = true
|
|
140
143
|
}
|
|
141
144
|
},
|
|
@@ -143,6 +146,7 @@ const config = {
|
|
|
143
146
|
where: where(),
|
|
144
147
|
id: 'equals',
|
|
145
148
|
bridge: "{ ...next(operator), left: before[0], right: after[0] }",
|
|
149
|
+
check: defaultContextCheckProperties(['left', 'right']),
|
|
146
150
|
words: ['='],
|
|
147
151
|
after: ['mathematical_operator'],
|
|
148
152
|
// TODO have this be per argument then 'is' can map to equals where this only applied to before[0] and not after[0]
|
|
@@ -195,7 +199,12 @@ knowledgeModule({
|
|
|
195
199
|
contents: tests,
|
|
196
200
|
checks: {
|
|
197
201
|
objects: [
|
|
198
|
-
|
|
202
|
+
{
|
|
203
|
+
property: 'formulas',
|
|
204
|
+
check: [
|
|
205
|
+
{ property: () => true, check: ['name', 'formula', 'equality'] },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
199
208
|
],
|
|
200
209
|
context: [
|
|
201
210
|
defaultContextCheck(),
|
package/common/gdefaults.js
CHANGED
|
@@ -139,75 +139,11 @@ const config = {
|
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
|
|
142
|
-
{
|
|
143
|
-
where: where(),
|
|
144
|
-
priority: -1,
|
|
145
|
-
match: ({context}) => context.marker == 'modifies' && context.evaluateWord && context.paraphrase && context.number == 'one',
|
|
146
|
-
apply: ({context}) => 'modifies'
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
where: where(),
|
|
150
|
-
priority: -1,
|
|
151
|
-
match: ({context}) => context.marker == 'modifies' && context.evaluateWord && context.paraphrase && (context.number == 'many' || context.number > 1),
|
|
152
|
-
apply: ({context}) => 'modify'
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
where: where(),
|
|
157
|
-
priority: -1,
|
|
158
|
-
match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && !context.imperative && !context.interpolate,
|
|
159
|
-
apply: ({context}) => {
|
|
160
|
-
const infinitive = englishHelpers.getInfinitive(context.word)
|
|
161
|
-
if (context.form == 'infinitive') {
|
|
162
|
-
const cases = englishHelpers.conjugateVerb(infinitive)
|
|
163
|
-
const def = cases.find((def) => def.form == context.form)
|
|
164
|
-
return def.word
|
|
165
|
-
} else if (context.tense) {
|
|
166
|
-
const cases = englishHelpers.conjugateVerb(infinitive)
|
|
167
|
-
const def = cases.find((def) => def.tense == context.tense)
|
|
168
|
-
return def.word
|
|
169
|
-
} else {
|
|
170
|
-
return pluralize.plural(context.word)
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
{
|
|
176
|
-
where: where(),
|
|
177
|
-
priority: -1,
|
|
178
|
-
match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || context.number > 1) && !context.interpolate,
|
|
179
|
-
apply: ({context}) => pluralize.plural(context.word),
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
where: where(),
|
|
184
|
-
priority: -1,
|
|
185
|
-
match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
|
|
186
|
-
apply: ({context}) => {
|
|
187
|
-
const infinitive = englishHelpers.getInfinitive(context.word)
|
|
188
|
-
const cases = englishHelpers.conjugateVerb(infinitive)
|
|
189
|
-
return pluralize.plural(context.word)
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
where: where(),
|
|
195
|
-
priority: -1,
|
|
196
|
-
match: ({context}) => context.evaluateWord && context.paraphrase && context.word && context.number == 'one' && !context.interpolate,
|
|
197
|
-
apply: ({context}) => {
|
|
198
|
-
return pluralize.singular(context.word)
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
|
|
202
142
|
{
|
|
203
143
|
where: where(),
|
|
204
144
|
match: ({context}) => context.paraphrase && context.word && (context.number == 'many' || context.number > 1) && !context.isModifier,
|
|
205
|
-
apply: ({context}) => {
|
|
206
|
-
|
|
207
|
-
if (["fahrenheit", "celcius"].includes(context.word)) {
|
|
208
|
-
return context.word
|
|
209
|
-
}
|
|
210
|
-
return pluralize.plural(context.word)
|
|
145
|
+
apply: ({context, kms}) => {
|
|
146
|
+
return kms.words.api.toPlural(context)
|
|
211
147
|
}
|
|
212
148
|
},
|
|
213
149
|
|
|
@@ -312,11 +248,6 @@ function initializer({config}) {
|
|
|
312
248
|
}
|
|
313
249
|
},
|
|
314
250
|
number: (context) => isMany(context) ? "many" : "one",
|
|
315
|
-
// number/gender/person etc
|
|
316
|
-
gw: (context, { number: numberContext } = {}) => {
|
|
317
|
-
const number = numberContext ? args.number(numberContext) : context.number;
|
|
318
|
-
return args.gp( { ...context, evaluateWord: true, number } )
|
|
319
|
-
},
|
|
320
251
|
verbatim,
|
|
321
252
|
say: verbatim,
|
|
322
253
|
interpolate: interpolate(args),
|
|
@@ -28,15 +28,6 @@ class API {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
warningNotEvaluated(log, value) {
|
|
32
|
-
const description = 'WARNING from Dialogues KM: For semantics, implement an evaluations handler, set "value" property of the operator to the value.'
|
|
33
|
-
const match = `({context}) => context.marker == '${value.marker}' && context.evaluate && <other conditions as you like>`
|
|
34
|
-
const apply = `({context}) => <do stuff...>; context.value = <value>`
|
|
35
|
-
const input = indent(JSON.stringify(value, null, 2), 2)
|
|
36
|
-
const message = `${description}\nThe semantic would be\n match: ${match}\n apply: ${apply}\nThe input context would be:\n${input}\n`
|
|
37
|
-
log(indent(message, 4))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
31
|
//
|
|
41
32
|
// duck typing: for operators you want to use here
|
|
42
33
|
//
|
|
@@ -98,7 +89,7 @@ class API {
|
|
|
98
89
|
}
|
|
99
90
|
|
|
100
91
|
initial.value = source_value || concept
|
|
101
|
-
await this.args.
|
|
92
|
+
await this.args.e({ value, makeObject: true, initial })
|
|
102
93
|
// config.addOperator({ pattern: `(["${fixUps(concept)}"])`, allowDups: true })
|
|
103
94
|
config.addOperator({ pattern: `(["${concept}"|])`, allowDups: true })
|
|
104
95
|
config.addBridge({ id: concept, level: 0, bridge: `{ ...operator, dead: true, value: or(operator.value, '${source_value || concept}') }` , allowDups: true })
|
|
@@ -496,16 +496,12 @@ class API {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
for (const arg of args) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return null
|
|
506
|
-
}
|
|
507
|
-
} catch(e) {
|
|
508
|
-
console.log(e)
|
|
499
|
+
const u = await this.args.unify(template[arg], value[arg])
|
|
500
|
+
if (u) {
|
|
501
|
+
continue
|
|
502
|
+
}
|
|
503
|
+
if (!matches(template[arg], value[arg])) {
|
|
504
|
+
return null
|
|
509
505
|
}
|
|
510
506
|
}
|
|
511
507
|
return value
|
package/common/helpers.js
CHANGED
|
@@ -102,6 +102,10 @@ function isMany(context) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
if (context.isPropertyValue) {
|
|
106
|
+
return false
|
|
107
|
+
}
|
|
108
|
+
|
|
105
109
|
let number = context.number
|
|
106
110
|
if (context.quantity) {
|
|
107
111
|
if (context.quantity.number) {
|
|
@@ -248,7 +252,7 @@ function toEValue(context) {
|
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
function toFinalValue(context) {
|
|
251
|
-
while( context
|
|
255
|
+
while( context?.evalue || context?.value ) {
|
|
252
256
|
if (context.evalue) {
|
|
253
257
|
context = context.evalue
|
|
254
258
|
} else {
|
|
@@ -279,7 +283,6 @@ function defaultContextCheck({marker, extra = [], exported = false} = {}) {
|
|
|
279
283
|
if (marker) {
|
|
280
284
|
match = ({context}) => context.marker == marker
|
|
281
285
|
} else {
|
|
282
|
-
match = () => true
|
|
283
286
|
}
|
|
284
287
|
return {
|
|
285
288
|
marker,
|
package/common/hierarchy.js
CHANGED
|
@@ -15,7 +15,7 @@ function getTypes( km, digraph, concept, instance ) {
|
|
|
15
15
|
return new Set([...set1].filter(x => set2.has(x)))
|
|
16
16
|
}
|
|
17
17
|
const descendants = digraph.descendants(concept.value || concept.marker)
|
|
18
|
-
const ancestors = digraph.ancestors(instance.evalue)
|
|
18
|
+
const ancestors = digraph.ancestors(instance.evalue || instance.value)
|
|
19
19
|
const common = intersect(ancestors, descendants)
|
|
20
20
|
const answer = Array.from(digraph.minima(common))
|
|
21
21
|
const words = answer.map( (value) => conceptAPI.getWordForValue(value) )
|
|
@@ -70,6 +70,7 @@ const config = {
|
|
|
70
70
|
hierarchy.isA(context.marker, 'is') &&
|
|
71
71
|
context.query &&
|
|
72
72
|
!context.one.pullFromContext &&
|
|
73
|
+
(context.one?.marker == 'type' || context.two?.marker == 'type') &&
|
|
73
74
|
!['what'].includes(context.one.marker) &&
|
|
74
75
|
!['what'].includes(context.two.marker) &&
|
|
75
76
|
(context.one.query || context.two.query),
|
|
@@ -84,7 +85,7 @@ const config = {
|
|
|
84
85
|
concept = two;
|
|
85
86
|
value = one;
|
|
86
87
|
}
|
|
87
|
-
let instance = await e(value)
|
|
88
|
+
let instance = await e(value, where())
|
|
88
89
|
if (instance.verbatim) {
|
|
89
90
|
context.evalue = { verbatim: instance.verbatim }
|
|
90
91
|
context.isResponse = true
|
|
@@ -118,7 +119,7 @@ const config = {
|
|
|
118
119
|
apply: async ({context, hierarchy, objects, e, gs, km, log}) => {
|
|
119
120
|
const concept = context.objects[0];
|
|
120
121
|
const value = context.objects[1];
|
|
121
|
-
let instance = await e(value)
|
|
122
|
+
let instance = await e(value, where())
|
|
122
123
|
if (instance.verbatim) {
|
|
123
124
|
context.evalue = { verbatim: instance.verbatim }
|
|
124
125
|
return
|
|
@@ -230,11 +231,13 @@ const config = {
|
|
|
230
231
|
notes: 'humans are mammels',
|
|
231
232
|
where: where(),
|
|
232
233
|
match: ({debug, context, listable, hierarchy, isA, callId}) => {
|
|
233
|
-
// debug.b2reakAt('dates#call4')
|
|
234
234
|
if (context.marker !== 'same') {
|
|
235
235
|
return
|
|
236
236
|
}
|
|
237
237
|
const { one, two } = context
|
|
238
|
+
if (one.query || two.query) {
|
|
239
|
+
return
|
|
240
|
+
}
|
|
238
241
|
|
|
239
242
|
// let the "the metric system is a measurement system" threw but block 'the gender is male'
|
|
240
243
|
if (one.theable && !two.determiner && !two.pullFromContext) {
|
|
@@ -242,8 +245,6 @@ const config = {
|
|
|
242
245
|
}
|
|
243
246
|
if (two.determiner && two.determiner.marker == 'a') {
|
|
244
247
|
two.concept = true;
|
|
245
|
-
} else if (two.evaluate) {
|
|
246
|
-
return // some kind of instance
|
|
247
248
|
} else if (two.word && pluralize.isPlural(two.word)) {
|
|
248
249
|
two.concept = true;
|
|
249
250
|
} else if (one.number == 'many') {
|
|
@@ -342,7 +343,10 @@ knowledgeModule( {
|
|
|
342
343
|
contents: hierarchy_tests,
|
|
343
344
|
// TODO doesnt this need the KM
|
|
344
345
|
checks: {
|
|
345
|
-
objects: [
|
|
346
|
+
objects: [
|
|
347
|
+
'children', 'concept', 'parents', 'properties',
|
|
348
|
+
{ km: 'properties' },
|
|
349
|
+
],
|
|
346
350
|
context: [
|
|
347
351
|
defaultContextCheck(),
|
|
348
352
|
],
|