tpmkms_4wp 8.0.0-beta.31 → 8.0.0-beta.33
Sign up to get free protection for your applications and to get access to all the features.
- package/common/animals.instance.json +325 -0
- package/common/articles.js +108 -0
- package/common/articles.test.json +310 -0
- package/common/colors.instance.json +340 -0
- package/common/crew.instance.json +525 -0
- package/common/dialogues.js +66 -102
- package/common/dimension.instance.json +20 -0
- package/common/edible.instance.json +650 -28
- package/common/emotions.instance.json +25 -0
- package/common/evaluate.instance.json +2 -0
- package/common/evaluate.js +55 -0
- package/common/evaluate.test.json +574 -0
- package/common/fastfood.instance.json +1989 -329
- package/common/formulas.instance.json +20 -0
- package/common/gdefaults.js +6 -6
- package/common/help.test.json +16 -4
- package/common/helpers.js +1 -1
- package/common/kirk.instance.json +20 -0
- package/common/length.instance.json +300 -0
- package/common/math.instance.json +25 -0
- package/common/nameable.instance.json +2 -0
- package/common/nameable.js +137 -0
- package/common/nameable.test.json +1545 -0
- package/common/ordering.instance.json +50 -0
- package/common/people.instance.json +165 -0
- package/common/pipboy.instance.json +340 -0
- package/common/pokemon.instance.json +265 -0
- package/common/pressure.instance.json +80 -0
- package/common/properties.instance.json +25 -0
- package/common/reports.instance.json +41 -1
- package/common/spock.instance.json +20 -0
- package/common/stm.js +109 -3
- package/common/stm.test.json +1702 -1
- package/common/temperature.instance.json +192 -0
- package/common/ui.instance.json +20 -0
- package/common/weight.instance.json +240 -0
- package/main.js +6 -0
- package/package.json +13 -2
package/common/stm.js
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const helpers = require('./helpers')
|
4
|
+
const articles = require('./articles')
|
5
|
+
const evaluate = require('./evaluate')
|
3
6
|
const stm_tests = require('./stm.test.json')
|
4
7
|
|
5
8
|
class API {
|
@@ -10,6 +13,11 @@ class API {
|
|
10
13
|
]
|
11
14
|
this._objects.mentioned = []
|
12
15
|
this._objects.variables = {}
|
16
|
+
this.idCounter = 0
|
17
|
+
}
|
18
|
+
|
19
|
+
getId() {
|
20
|
+
return ++this.idCounter
|
13
21
|
}
|
14
22
|
|
15
23
|
addIsA(isA) {
|
@@ -27,6 +35,10 @@ class API {
|
|
27
35
|
return false
|
28
36
|
}
|
29
37
|
|
38
|
+
getByType(type) {
|
39
|
+
return this._objects.mentioned.filter( (context) => this.isA(context.marker, type) )
|
40
|
+
}
|
41
|
+
|
30
42
|
mentioned(concept, value = undefined) {
|
31
43
|
// TODO value should perhaps have been called id as in concept id and then value could be value
|
32
44
|
if (value) {
|
@@ -43,13 +55,24 @@ class API {
|
|
43
55
|
concept.value = value
|
44
56
|
}
|
45
57
|
concept.fromSTM = true
|
58
|
+
if (!concept.stm_uuid) {
|
59
|
+
concept.stm_uuid = this.getId()
|
60
|
+
}
|
61
|
+
this._objects.mentioned = this._objects.mentioned.filter( (context) => context.stm_uuid != concept.stm_uuid )
|
46
62
|
this._objects.mentioned.unshift(concept)
|
47
63
|
}
|
48
64
|
|
49
65
|
mentions(context, useHierarchy=true) {
|
66
|
+
const findPrevious = !!context.stm_previous
|
67
|
+
|
50
68
|
// care about value first
|
69
|
+
let findCounter = 0
|
51
70
|
for (let m of this._objects.mentioned) {
|
52
|
-
if (context.value && context.value == m.marker) {
|
71
|
+
if (context.value && (context.value == m.marker || context.value == m.value)) {
|
72
|
+
if (findPrevious && findCounter < 1) {
|
73
|
+
findCounter += 1
|
74
|
+
continue
|
75
|
+
}
|
53
76
|
return m
|
54
77
|
}
|
55
78
|
}
|
@@ -57,24 +80,39 @@ class API {
|
|
57
80
|
if (!useHierarchy) {
|
58
81
|
return
|
59
82
|
}
|
83
|
+
|
60
84
|
// care about marker second
|
85
|
+
findCounter = 0
|
61
86
|
for (let m of this._objects.mentioned) {
|
62
87
|
if (context.marker != 'unknown' && this.isA(m.marker, context.marker)) {
|
88
|
+
if (findPrevious && findCounter < 1) {
|
89
|
+
findCounter += 1
|
90
|
+
continue
|
91
|
+
}
|
63
92
|
return m
|
64
93
|
}
|
65
94
|
// if (context.types && context.types.includes(m.marker)) {
|
66
95
|
if (context.types) {
|
67
96
|
for (let parent of context.types) {
|
68
97
|
if (parent != 'unknown' && this.isA(m.marker, parent)) {
|
98
|
+
if (findPrevious && findCounter < 1) {
|
99
|
+
findCounter += 1
|
100
|
+
continue
|
101
|
+
}
|
69
102
|
return m
|
70
103
|
}
|
71
104
|
}
|
72
105
|
}
|
73
106
|
}
|
74
107
|
|
108
|
+
findCounter = 0
|
75
109
|
if (context.types && context.types.length == 1) {
|
76
110
|
for (let m of this._objects.mentioned) {
|
77
111
|
if (context.unknown) {
|
112
|
+
if (findPrevious && findCounter < 1) {
|
113
|
+
findCounter += 1
|
114
|
+
continue
|
115
|
+
}
|
78
116
|
return m
|
79
117
|
}
|
80
118
|
}
|
@@ -99,8 +137,75 @@ class API {
|
|
99
137
|
|
100
138
|
const api = new API()
|
101
139
|
|
140
|
+
const configStruct = {
|
141
|
+
name: 'stm',
|
142
|
+
operators: [
|
143
|
+
"([stm_previous|previous] ([memorable]))",
|
144
|
+
"(([memorable]) [stm_before|before])",
|
145
|
+
"([remember] (memorable/*))",
|
146
|
+
],
|
147
|
+
words: {
|
148
|
+
literals: {
|
149
|
+
"m1": [{"id": "memorable", development: true, "initial": "{ value: 'm1' }" }],
|
150
|
+
"m2": [{"id": "memorable", development: true, "initial": "{ value: 'm2' }" }],
|
151
|
+
},
|
152
|
+
},
|
153
|
+
bridges: [
|
154
|
+
{
|
155
|
+
id: 'memorable',
|
156
|
+
isA: ['theAble'],
|
157
|
+
words: helpers.words('memorable')
|
158
|
+
},
|
159
|
+
{
|
160
|
+
id: 'remember',
|
161
|
+
bridge: "{ ...next(operator), postModifiers: ['rememberee'], rememberee: after[0] }",
|
162
|
+
isA: ['verby'],
|
163
|
+
semantic: async ({context, api, e}) => {
|
164
|
+
let value = (await e(context.rememberee)).evalue
|
165
|
+
if (value == context.rememberee.value) {
|
166
|
+
value = context.rememberee
|
167
|
+
}
|
168
|
+
api.mentioned(value)
|
169
|
+
},
|
170
|
+
},
|
171
|
+
{
|
172
|
+
id: 'stm_previous',
|
173
|
+
bridge: '{ ...after[0], modifiers: ["stm_previous"], stm_previous: operator, pullFromContext: true }',
|
174
|
+
},
|
175
|
+
{
|
176
|
+
id: 'stm_before',
|
177
|
+
isA: ['adjective'],
|
178
|
+
bridge: '{ ...before[0], postModifiers: ["stm_previous"], stm_previous: operator, pullFromContext: true }',
|
179
|
+
},
|
180
|
+
],
|
181
|
+
semantics: [
|
182
|
+
{
|
183
|
+
where: where(),
|
184
|
+
notes: 'pull from context',
|
185
|
+
// match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
|
186
|
+
match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
|
187
|
+
apply: async ({callId, context, kms, e, log, retry}) => {
|
188
|
+
context.value = kms.stm.api.mentions(context)
|
189
|
+
if (!context.value) {
|
190
|
+
// retry()
|
191
|
+
context.value = { marker: 'answerNotKnown' }
|
192
|
+
return
|
193
|
+
}
|
194
|
+
|
195
|
+
const instance = await e(context.value)
|
196
|
+
if (instance.evalue && !instance.edefault) {
|
197
|
+
context.value = instance.evalue
|
198
|
+
}
|
199
|
+
if (context.evaluate) {
|
200
|
+
context.evalue = context.value
|
201
|
+
}
|
202
|
+
},
|
203
|
+
},
|
204
|
+
],
|
205
|
+
}
|
206
|
+
|
102
207
|
let createConfig = async () => {
|
103
|
-
const config = new Config(
|
208
|
+
const config = new Config(configStruct, module)
|
104
209
|
config.stop_auto_rebuild()
|
105
210
|
|
106
211
|
await config.initializer( ({config}) => {
|
@@ -114,6 +219,7 @@ let createConfig = async () => {
|
|
114
219
|
}))
|
115
220
|
})
|
116
221
|
await config.setApi(api)
|
222
|
+
await config.add(evaluate, articles)
|
117
223
|
|
118
224
|
await config.restart_auto_rebuild()
|
119
225
|
return config
|
@@ -127,7 +233,7 @@ knowledgeModule( {
|
|
127
233
|
name: './stm.test.json',
|
128
234
|
contents: stm_tests,
|
129
235
|
checks: {
|
130
|
-
context: defaultContextCheck,
|
236
|
+
context: [...defaultContextCheck, 'pullFromContext', 'stm_uuid'],
|
131
237
|
objects: ['mentioned'],
|
132
238
|
},
|
133
239
|
},
|