tpmkms_4wp 9.5.1-beta.21 → 9.5.1-beta.24
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/asking.js +5 -2
- package/common/can.instance.json +4 -10
- package/common/can.test.json +609 -8
- package/common/colors.instance.json +0 -28
- package/common/conjunction.test.json +32 -42
- package/common/crew.instance.json +0 -104
- package/common/dateTimeSelectors.instance.json +2 -2
- package/common/dateTimeSelectors.js +3 -3
- package/common/dateTimeSelectors.test.json +2229 -1560
- package/common/dates.instance.json +0 -84
- package/common/dates.test.json +284 -287
- package/common/dialogues.test.json +1171 -996
- package/common/dimension.instance.json +3 -3
- package/common/dimension.js +16 -7
- package/common/edible.instance.json +72 -56
- package/common/fastfood.instance.json +149 -121
- package/common/fastfood.test.json +6970 -6829
- package/common/gdefaults.js +5 -3
- package/common/helpers/dialogues.js +6 -1
- package/common/helpers/properties.js +2 -2
- package/common/helpers.js +30 -1
- package/common/length.instance.json +5069 -1358
- package/common/length.js +2 -1
- package/common/length.test.json +9010 -1241
- package/common/menus.instance.json +3 -6
- package/common/menus.js +1 -8
- package/common/numbers.js +1 -1
- package/common/ordering.test.json +104 -174
- package/common/people.instance.json +37 -101
- package/common/pipboy.instance.json +0 -56
- package/common/pressure.instance.json +105 -25
- package/common/properties.instance.json +2 -5
- package/common/properties.js +3 -3
- package/common/properties.test.json +8746 -6638
- package/common/rates.instance.json +57 -0
- package/common/rates.js +94 -0
- package/common/rates.test.json +25771 -0
- package/common/reminders.test.json +1641 -1601
- package/common/reports.instance.json +2 -2
- package/common/tank.instance.json +14862 -0
- package/common/tank.js +407 -0
- package/common/tank.test.json +56670 -0
- package/common/temperature.instance.json +136 -56
- package/common/time.instance.json +20298 -0
- package/common/time.js +150 -139
- package/common/time.test.json +13080 -2233
- package/common/ui.instance.json +2 -5
- package/common/ui.js +1 -8
- package/common/weight.instance.json +522 -182
- package/common/weight.test.json +2590 -2240
- package/common/wp.instance.json +74 -58
- package/common/wp.test.json +4145 -7135
- package/main.js +4 -0
- package/package.json +11 -2
package/common/time.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const tell = require('./tell')
|
|
4
|
-
const
|
|
5
|
-
const numbers = require('./numbers')
|
|
4
|
+
const dimension = require('./dimension')
|
|
6
5
|
const helpers = require('./helpers')
|
|
7
6
|
const time_tests = require('./time.test.json')
|
|
7
|
+
const instance = require('./time.instance.json')
|
|
8
8
|
|
|
9
9
|
function pad(v, l) {
|
|
10
10
|
const s = String(v)
|
|
@@ -12,6 +12,12 @@ function pad(v, l) {
|
|
|
12
12
|
return "0".repeat(n) + s
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
//"what is the time in 24 hour format"
|
|
16
|
+
//"what time is it in Paris"
|
|
17
|
+
//"what time is it in GMT"
|
|
18
|
+
// what is the time
|
|
19
|
+
// how many hours are in a day
|
|
20
|
+
|
|
15
21
|
class API {
|
|
16
22
|
// gets the contexts for doing the happening
|
|
17
23
|
semantics({context, args, kms}) {
|
|
@@ -45,147 +51,151 @@ class API {
|
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//"what is the time in 24 hour format"
|
|
61
|
-
//"what time is it in Paris"
|
|
62
|
-
//"what time is it in GMT"
|
|
63
|
-
// what is the time
|
|
64
|
-
// how many hours are in a day
|
|
65
|
-
],
|
|
66
|
-
bridges: [
|
|
54
|
+
|
|
55
|
+
const template = {
|
|
56
|
+
configs: [
|
|
57
|
+
"years hours minutes and seconds are units of time",
|
|
58
|
+
"hours = minutes / 60",
|
|
59
|
+
"minutes = hours * 60",
|
|
60
|
+
"seconds = minutes * 60",
|
|
61
|
+
"hours = seconds / 3600",
|
|
62
|
+
"seconds = hours * 3600",
|
|
63
|
+
"minutes = seconds / 60",
|
|
64
|
+
"day = hours / 24",
|
|
65
|
+
"hours = days * 24",
|
|
67
66
|
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
id: "atTime",
|
|
75
|
-
words: ['@'],
|
|
76
|
-
isA: ['preposition'],
|
|
77
|
-
bridge: "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: "time",
|
|
81
|
-
bridge: "{ ...next(operator) }"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "ampm",
|
|
85
|
-
isA: ['adjective'],
|
|
86
|
-
localHierarchy: [
|
|
87
|
-
['integer', 'time'],
|
|
67
|
+
operators: [
|
|
68
|
+
"(([timePoint]) [ampm|])",
|
|
69
|
+
"([atTime|at] (timePoint))",
|
|
70
|
+
"([use] (([timeUnit]) [timeFormat|format]))",
|
|
71
|
+
"([hourMinutes|] (integer) (colon) (integer))",
|
|
88
72
|
],
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
bridges: [
|
|
74
|
+
{
|
|
75
|
+
id: 'hourMinutes',
|
|
76
|
+
isA: ['timePoint'],
|
|
77
|
+
convolution: true,
|
|
78
|
+
bridge: "{ ...next(operator), hour: after[0], colon: after[1], minute: after[2], interpolate: '${hour}${colon}${minute}' }",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "timePoint",
|
|
82
|
+
words: ['time'],
|
|
83
|
+
isA: ['noun'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "atTime",
|
|
87
|
+
words: ['@'],
|
|
88
|
+
isA: ['preposition'],
|
|
89
|
+
bridge: "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "ampm",
|
|
93
|
+
isA: ['adjective'],
|
|
94
|
+
localHierarchy: [
|
|
95
|
+
['integer', 'timePoint'],
|
|
96
|
+
],
|
|
97
|
+
bridge: "{ ...next(before[0]), marker: if(isA(before[0].marker, 'integer'), operator('timePoint'), before[0].marker), ampm: operator, time: before[0], interpolate: concat(default(before[0].interpolate, '${time}'), ' ${ampm}') }",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "timeFormat",
|
|
101
|
+
bridge: "{ ...before[0], ...next(operator) }"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "timeUnit",
|
|
105
|
+
isA: ['countable'],
|
|
106
|
+
words: [
|
|
107
|
+
...helpers.words('hour', { initial: "{ units: 'hour' }" }),
|
|
108
|
+
...helpers.words('minute', { initial: "{ units: 'minute' }" }),
|
|
109
|
+
...helpers.words('second', { initial: "{ units: 'second' }" }),
|
|
110
|
+
],
|
|
111
|
+
bridge: "{ ...next(operator) }"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "use",
|
|
115
|
+
bridge: "{ ...next(operator), format: after[0] }",
|
|
116
|
+
generatorp: ({g, context}) => `use ${context.format.quantity.value} hour time`
|
|
117
|
+
},
|
|
101
118
|
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
['ampm', 'queryable'],
|
|
113
|
-
['time', 'theAble'],
|
|
114
|
-
['timeUnit', 'countable'],
|
|
115
|
-
],
|
|
116
|
-
|
|
117
|
-
"words": {
|
|
118
|
-
"literals": {
|
|
119
|
-
"am": [{id: "ampm", "initial": "{ ampm: 'am', determined: true }" }],
|
|
120
|
-
"pm": [{id: "ampm", "initial": "{ ampm: 'pm', determined: true }" }],
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
generators: [
|
|
125
|
-
{
|
|
126
|
-
where: where(),
|
|
127
|
-
match: ({context}) => context.marker == 'time' && context.evalue && context.format == 12,
|
|
128
|
-
apply: ({context}) => {
|
|
129
|
-
let hh = context.evalue.getHours();
|
|
130
|
-
let ampm = 'am'
|
|
131
|
-
if (hh > 12) {
|
|
132
|
-
hh -= 12;
|
|
133
|
-
ampm = 'pm'
|
|
134
|
-
}
|
|
135
|
-
let ss = context.evalue.getMinutes()
|
|
136
|
-
ss = pad(ss, 2)
|
|
137
|
-
return `${hh}:${ss} ${ampm}`
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
where: where(),
|
|
142
|
-
match: ({context}) => context.marker == 'time' && context.evalue && context.format == 24,
|
|
143
|
-
apply: ({g, context}) => {
|
|
144
|
-
function pad(num, size) {
|
|
145
|
-
num = num.toString();
|
|
146
|
-
while (num.length < size) num = "0" + num;
|
|
147
|
-
return num;
|
|
119
|
+
hierarchy: [
|
|
120
|
+
/*
|
|
121
|
+
['ampm', 'queryable'],
|
|
122
|
+
['timeUnit', 'countable'],
|
|
123
|
+
*/
|
|
124
|
+
],
|
|
125
|
+
"words": {
|
|
126
|
+
"literals": {
|
|
127
|
+
"am": [{id: "ampm", "initial": "{ ampm: 'am', determined: true }" }],
|
|
128
|
+
"pm": [{id: "ampm", "initial": "{ ampm: 'pm', determined: true }" }],
|
|
148
129
|
}
|
|
130
|
+
},
|
|
149
131
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
132
|
+
generators: [
|
|
133
|
+
{
|
|
134
|
+
where: where(),
|
|
135
|
+
match: ({context}) => context.marker == 'timePoint' && context.evalue && context.format == 12,
|
|
136
|
+
apply: ({context}) => {
|
|
137
|
+
let hh = context.evalue.getHours();
|
|
138
|
+
let ampm = 'am'
|
|
139
|
+
if (hh > 12) {
|
|
140
|
+
hh -= 12;
|
|
141
|
+
ampm = 'pm'
|
|
142
|
+
}
|
|
143
|
+
let ss = context.evalue.getMinutes()
|
|
144
|
+
ss = pad(ss, 2)
|
|
145
|
+
return `${hh}:${ss} ${ampm}`
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
where: where(),
|
|
150
|
+
match: ({context}) => context.marker == 'timePoint' && context.evalue && context.format == 24,
|
|
151
|
+
apply: ({g, context}) => {
|
|
152
|
+
function pad(num, size) {
|
|
153
|
+
num = num.toString();
|
|
154
|
+
while (num.length < size) num = "0" + num;
|
|
155
|
+
return num;
|
|
156
|
+
}
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
158
|
+
return `${context.evalue.getHours()}:${pad(context.evalue.getMinutes(), 2)}`
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
where: where(),
|
|
163
|
+
match: ({context}) => context.marker == 'response',
|
|
164
|
+
apply: ({g, context}) => context.text
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
|
|
168
|
+
semantics: [
|
|
169
|
+
{
|
|
170
|
+
notes: 'evaluate time',
|
|
171
|
+
where: where(),
|
|
172
|
+
match: ({objects, context, api}) => context.marker == 'timePoint' && context.evaluate,
|
|
173
|
+
apply: ({objects, context, api}) => {
|
|
174
|
+
context.evalue = api.newDate()
|
|
175
|
+
context.format = objects.format
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
notes: 'use time format working case',
|
|
180
|
+
where: where(),
|
|
181
|
+
match: ({objects, context}) => context.marker == 'use' && context.format && (context.format.quantity.value == 12 || context.format.quantity.value == 24),
|
|
182
|
+
apply: ({objects, context}) => {
|
|
183
|
+
objects.format = context.format.quantity.value
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
notes: 'use time format error case',
|
|
188
|
+
where: where(),
|
|
189
|
+
match: ({objects, context}) => context.marker == 'use' && context.format && (context.format.quantity.value != 12 && context.format.quantity.value != 24),
|
|
190
|
+
apply: ({objects, context}) => {
|
|
191
|
+
context.marker = 'response'
|
|
192
|
+
context.text = 'The hour format is 12 hour or 24 hour'
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
}
|
|
187
197
|
],
|
|
188
|
-
}
|
|
198
|
+
}
|
|
189
199
|
|
|
190
200
|
function initializer({api, config, objects, kms, isModule}) {
|
|
191
201
|
if (!isModule) {
|
|
@@ -201,8 +211,8 @@ function initializer({api, config, objects, kms, isModule}) {
|
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
knowledgeModule({
|
|
204
|
-
config,
|
|
205
|
-
includes: [tell,
|
|
214
|
+
config: { name: 'time' },
|
|
215
|
+
includes: [tell, dimension],
|
|
206
216
|
api: () => new API(),
|
|
207
217
|
initializer,
|
|
208
218
|
|
|
@@ -212,7 +222,8 @@ knowledgeModule({
|
|
|
212
222
|
name: './time.test.json',
|
|
213
223
|
contents: time_tests,
|
|
214
224
|
checks: {
|
|
215
|
-
context: [defaultContextCheck({ extra: ['one', 'two', 'events', 'time', 'ampm'] })],
|
|
225
|
+
context: [defaultContextCheck({ extra: ['one', 'two', 'events', 'time', 'timePoint', 'ampm'] })],
|
|
216
226
|
}
|
|
217
227
|
},
|
|
228
|
+
template: { template, instance },
|
|
218
229
|
})
|