tpmkms_4wp 9.5.1-beta.2 → 9.5.1-beta.20
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/animals.instance.json +21 -61
- package/common/asking.js +102 -100
- package/common/can.instance.json +2180 -0
- package/common/can.js +254 -0
- package/common/can.test.json +50706 -0
- package/common/characters.js +3 -3
- package/common/colors.instance.json +38 -10
- package/common/comparable.instance.json +2 -2
- package/common/concept.test.json +54 -40
- package/common/conjunction.js +13 -5
- package/common/crew.instance.json +241 -123
- package/common/crew.js +1 -1
- package/common/currency.js +1 -1
- package/common/dates.instance.json +87 -3
- package/common/dialogues.js +41 -119
- package/common/dimension.instance.json +16 -12
- package/common/dimension.js +23 -4
- package/common/dimension.test.json +1758 -2351
- package/common/edible.instance.json +79 -95
- package/common/emotions.instance.json +53 -80
- package/common/emotions.js +1 -1
- package/common/english_helpers.js +277 -67
- package/common/fastfood.instance.json +35 -663
- package/common/fastfood.js +4 -4
- package/common/formulas.instance.json +1 -1
- package/common/gdefaults.js +85 -14
- package/common/help.js +2 -2
- package/common/help.test.json +65 -11
- package/common/helpers/concept.js +1 -1
- package/common/helpers/conjunction.js +54 -44
- package/common/helpers/dateTimeSelectors.js +2 -2
- package/common/helpers/dialogues.js +1 -1
- package/common/helpers/formulas.js +13 -11
- package/common/helpers/menus.js +12 -12
- package/common/helpers/meta.js +8 -8
- package/common/helpers/properties.js +102 -21
- package/common/helpers.js +82 -46
- package/common/hierarchy.js +4 -3
- package/common/kirk.instance.json +1 -1
- package/common/latin.instance.json +10 -10
- package/common/latin.js +5 -5
- package/common/length.instance.json +20 -2
- package/common/length.test.json +2241 -1801
- package/common/math.instance.json +20 -20
- package/common/math.js +45 -44
- package/common/menus.instance.json +3 -3
- package/common/menus.js +1 -1
- package/common/meta.js +49 -33
- package/common/ordering.instance.json +20 -30
- package/common/ordering.js +1 -1
- package/common/ordering.test.json +354 -296
- package/common/people.instance.json +56 -258
- package/common/people.js +1 -1
- package/common/people.test.json +952 -681
- package/common/pipboy.instance.json +72 -16
- package/common/pokemon.instance.json +8 -8
- package/common/pokemon.js +1 -1
- package/common/pressure.instance.json +6 -2
- package/common/properties.instance.json +4 -12
- package/common/properties.js +16 -3
- package/common/reminders.js +1 -1
- package/common/reports.instance.json +3 -3
- package/common/reports.js +18 -16
- package/common/scorekeeper.js +4 -4
- package/common/sdefaults.js +22 -2
- package/common/spock.instance.json +1 -1
- package/common/stgame.js +1 -1
- package/common/stm.js +2 -2
- package/common/tell.js +1 -1
- package/common/temperature.instance.json +6 -2
- package/common/tester.js +3 -3
- package/common/time.js +3 -3
- package/common/tokenize.js +1 -1
- package/common/weight.instance.json +19 -2
- package/common/words.instance.json +9 -0
- package/common/words.js +53 -0
- package/common/words.test.json +2 -0
- package/common/wp.instance.json +320 -8
- package/common/wp.js +8 -4
- package/common/wp.test.json +3469 -0
- package/main.js +0 -2
- package/package.json +9 -5
- package/common/listener.js +0 -50
- package/common/listener.test.json +0 -142
|
@@ -13,7 +13,7 @@ function getVariables(expression, isVariable = (expression) => typeof expression
|
|
|
13
13
|
return []
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function match(values, head, value) {
|
|
17
17
|
for (const prop in head) {
|
|
18
18
|
if (head[prop] instanceof Function) {
|
|
19
19
|
if (!head[prop](value[prop])) {
|
|
@@ -33,22 +33,24 @@ const match = (values, head, value) => {
|
|
|
33
33
|
return true
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
function unify(rule, value) {
|
|
37
37
|
const values = { ...rule.values }
|
|
38
38
|
if (match(values, rule.head(values), value)) {
|
|
39
39
|
return rule.body(values)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
function f(values, variable) {
|
|
44
|
+
return (value) => {
|
|
45
|
+
if (!value) {
|
|
46
|
+
throw new Error("Value not present")
|
|
47
|
+
}
|
|
48
|
+
if (values[variable] && values[variable] != value) {
|
|
49
|
+
throw new Error("Variable already set to different value")
|
|
50
|
+
}
|
|
51
|
+
values[variable] = value
|
|
52
|
+
return true
|
|
49
53
|
}
|
|
50
|
-
values[variable] = value
|
|
51
|
-
return true
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
const rules = [
|
|
@@ -74,7 +76,7 @@ const rules = [
|
|
|
74
76
|
]
|
|
75
77
|
|
|
76
78
|
function solveFor(expression, variable, isVariable = (expression) => typeof expression.value != 'number') {
|
|
77
|
-
|
|
79
|
+
function sameVar(c1, c2) {
|
|
78
80
|
return c1.value == c2.value
|
|
79
81
|
}
|
|
80
82
|
|
package/common/helpers/menus.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function calculateLefts(defs) {
|
|
2
2
|
const lefts = {}
|
|
3
3
|
calculateLeftsHelper(defs, lefts)
|
|
4
4
|
return lefts
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function calculateLeftsHelper(defs, lefts) {
|
|
8
8
|
if (Array.isArray(defs)) {
|
|
9
9
|
let previous
|
|
10
10
|
for (const def of defs) {
|
|
@@ -19,13 +19,13 @@ const calculateLeftsHelper = (defs, lefts) => {
|
|
|
19
19
|
return lefts
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function calculateRights(defs) {
|
|
23
23
|
const rights = {}
|
|
24
24
|
calculateRightsHelper(defs, rights)
|
|
25
25
|
return rights
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
function calculateRightsHelper(defs, rights) {
|
|
29
29
|
if (Array.isArray(defs)) {
|
|
30
30
|
let previous
|
|
31
31
|
for (const def of defs) {
|
|
@@ -40,13 +40,13 @@ const calculateRightsHelper = (defs, rights) => {
|
|
|
40
40
|
return rights
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
function calculateDowns(defs) {
|
|
44
44
|
const downs = {}
|
|
45
45
|
calculateDownsHelper(defs, downs)
|
|
46
46
|
return downs
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
function calculateDownsHelper(defs, downs) {
|
|
50
50
|
if (Array.isArray(defs)) {
|
|
51
51
|
for (const def of defs) {
|
|
52
52
|
calculateDownsHelper(def, downs)
|
|
@@ -72,13 +72,13 @@ const calculateDownsHelper = (defs, downs) => {
|
|
|
72
72
|
return downs
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
function calculateUps(defs) {
|
|
76
76
|
const ups = {}
|
|
77
77
|
calculateUpsHelper(defs, ups)
|
|
78
78
|
return ups
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
function calculateUpsHelper(defs, ups) {
|
|
82
82
|
if (Array.isArray(defs)) {
|
|
83
83
|
for (const def of defs) {
|
|
84
84
|
calculateUpsHelper(def, ups)
|
|
@@ -100,13 +100,13 @@ const calculateUpsHelper = (defs, ups) => {
|
|
|
100
100
|
return ups
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
function calculateParents(defs) {
|
|
104
104
|
const parents = {}
|
|
105
105
|
calculateParentsHelper(defs, parents)
|
|
106
106
|
return parents
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
function calculateParentsHelper(defs, parents) {
|
|
110
110
|
if (Array.isArray(defs)) {
|
|
111
111
|
for (const def of defs) {
|
|
112
112
|
parents[def.key] = def.key
|
|
@@ -123,13 +123,13 @@ const calculateParentsHelper = (defs, parents) => {
|
|
|
123
123
|
return parents
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
function calculatePaths(defs) {
|
|
127
127
|
const paths = {}
|
|
128
128
|
calculatePathsHelper(defs, paths)
|
|
129
129
|
return paths
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
function calculatePathsHelper(defs, paths) {
|
|
133
133
|
if (Array.isArray(defs)) {
|
|
134
134
|
for (const def of defs) {
|
|
135
135
|
calculatePathsHelper(def, paths)
|
package/common/helpers/meta.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function hashIndexesGet(hash, indexes) {
|
|
4
4
|
let value = hash
|
|
5
5
|
for (const i of indexes) {
|
|
6
6
|
value = value[i]
|
|
@@ -8,7 +8,7 @@ const hashIndexesGet = (hash, indexes) => {
|
|
|
8
8
|
return value
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function hashIndexesSet(hash, indexes, value) {
|
|
12
12
|
let currentValue = hash
|
|
13
13
|
for (const i of indexes.slice(0, -1)) {
|
|
14
14
|
if (!currentValue[i]) {
|
|
@@ -19,7 +19,7 @@ const hashIndexesSet = (hash, indexes, value) => {
|
|
|
19
19
|
currentValue[indexes[indexes.length-1]] = value
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function isPrefix(prefix, fix) {
|
|
23
23
|
return prefix.every((element, index) => {
|
|
24
24
|
return prefix[index] === fix[index]
|
|
25
25
|
})
|
|
@@ -27,11 +27,11 @@ const isPrefix = (prefix, fix) => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// assumes isPrefix is true
|
|
30
|
-
|
|
30
|
+
function replacePrefix(prefix, prefixPrime, fix) {
|
|
31
31
|
return prefixPrime.concat(fix.slice(prefix.length))
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
function compose(m1s, m2s) {
|
|
35
35
|
return m2s.map( (m2) => {
|
|
36
36
|
m1 = m1s.find( (m1) => isPrefix(m1.from, m2.from) )
|
|
37
37
|
if (m1) {
|
|
@@ -48,7 +48,7 @@ const compose = (m1s, m2s) => {
|
|
|
48
48
|
'[{"from":["two"],"to":["owner"]},{"from":["one"],"to":["ownee"]},{"from":["number"],"to":["number"]}]'
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
function translationMapping(from, to) {
|
|
52
52
|
const mappings = []
|
|
53
53
|
if (from.atomic) {
|
|
54
54
|
return mappings
|
|
@@ -89,7 +89,7 @@ const translationMapping = (from, to) => {
|
|
|
89
89
|
return mappings
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
function translationMappings(froms, to) {
|
|
93
93
|
const mappingss = []
|
|
94
94
|
for (const from of froms) {
|
|
95
95
|
mappingss.push(translationMapping(from, to))
|
|
@@ -97,7 +97,7 @@ const translationMappings = (froms, to) => {
|
|
|
97
97
|
return mappingss
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
function translationMappingToInstantiatorMappings(translationMapping, from , to) {
|
|
101
101
|
return translationMapping.map( (tm) => {
|
|
102
102
|
return {
|
|
103
103
|
// match: ({context}) => context.value == to[tm.to].value,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const pluralize = require('pluralize')
|
|
2
|
+
const { conjugateVerb } = require('../english_helpers')
|
|
2
3
|
const { unflatten, flattens, Digraph } = require('../runtime').theprogrammablemind
|
|
3
4
|
const _ = require('lodash')
|
|
4
5
|
const deepEqual = require('deep-equal')
|
|
@@ -9,6 +10,24 @@ const { compose, translationMapping, translationMappingToInstantiatorMappings }
|
|
|
9
10
|
class API {
|
|
10
11
|
constructor() {
|
|
11
12
|
this.digraph = new Digraph()
|
|
13
|
+
this.hierarchyWatchers = []
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
addHierarchyWatcher(watcher) {
|
|
17
|
+
this.hierarchyWatchers.push(watcher)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
removeHierarchyWatcher(watcher) {
|
|
21
|
+
this.hierarchyWatchers = this.hierarchyWatchers.filter((w) => w.id == watcher.id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
seenHierarchyWatcher(watcherArgs) {
|
|
25
|
+
const args = { ...this.args, ...watcherArgs }
|
|
26
|
+
for (const { match, apply } of this.hierarchyWatchers) {
|
|
27
|
+
if (match(args)) {
|
|
28
|
+
apply(args)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
12
31
|
}
|
|
13
32
|
|
|
14
33
|
initialize({ km, objects, config }) {
|
|
@@ -28,7 +47,7 @@ class API {
|
|
|
28
47
|
this._km = km
|
|
29
48
|
this.__config = config
|
|
30
49
|
this.digraph = new Digraph()
|
|
31
|
-
|
|
50
|
+
function toJSON(h) {
|
|
32
51
|
if (h.child && h.parent) {
|
|
33
52
|
return h
|
|
34
53
|
} else {
|
|
@@ -274,12 +293,14 @@ class API {
|
|
|
274
293
|
relation,
|
|
275
294
|
ordering,
|
|
276
295
|
doAble,
|
|
296
|
+
flatten,
|
|
297
|
+
can,
|
|
277
298
|
words = [],
|
|
278
299
|
unflatten:unflattenArgs = [],
|
|
279
300
|
focusable = [],
|
|
280
301
|
edAble } = args;
|
|
281
302
|
|
|
282
|
-
|
|
303
|
+
function createToCanonical(concept) {
|
|
283
304
|
if (typeof concept == 'string') {
|
|
284
305
|
return { id: concept, isA: [] }
|
|
285
306
|
} else {
|
|
@@ -308,7 +329,6 @@ class API {
|
|
|
308
329
|
pattern: `([(${beforeOperators} [${operator}|] ${afterOperators}^)])`,
|
|
309
330
|
allowDups: true,
|
|
310
331
|
})
|
|
311
|
-
// config.addOperator({ id: operator, level: 1, words: [operator] })
|
|
312
332
|
config.addBridge({
|
|
313
333
|
id: operator,
|
|
314
334
|
level: 1,
|
|
@@ -328,7 +348,6 @@ class API {
|
|
|
328
348
|
if (create.includes(argument.id)) {
|
|
329
349
|
// config.addHierarchy('unknown', argument.id)
|
|
330
350
|
// config.addHierarchy('what', argument.id)
|
|
331
|
-
// greg23 <<<<<<<<<<<< doing this
|
|
332
351
|
config.addHierarchy(argument.id, 'unknown')
|
|
333
352
|
config.addHierarchy(argument.id, 'what')
|
|
334
353
|
}
|
|
@@ -346,7 +365,7 @@ class API {
|
|
|
346
365
|
|
|
347
366
|
create.map( ({ id, isA }) => {
|
|
348
367
|
if (id === operator) {
|
|
349
|
-
|
|
368
|
+
function tagsToProps(where, args, suffix='') {
|
|
350
369
|
const i = 0;
|
|
351
370
|
let r = ''
|
|
352
371
|
for (const arg of args) {
|
|
@@ -367,16 +386,25 @@ class API {
|
|
|
367
386
|
const imperative = (before.length == 0) ? "true" : "false"
|
|
368
387
|
// const interpolate = "[" + before.map((arg) => `{ property: '${arg.tag}' }`).concat(`{ ...operator, evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' }`).concat(after.map((arg) => `{ property: '${arg.tag}' }`)).join(',') + "]"
|
|
369
388
|
// const interpolateVerb = `{ property: "operator", context: { evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' } }`
|
|
370
|
-
|
|
389
|
+
let interpolateVerb
|
|
390
|
+
if (before.length > 0) {
|
|
391
|
+
interpolateVerb = `{ property: "operator", number: '${before[0].tag}' }`
|
|
392
|
+
} else {
|
|
393
|
+
interpolateVerb = `{ property: "operator" }`
|
|
394
|
+
}
|
|
371
395
|
const interpolate = "[" + before.map((arg) => `{ property: '${arg.tag}' }`).concat(interpolateVerb).concat(after.map((arg) => `{ property: '${arg.tag}' }`)).join(',') + "]"
|
|
372
396
|
|
|
373
397
|
const unflattenArgs = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
|
374
398
|
const focusable = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
|
|
399
|
+
let flattenProperty = ''
|
|
400
|
+
if (flatten) {
|
|
401
|
+
flattenProperty = ", flatten: true, relation: true "
|
|
402
|
+
}
|
|
375
403
|
config.addBridge({
|
|
376
404
|
id: operator,
|
|
377
405
|
level: 0,
|
|
378
406
|
localHierarchy: [...localHierarchy, ['object', 'unknown']],
|
|
379
|
-
bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, operator: { ...operator, evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' }, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)}, interpolate: ${interpolate} }`,
|
|
407
|
+
bridge: `{ ... next(operator) ${flattenProperty} ${doParams} ${beforeArgs} ${afterArgs}, operator: { ...operator, evaluateWord: true, imperative: ${imperative}, isVerb: true, number: 'one' }, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)}, interpolate: ${interpolate} }`,
|
|
380
408
|
allowDups: true
|
|
381
409
|
})
|
|
382
410
|
if (words.length > 0) {
|
|
@@ -396,10 +424,19 @@ class API {
|
|
|
396
424
|
})
|
|
397
425
|
|
|
398
426
|
if (words.length == 0) {
|
|
427
|
+
const createDef = createInit.find((def) => def.id == operator)
|
|
428
|
+
if (createDef && createDef.infinitive) {
|
|
429
|
+
const conjugation = conjugateVerb(createDef.infinitive)
|
|
430
|
+
if (can) {
|
|
431
|
+
const def = conjugation.find((def) => def.form == "pastParticiple")
|
|
432
|
+
config.addWord(def.word, { id: operator, initial: `{ value: '${operator}', isVerb: true, tense: '${def.tense}' }`})
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
399
436
|
const operatorPlural = pluralize.singular(operator)
|
|
400
437
|
const operatorSingular = pluralize.plural(operator)
|
|
401
|
-
config.addWord(operatorSingular, { id: operator, initial: `{ value: '${operator}', number: 'one' }`})
|
|
402
|
-
config.addWord(operatorPlural, { id: operator, initial: `{ value: '${operator}', number: 'many' }`})
|
|
438
|
+
config.addWord(operatorSingular, { id: operator, initial: `{ value: '${operator}', isVerb: true, number: 'one' }`})
|
|
439
|
+
config.addWord(operatorPlural, { id: operator, initial: `{ value: '${operator}', isVerb: true, number: 'many' }`})
|
|
403
440
|
}
|
|
404
441
|
|
|
405
442
|
for (const { child, parent } of hierarchy) {
|
|
@@ -413,6 +450,18 @@ class API {
|
|
|
413
450
|
config.addPriority({ "context": [[operator, 0], ['means', 0], ], "choose": [0] })
|
|
414
451
|
config.addPriority({ "context": [['article', 0], [operator, 0], ], "choose": [0] })
|
|
415
452
|
|
|
453
|
+
if (can) {
|
|
454
|
+
const beforeIds = before.map((def) => def.id)
|
|
455
|
+
const afterIds = after.map((def) => def.id)
|
|
456
|
+
config.addHierarchy(operator, 'canableAction')
|
|
457
|
+
config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestion', 0], [beforeIds[0], 0], [operator, 0]], choose: 1 })
|
|
458
|
+
config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestion', 0], [beforeIds[0], 0], [operator, 0]], choose: 1 })
|
|
459
|
+
config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0]], choose: 1 })
|
|
460
|
+
config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0]], choose: 1 })
|
|
461
|
+
config.addAssociation({ context: [[afterIds[0], 0], ['canPassive', 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
|
|
462
|
+
config.addAssociation({ context: [[afterIds[0], 1], ['canPassive', 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
|
|
463
|
+
}
|
|
464
|
+
|
|
416
465
|
if (false) {
|
|
417
466
|
config.addGenerator({
|
|
418
467
|
notes: 'ordering generator for paraphrase',
|
|
@@ -440,22 +489,54 @@ class API {
|
|
|
440
489
|
config.addGenerator({
|
|
441
490
|
notes: 'ordering generator for response',
|
|
442
491
|
match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
|
|
443
|
-
apply: async ({context, g, km}) => {
|
|
492
|
+
apply: async ({context, s, g, km, flatten}) => {
|
|
444
493
|
const brief = km("dialogues").api.getBrief()
|
|
445
494
|
|
|
446
|
-
|
|
495
|
+
let { evalue } = context
|
|
447
496
|
let yesno = ''
|
|
448
|
-
|
|
449
|
-
|
|
497
|
+
let hasVariables = false
|
|
498
|
+
if (context.focusable) {
|
|
499
|
+
for (const f of context.focusable) {
|
|
500
|
+
if (context[f].query) {
|
|
501
|
+
hasVariables = true
|
|
502
|
+
break
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// if (!context.do?.query || evalue.truthValueOnly || context.truthValueOnly || brief) {
|
|
508
|
+
if (evalue.truthValueOnly || context.truthValueOnly || context.wantsTruthValue || !hasVariables) {
|
|
509
|
+
function any(value, test) {
|
|
510
|
+
if (test(value)) {
|
|
511
|
+
return true
|
|
512
|
+
}
|
|
513
|
+
const values = flatten(['list'], value)[0]
|
|
514
|
+
for (const value of values) {
|
|
515
|
+
if (test(value)) {
|
|
516
|
+
return true
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (any(evalue, (value) => value.truthValue)) {
|
|
450
521
|
yesno = 'yes'
|
|
451
|
-
} else if (evalue.truthValue === false) {
|
|
522
|
+
} else if (evalue.truthValue === false || context.truthValueOnly) {
|
|
452
523
|
yesno = 'no'
|
|
453
524
|
}
|
|
454
525
|
}
|
|
455
|
-
if (evalue.truthValueOnly
|
|
526
|
+
if (evalue.truthValueOnly) {
|
|
456
527
|
return `${yesno}`
|
|
457
528
|
} else {
|
|
458
|
-
|
|
529
|
+
if (context.voice) {
|
|
530
|
+
evalue = await s({ ...evalue, toVoice: context.voice, flatten: false})
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const details = await g(Object.assign({}, evalue, { paraphrase: true }))
|
|
534
|
+
if (yesno) {
|
|
535
|
+
return `${yesno} ${details}`
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return details
|
|
539
|
+
}
|
|
459
540
|
}
|
|
460
541
|
}
|
|
461
542
|
})
|
|
@@ -535,7 +616,7 @@ class API {
|
|
|
535
616
|
if (relation) {
|
|
536
617
|
config.addSemantic({
|
|
537
618
|
notes: `setter for ${operator}`,
|
|
538
|
-
match: ({context}) => context.marker == operator,
|
|
619
|
+
match: ({context}) => context.marker == operator && !context.toVoice,
|
|
539
620
|
apply: ({context, km, hierarchy, config}) => {
|
|
540
621
|
const api = km('properties').api
|
|
541
622
|
// add types for arguments
|
|
@@ -558,7 +639,6 @@ class API {
|
|
|
558
639
|
match: ({context}) => context.marker == operator && context.query,
|
|
559
640
|
apply: ({context, km, callId}) => {
|
|
560
641
|
const api = km('properties').api
|
|
561
|
-
|
|
562
642
|
context.evalue = {
|
|
563
643
|
marker: 'list',
|
|
564
644
|
value: unflatten(api.relation_get(context, before.concat(after).map( (arg) => arg.tag ) ))
|
|
@@ -568,8 +648,8 @@ class API {
|
|
|
568
648
|
if (context.evalue.value.length == 0) {
|
|
569
649
|
context.evalue.marker = 'answerNotKnown';
|
|
570
650
|
context.evalue.value = [];
|
|
571
|
-
|
|
572
|
-
context.evalue.
|
|
651
|
+
} else {
|
|
652
|
+
// context.evalue.truthValue = true
|
|
573
653
|
}
|
|
574
654
|
}
|
|
575
655
|
})
|
|
@@ -599,6 +679,7 @@ class API {
|
|
|
599
679
|
relations = [relations]
|
|
600
680
|
}
|
|
601
681
|
for (const relation of relations) {
|
|
682
|
+
relation.truthValue = true
|
|
602
683
|
this._objects.relations.push(relation)
|
|
603
684
|
}
|
|
604
685
|
}
|
|
@@ -642,7 +723,7 @@ class API {
|
|
|
642
723
|
return value
|
|
643
724
|
}
|
|
644
725
|
|
|
645
|
-
relation_get(context, args) {
|
|
726
|
+
relation_get (context, args) {
|
|
646
727
|
const andTheAnswerIs = []
|
|
647
728
|
for (const relation of this._objects.relations) {
|
|
648
729
|
if (this.relation_match(args, context, relation)) {
|