tpmkms_4wp 9.5.1 → 9.6.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/animals.instance.json +151 -61
- package/common/animals.js +3 -5
- package/common/asking.js +116 -106
- package/common/avatar.test.json +1001 -860
- package/common/can.instance.json +2194 -0
- package/common/can.js +251 -0
- package/common/can.test.json +51307 -0
- package/common/characters.js +5 -5
- package/common/colors.instance.json +152 -12
- package/common/colors.js +3 -6
- package/common/comparable.instance.json +33 -3
- package/common/comparable.js +3 -6
- package/common/concept.js +25 -27
- package/common/concept.test.json +180 -144
- package/common/conjunction.js +13 -5
- package/common/conjunction.test.json +32 -42
- package/common/crew.instance.json +433 -173
- package/common/crew.js +4 -7
- package/common/crew.test.json +4148 -3324
- package/common/currency.js +1 -1
- package/common/dateTimeSelectors.instance.json +2 -2
- package/common/dateTimeSelectors.js +6 -9
- package/common/dateTimeSelectors.test.json +76935 -35739
- package/common/dates.instance.json +53 -3
- package/common/dates.js +3 -6
- package/common/dates.test.json +284 -287
- package/common/dialogues.js +43 -122
- package/common/dialogues.test.json +1248 -1152
- package/common/dimension.instance.json +21493 -561
- package/common/dimension.js +150 -55
- package/common/dimension.test.json +10979 -4625
- package/common/drone.instance.json +24709 -0
- package/common/drone.js +662 -0
- package/common/drone.test.json +30522 -0
- package/common/drone_v1.instance.json +24703 -0
- package/common/drone_v1.js +596 -0
- package/common/drone_v1.test.json +115538 -0
- package/common/edible.instance.json +388 -32
- package/common/edible.js +3 -5
- package/common/emotions.instance.json +85 -76
- package/common/emotions.js +4 -7
- package/common/emotions.test.json +242 -174
- package/common/english_helpers.js +336 -0
- package/common/errors.js +6 -6
- package/common/evaluate.js +2 -2
- package/common/events.js +8 -8
- package/common/fastfood.instance.json +1071 -393
- package/common/fastfood.js +14 -16
- package/common/fastfood.test.json +6970 -6829
- package/common/formulas.instance.json +11 -1
- package/common/formulas.js +3 -2
- package/common/gdefaults.js +111 -17
- package/common/help.js +12 -12
- 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 +10 -2
- package/common/helpers/formulas.js +13 -11
- package/common/helpers/menus.js +12 -12
- package/common/helpers/meta.js +9 -9
- package/common/helpers/properties.js +186 -64
- package/common/helpers.js +167 -48
- package/common/hierarchy.js +12 -10
- package/common/kirk.instance.json +11 -1
- package/common/kirk.js +4 -6
- package/common/kirk.test.json +600 -424
- package/common/latin.instance.json +12 -12
- package/common/latin.js +12 -14
- package/common/length.instance.json +34660 -3158
- package/common/length.js +11 -6
- package/common/length.test.json +54357 -2557
- package/common/math.instance.json +39 -29
- package/common/math.js +49 -47
- package/common/menus.instance.json +77 -10
- package/common/menus.js +4 -13
- package/common/meta.js +80 -65
- package/common/nameable.js +36 -22
- package/common/nameable.test.json +436 -0
- package/common/numbers.js +1 -1
- package/common/ordering.instance.json +107 -19
- package/common/ordering.js +4 -6
- package/common/ordering.test.json +835 -417
- package/common/people.instance.json +176 -348
- package/common/people.js +9 -9
- package/common/people.test.json +4135 -3606
- package/common/pipboy.instance.json +187 -17
- package/common/pipboy.js +4 -4
- package/common/pokemon.instance.json +143 -13
- package/common/pokemon.js +4 -6
- package/common/pressure.instance.json +3610 -1601
- package/common/pressure.js +3 -5
- package/common/pressure.test.json +433 -477
- package/common/properties.instance.json +16 -17
- package/common/properties.js +32 -13
- package/common/properties.test.json +9565 -6951
- package/common/rates.instance.json +59 -0
- package/common/rates.js +95 -0
- package/common/rates.test.json +27702 -0
- package/common/reminders.instance.json +4 -4
- package/common/reminders.js +8 -11
- package/common/reminders.test.json +64635 -25787
- package/common/reports.instance.json +23 -3
- package/common/reports.js +21 -21
- package/common/scorekeeper.js +9 -12
- package/common/sdefaults.js +22 -2
- package/common/spock.instance.json +11 -1
- package/common/spock.js +4 -7
- package/common/spock.test.json +606 -430
- package/common/stgame.js +1 -1
- package/common/stm.js +41 -24
- package/common/tell.js +1 -1
- package/common/temperature.instance.json +3163 -1154
- package/common/temperature.js +3 -5
- package/common/temperature.test.json +433 -477
- package/common/tester.js +3 -3
- package/common/time.instance.json +24852 -0
- package/common/time.js +138 -141
- package/common/time.test.json +31876 -3757
- package/common/tokenize.js +5 -2
- package/common/ui.instance.json +12 -5
- package/common/ui.js +4 -13
- package/common/weight.instance.json +10501 -4099
- package/common/weight.js +3 -5
- package/common/weight.test.json +2601 -2263
- package/common/words.instance.json +9 -0
- package/common/words.js +50 -0
- package/common/words.test.json +2 -0
- package/common/wp.instance.json +548 -8
- package/common/wp.js +10 -8
- package/common/wp.test.json +7385 -6906
- package/main.js +6 -2
- package/package.json +25 -6
- package/common/listener.js +0 -50
- package/common/listener.test.json +0 -142
package/common/dimension.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
|
2
|
-
const { defaultObjectCheck, defaultContextCheck } = require('./helpers')
|
|
1
|
+
const { debug, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
|
2
|
+
const { defaultObjectCheck, defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
|
|
3
3
|
const hierarchy = require('./hierarchy.js')
|
|
4
4
|
const formulas = require('./formulas.js')
|
|
5
5
|
const testing = require('./testing.js')
|
|
@@ -11,6 +11,14 @@ const instance = require('./dimension.instance.json')
|
|
|
11
11
|
x fahrenheit equals (x-32)*5/9 + 32 fahrenheit
|
|
12
12
|
10 celcius + 5
|
|
13
13
|
|
|
14
|
+
1 meter 10 centimeters
|
|
15
|
+
|
|
16
|
+
1 meter in feet and inches
|
|
17
|
+
10 feet in meters and inches
|
|
18
|
+
|
|
19
|
+
show length in feet and inches
|
|
20
|
+
show length in meters and millimeters
|
|
21
|
+
|
|
14
22
|
10 C
|
|
15
23
|
|
|
16
24
|
use a digraph for calculating convertions
|
|
@@ -24,8 +32,21 @@ const instance = require('./dimension.instance.json')
|
|
|
24
32
|
*/
|
|
25
33
|
class API {
|
|
26
34
|
|
|
27
|
-
initialize({ config }) {
|
|
35
|
+
initialize({ config, objects }) {
|
|
28
36
|
this._config = config
|
|
37
|
+
this._objects = objects
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setMeasurementSystem(measurementSystem) {
|
|
41
|
+
this._objects.measurementSystem = measurementSystem
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if the user says 2 feet deduce english etc
|
|
45
|
+
deduceMeasurementSystem(utterance) {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getMeasurementSystem() {
|
|
49
|
+
return this._objects.measurementSystem
|
|
29
50
|
}
|
|
30
51
|
|
|
31
52
|
setup( {dimension, units} ) {
|
|
@@ -50,27 +71,26 @@ class API {
|
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
// eg, dimension == length; meters == unit; 2 meters == quantity
|
|
54
75
|
|
|
55
76
|
const config = {
|
|
56
77
|
name: 'dimension',
|
|
57
78
|
operators: [
|
|
58
|
-
"([
|
|
79
|
+
"([quantity])",
|
|
59
80
|
"([unit])",
|
|
60
|
-
|
|
61
|
-
"((amount/1 || number/1) [amountOfDimension|] ([unit]))",
|
|
81
|
+
"((amount/* || number/*) [amountOfCoordinate|] ([unit]))",
|
|
62
82
|
"(([amount]) [unit])",
|
|
63
|
-
"((
|
|
83
|
+
"((@<=quantity || context.possession == true) [convertToUnits|in] (unit))",
|
|
64
84
|
|
|
65
85
|
"(([number]) [degree])",
|
|
66
|
-
{ pattern: "([length])",
|
|
86
|
+
{ pattern: "([length])", scope: "testing" },
|
|
67
87
|
],
|
|
68
88
|
priorities: [
|
|
69
89
|
// TODO this should have been calculated
|
|
70
|
-
{ "context": [['
|
|
90
|
+
{ "context": [['amountOfCoordinate', 0], ['convertToUnits', 0], ], "choose": [0] },
|
|
71
91
|
],
|
|
72
92
|
hierarchy: [
|
|
73
|
-
{ child: 'convertToUnits', parent: 'testingValue',
|
|
93
|
+
{ child: 'convertToUnits', parent: 'testingValue', scope: "testing" },
|
|
74
94
|
],
|
|
75
95
|
generators: [
|
|
76
96
|
{
|
|
@@ -83,29 +103,21 @@ const config = {
|
|
|
83
103
|
{
|
|
84
104
|
where: where(),
|
|
85
105
|
id: "dimension",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
where: where(),
|
|
109
|
+
id: "quantity",
|
|
110
|
+
isA: ["noun"],
|
|
86
111
|
bridge: "{ ...next(operator) }",
|
|
87
|
-
|
|
88
|
-
generatorpr: {
|
|
89
|
-
match: ({context}) => context.amount,
|
|
90
|
-
apply: async ({context, gp, gr}) => `${await gr(context.amount)} ${await gp(context.unit)}`,
|
|
91
|
-
},
|
|
112
|
+
generatorpr: async ({context, gp, gr}) => `${await gr(context.amount)} ${await gp(context.unit)}`,
|
|
92
113
|
},
|
|
93
114
|
{
|
|
94
115
|
id: "length",
|
|
95
116
|
isA: ['dimension'],
|
|
96
117
|
bridge: "{ ...next(operator) }",
|
|
97
|
-
|
|
118
|
+
scope: "testing"
|
|
98
119
|
},
|
|
99
120
|
{ id: "amount", },
|
|
100
|
-
/*
|
|
101
|
-
{
|
|
102
|
-
id: "kindOfDimension",
|
|
103
|
-
bridge: "{ ...next(operator), subclass: before[0], class: after[0], value: concat(before[0].marker.id, after[0].marker.id) }",
|
|
104
|
-
// bridge: "{ ...next(operator), subclass: before[0], class: after[0], value: concat(before[0].marker, after[0].marker) }",
|
|
105
|
-
isA: ['preposition'],
|
|
106
|
-
generatorp: ({context, gp}) => `${gp(context.subclass)} ${context.word} ${gp(context.class)}`,
|
|
107
|
-
},
|
|
108
|
-
*/
|
|
109
121
|
{
|
|
110
122
|
where: where(),
|
|
111
123
|
id: "degree",
|
|
@@ -115,9 +127,9 @@ const config = {
|
|
|
115
127
|
bridge: "{ ...next(operator), value: before[0].value, amount: before[0] }",
|
|
116
128
|
},
|
|
117
129
|
{
|
|
118
|
-
id: "
|
|
130
|
+
id: "amountOfCoordinate",
|
|
119
131
|
convolution: true,
|
|
120
|
-
bridge: "{ marker: operator('
|
|
132
|
+
bridge: "{ marker: next(operator('quantity')), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
|
|
121
133
|
},
|
|
122
134
|
{
|
|
123
135
|
where: where(),
|
|
@@ -128,31 +140,53 @@ const config = {
|
|
|
128
140
|
after: [['possession', 0], ['possession', 1]],
|
|
129
141
|
generatorp: async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`,
|
|
130
142
|
// evaluator: ({context, kms, error}) => {
|
|
131
|
-
evaluator: async ({context, kms, e, error}) => {
|
|
132
|
-
/*
|
|
133
|
-
error(({context, e}) => {
|
|
134
|
-
context.evalue = 'dont know...'
|
|
135
|
-
})
|
|
136
|
-
*/
|
|
143
|
+
evaluator: async ({context, kms, e, error, toArray, gp, gr, toList}) => {
|
|
137
144
|
const from = context.from;
|
|
138
|
-
const
|
|
145
|
+
const tos = toArray(context.to);
|
|
139
146
|
let evalue;
|
|
140
147
|
let efrom = from
|
|
141
148
|
if (!from.unit) {
|
|
142
149
|
efrom = (await e(from)).evalue
|
|
143
150
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
async function convert(to) {
|
|
152
|
+
if (to.value == efrom.unit.value) {
|
|
153
|
+
evalue = efrom.amount
|
|
154
|
+
evalue.evalue = efrom.amount.value
|
|
155
|
+
} else {
|
|
156
|
+
const formula = kms.formulas.api.get(to, [efrom.unit])
|
|
157
|
+
if (!formula) {
|
|
158
|
+
const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }
|
|
159
|
+
kms.stm.api.mentioned({ context: reason })
|
|
160
|
+
error(reason)
|
|
161
|
+
}
|
|
162
|
+
kms.stm.api.setVariable(efrom.unit.value, efrom.amount)
|
|
163
|
+
evalue = await e(formula)
|
|
152
164
|
}
|
|
153
|
-
|
|
154
|
-
|
|
165
|
+
return evalue
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let evalues = []
|
|
169
|
+
for (const to of tos) {
|
|
170
|
+
evalues.push({ value: await convert(to), to: structuredClone(to) })
|
|
171
|
+
}
|
|
172
|
+
evalues.sort((a, b) => a.evalue - b.evalue )
|
|
173
|
+
|
|
174
|
+
let fractionalPart = 0
|
|
175
|
+
let scale = 1
|
|
176
|
+
for (const evalue of evalues) {
|
|
177
|
+
const value = evalue.value.evalue * scale
|
|
178
|
+
const integerPart = Math.trunc(value)
|
|
179
|
+
fractionalPart = Math.abs(value - integerPart)
|
|
180
|
+
evalue.value.evalue = integerPart
|
|
181
|
+
scale = fractionalPart / value * scale
|
|
155
182
|
}
|
|
183
|
+
// evalues[evalues.length-1].value.evalue = Number((integerPart * (1+scale)).toFixed(4))
|
|
184
|
+
evalues[evalues.length-1].value.evalue += fractionalPart
|
|
185
|
+
evalues[evalues.length-1].value.evalue = Number(evalues[evalues.length-1].value.evalue.toFixed(4))
|
|
186
|
+
|
|
187
|
+
// remove the zeros
|
|
188
|
+
evalues = evalues.filter( (evalue) => evalue.value.evalue )
|
|
189
|
+
|
|
156
190
|
/*
|
|
157
191
|
'{
|
|
158
192
|
"marker":"dimension",
|
|
@@ -161,12 +195,21 @@ const config = {
|
|
|
161
195
|
"amount":{"word":"degrees","number":"many","text":"10 degrees","marker":"degree","range":{"start":8,"end":17},"value":10,"amount":{"value":10,"text":"10","marker":"number","word":"10","range":{"start":8,"end":9},"types":["number"]}},
|
|
162
196
|
"text":"10 degrees celcius","range":{"start":8,"end":25}}'
|
|
163
197
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
198
|
+
evalues = evalues.map((evalue) => {
|
|
199
|
+
const number = evalue.value.evalue == 1 ? 'one' : 'many'
|
|
200
|
+
evalue.to.number = number
|
|
201
|
+
return {
|
|
202
|
+
paraphrase: true,
|
|
203
|
+
marker: 'quantity',
|
|
204
|
+
level: 1,
|
|
205
|
+
unit: evalue.to,
|
|
206
|
+
amount: { evalue: evalue.value, paraphrase: undefined }
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
if (evalues.length > 1) {
|
|
210
|
+
context.evalue = toList(evalues)
|
|
211
|
+
} else {
|
|
212
|
+
context.evalue = evalues[0]
|
|
170
213
|
}
|
|
171
214
|
},
|
|
172
215
|
},
|
|
@@ -179,8 +222,49 @@ const config = {
|
|
|
179
222
|
|
|
180
223
|
const template = {
|
|
181
224
|
configs: [
|
|
182
|
-
"
|
|
225
|
+
"measurement modifies unit",
|
|
226
|
+
"dimension and measurement unit are concepts",
|
|
227
|
+
"unit means measurement unit",
|
|
228
|
+
({apis}) => {
|
|
229
|
+
apis('properties').addHierarchyWatcher({
|
|
230
|
+
match: ({parentId, isA}) => isA(parentId, 'unit') && parentId.startsWith('unit_'),
|
|
231
|
+
apply: ({config, childId, parent, parentId}) => {
|
|
232
|
+
config.updateBridge(childId, ({ bridge }) => {
|
|
233
|
+
if (!bridge.init) {
|
|
234
|
+
bridge.init = {}
|
|
235
|
+
}
|
|
236
|
+
// bridge.init['dimension'] = parent.object.marker
|
|
237
|
+
bridge.init['dimension'] = parent.object.value
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
},
|
|
242
|
+
"metric modifies system",
|
|
243
|
+
"imperial modifies system",
|
|
244
|
+
"measurement modifies system",
|
|
245
|
+
"the metric system is a measurement system",
|
|
246
|
+
"the imperial system is a measurement system",
|
|
247
|
+
"imperial modifies unit",
|
|
248
|
+
"metric modifies unit",
|
|
249
|
+
"imperial unit is a unit",
|
|
250
|
+
"metric unit is a unit",
|
|
183
251
|
config,
|
|
252
|
+
{
|
|
253
|
+
operators: [
|
|
254
|
+
"([useMeasurementSystem|use] (measurement_system))",
|
|
255
|
+
],
|
|
256
|
+
bridges: [
|
|
257
|
+
{
|
|
258
|
+
id: 'useMeasurementSystem',
|
|
259
|
+
isA: ['verb'],
|
|
260
|
+
bridge: "{ ...next(operator), system: after[0], interpolate: [ { context: operator }, { property: 'system' } ] }",
|
|
261
|
+
semantic: ({context, api}) => {
|
|
262
|
+
api.setMeasurementSystem(context.system.value)
|
|
263
|
+
},
|
|
264
|
+
check: defaultContextCheckProperties(['system']),
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
},
|
|
184
268
|
],
|
|
185
269
|
}
|
|
186
270
|
|
|
@@ -191,14 +275,25 @@ knowledgeModule({
|
|
|
191
275
|
|
|
192
276
|
module,
|
|
193
277
|
description: 'Used to define numeric temperature such as currency, temperature or weight',
|
|
194
|
-
|
|
278
|
+
instance,
|
|
279
|
+
template,
|
|
195
280
|
test: {
|
|
196
281
|
name: './dimension.test.json',
|
|
197
282
|
contents: tests,
|
|
198
283
|
checks: {
|
|
199
|
-
objects: [
|
|
284
|
+
objects: [
|
|
285
|
+
{ km: 'properties' },
|
|
286
|
+
{ path: ['measurementSystem'] },
|
|
287
|
+
],
|
|
200
288
|
context: [
|
|
201
|
-
defaultContextCheck(),
|
|
289
|
+
defaultContextCheck({ marker: 'metric_system', exported: true }),
|
|
290
|
+
defaultContextCheck({ marker: 'convertToUnits', exported: true, extra: ['from', 'to'] }),
|
|
291
|
+
defaultContextCheck({
|
|
292
|
+
match: ({context, isA}) => isA(context.marker, 'unit'),
|
|
293
|
+
exported: true,
|
|
294
|
+
extra: ['dimension'],
|
|
295
|
+
}),
|
|
296
|
+
// defaultContextCheck(['dimension', 'response']),
|
|
202
297
|
],
|
|
203
298
|
},
|
|
204
299
|
},
|