tpmkms_4wp 9.5.1-beta.9 → 9.6.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.
Files changed (87) hide show
  1. package/common/asking.js +12 -4
  2. package/common/avatar.test.json +1001 -860
  3. package/common/can.instance.json +2162 -5
  4. package/common/can.js +101 -35
  5. package/common/can.test.json +51307 -0
  6. package/common/colors.instance.json +2 -30
  7. package/common/comparable.instance.json +1 -1
  8. package/common/concept.js +25 -27
  9. package/common/concept.test.json +142 -120
  10. package/common/conjunction.test.json +32 -42
  11. package/common/crew.instance.json +163 -113
  12. package/common/dateTimeSelectors.instance.json +2 -2
  13. package/common/dateTimeSelectors.js +3 -3
  14. package/common/dateTimeSelectors.test.json +76935 -35739
  15. package/common/dates.instance.json +0 -84
  16. package/common/dates.test.json +284 -287
  17. package/common/dialogues.js +31 -112
  18. package/common/dialogues.test.json +1171 -996
  19. package/common/dimension.instance.json +21374 -562
  20. package/common/dimension.js +145 -51
  21. package/common/dimension.test.json +8753 -3495
  22. package/common/drone.instance.json +23712 -0
  23. package/common/drone.js +448 -0
  24. package/common/drone.test.json +66665 -0
  25. package/common/edible.instance.json +9 -65
  26. package/common/emotions.instance.json +47 -70
  27. package/common/errors.js +3 -3
  28. package/common/fastfood.instance.json +758 -266
  29. package/common/fastfood.js +7 -7
  30. package/common/fastfood.test.json +6970 -6829
  31. package/common/gdefaults.js +58 -13
  32. package/common/help.js +9 -9
  33. package/common/help.test.json +65 -11
  34. package/common/helpers/dialogues.js +6 -1
  35. package/common/helpers/properties.js +36 -16
  36. package/common/helpers.js +32 -2
  37. package/common/hierarchy.js +3 -1
  38. package/common/kirk.test.json +600 -424
  39. package/common/latin.instance.json +10 -10
  40. package/common/latin.js +5 -5
  41. package/common/length.instance.json +27611 -2889
  42. package/common/length.js +6 -1
  43. package/common/length.test.json +45315 -3925
  44. package/common/math.instance.json +1 -1
  45. package/common/menus.instance.json +4 -7
  46. package/common/menus.js +1 -8
  47. package/common/meta.js +1 -0
  48. package/common/nameable.js +13 -6
  49. package/common/nameable.test.json +436 -0
  50. package/common/numbers.js +1 -1
  51. package/common/ordering.instance.json +4 -2
  52. package/common/ordering.test.json +104 -174
  53. package/common/people.instance.json +60 -315
  54. package/common/pipboy.instance.json +1 -57
  55. package/common/pokemon.instance.json +5 -5
  56. package/common/pressure.instance.json +3959 -1990
  57. package/common/pressure.test.json +433 -477
  58. package/common/properties.instance.json +5 -16
  59. package/common/properties.js +3 -3
  60. package/common/properties.test.json +9565 -6951
  61. package/common/rates.instance.json +59 -0
  62. package/common/rates.js +97 -0
  63. package/common/rates.test.json +27702 -0
  64. package/common/reminders.js +2 -2
  65. package/common/reminders.test.json +64635 -25787
  66. package/common/reports.instance.json +2 -2
  67. package/common/spock.test.json +606 -430
  68. package/common/stm.js +13 -2
  69. package/common/temperature.instance.json +3658 -1689
  70. package/common/temperature.test.json +433 -477
  71. package/common/time.instance.json +24762 -0
  72. package/common/time.js +135 -139
  73. package/common/time.test.json +31876 -3757
  74. package/common/ui.instance.json +2 -5
  75. package/common/ui.js +1 -8
  76. package/common/weight.instance.json +10359 -4077
  77. package/common/weight.test.json +2601 -2263
  78. package/common/words.instance.json +9 -0
  79. package/common/words.js +53 -0
  80. package/common/words.test.json +2 -0
  81. package/common/wp.instance.json +330 -58
  82. package/common/wp.js +4 -0
  83. package/common/wp.test.json +7385 -6906
  84. package/main.js +4 -2
  85. package/package.json +16 -5
  86. package/common/listener.js +0 -50
  87. package/common/listener.test.json +0 -142
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 countable = require('./countable')
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,136 @@ class API {
45
51
  }
46
52
  }
47
53
 
48
- const config = {
49
- name: 'time',
50
- operators: [
51
- "([time])",
52
- "([atTime|at] (time))",
53
- "([use] (([timeUnit]) [timeFormat|format]))",
54
- // "(([number|]) [ampm|])",
55
- "((time) [ampm|])",
56
- "([hourMinutes|] (integer) (colon) (integer))",
57
- //"(([anyConcept]) [equals|is] ([anyConcept]))",
58
- //"(([what0|what]) [equals] (<the> ([timeConcept])))",
59
- //"(<whatP|what> ([anyConcept]))",
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
- id: 'hourMinutes',
69
- isA: ['time'],
70
- convolution: true,
71
- bridge: "{ ...next(operator), hour: after[0], colon: after[1], minute: after[2], interpolate: '${hour}${colon}${minute}' }",
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
+ "([use] (([quantity]) [timeFormat|format]))",
72
+ "([hourMinutes|] (integer) (colon) (integer))",
88
73
  ],
89
- bridge: "{ ...next(before[0]), marker: if(isA(before[0].marker, 'integer'), operator('time'), before[0].marker), ampm: operator, time: before[0], interpolate: concat(default(before[0].interpolate, '${time}'), ' ${ampm}') }",
90
- },
91
- {
92
- id: "timeFormat",
93
- bridge: "{ ...before[0], ...next(operator) }"
94
- },
95
- {
96
- id: "timeUnit",
97
- words: [
98
- ...helpers.words('hour', { initial: "{ units: 'hour' }" }),
99
- ...helpers.words('minute', { initial: "{ units: 'minute' }" }),
100
- ...helpers.words('second', { initial: "{ units: 'second' }" }),
74
+ bridges: [
75
+ {
76
+ id: 'hourMinutes',
77
+ isA: ['timePoint'],
78
+ convolution: true,
79
+ bridge: "{ ...next(operator), hour: after[0], colon: after[1], minute: after[2], interpolate: '${hour}${colon}${minute}' }",
80
+ },
81
+ {
82
+ id: "timePoint",
83
+ words: ['time'],
84
+ isA: ['noun'],
85
+ },
86
+ {
87
+ id: "atTime",
88
+ words: ['@'],
89
+ isA: ['preposition'],
90
+ bridge: "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
91
+ },
92
+ {
93
+ id: "ampm",
94
+ isA: ['adjective'],
95
+ localHierarchy: [
96
+ ['integer', 'timePoint'],
97
+ ],
98
+ 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}') }",
99
+ },
100
+ {
101
+ id: "timeFormat",
102
+ bridge: "{ ...before[0], ...next(operator), interpolate: [ { context: before[0] }, { context: operator } ] }"
103
+ },
104
+ {
105
+ id: "use",
106
+ bridge: "{ ...next(operator), format: after[0], interpolate: [{ context: operator }, { property: 'format' }] }",
107
+ // generatorp: ({g, context}) => `use ${context.format.quantity.value} hour time`
108
+ },
101
109
  ],
102
- bridge: "{ ...next(operator) }"
103
- },
104
- {
105
- id: "use",
106
- bridge: "{ ...next(operator), format: after[0] }",
107
- generatorp: ({g, context}) => `use ${context.format.quantity.value} hour time`
108
- },
109
- ],
110
- hierarchy: [
111
- ['time', 'queryable'],
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;
110
+ "words": {
111
+ "literals": {
112
+ "am": [{id: "ampm", "initial": "{ ampm: 'am', determined: true }" }],
113
+ "pm": [{id: "ampm", "initial": "{ ampm: 'pm', determined: true }" }],
148
114
  }
115
+ },
149
116
 
150
- return `${context.evalue.getHours()}:${pad(context.evalue.getMinutes(), 2)}`
151
- }
152
- },
153
- {
154
- where: where(),
155
- match: ({context}) => context.marker == 'response',
156
- apply: ({g, context}) => context.text
157
- },
158
- ],
117
+ generators: [
118
+ {
119
+ where: where(),
120
+ match: ({context}) => context.marker == 'timePoint' && context.evalue && context.format == 12,
121
+ apply: ({context}) => {
122
+ let hh = context.evalue.getHours();
123
+ let ampm = 'am'
124
+ if (hh > 12) {
125
+ hh -= 12;
126
+ ampm = 'pm'
127
+ }
128
+ let ss = context.evalue.getMinutes()
129
+ ss = pad(ss, 2)
130
+ return `${hh}:${ss} ${ampm}`
131
+ }
132
+ },
133
+ {
134
+ where: where(),
135
+ match: ({context}) => context.marker == 'timePoint' && context.evalue && context.format == 24,
136
+ apply: ({g, context}) => {
137
+ function pad(num, size) {
138
+ num = num.toString();
139
+ while (num.length < size) num = "0" + num;
140
+ return num;
141
+ }
159
142
 
160
- semantics: [
161
- {
162
- notes: 'evaluate time',
163
- where: where(),
164
- match: ({objects, context, api}) => context.marker == 'time' && context.evaluate,
165
- apply: ({objects, context, api}) => {
166
- context.evalue = api.newDate()
167
- context.format = objects.format
168
- }
169
- },
170
- {
171
- notes: 'use time format working case',
172
- where: where(),
173
- match: ({objects, context}) => context.marker == 'use' && context.format && (context.format.quantity.value == 12 || context.format.quantity.value == 24),
174
- apply: ({objects, context}) => {
175
- objects.format = context.format.quantity.value
176
- }
177
- },
178
- {
179
- notes: 'use time format error 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
- context.marker = 'response'
184
- context.text = 'The hour format is 12 hour or 24 hour'
185
- }
186
- },
143
+ return `${context.evalue.getHours()}:${pad(context.evalue.getMinutes(), 2)}`
144
+ }
145
+ },
146
+ {
147
+ where: where(),
148
+ match: ({context}) => context.marker == 'response',
149
+ apply: ({g, context}) => context.text
150
+ },
151
+ ],
152
+
153
+ semantics: [
154
+ {
155
+ notes: 'evaluate time',
156
+ where: where(),
157
+ match: ({objects, context, api}) => context.marker == 'timePoint' && context.evaluate,
158
+ apply: ({objects, context, api}) => {
159
+ context.evalue = api.newDate()
160
+ context.format = objects.format
161
+ }
162
+ },
163
+ {
164
+ notes: 'use time format working case',
165
+ where: where(),
166
+ match: ({objects, context}) => context.marker == 'use' && context.format && (context.format.amount.value == 12 || context.format.amount.value == 24),
167
+ apply: ({objects, context}) => {
168
+ objects.format = context.format.amount.value
169
+ }
170
+ },
171
+ {
172
+ notes: 'use time format error case',
173
+ where: where(),
174
+ match: ({objects, context}) => context.marker == 'use' && context.format && (context.format.amount.value != 12 && context.format.amount.value != 24),
175
+ apply: ({objects, context}) => {
176
+ context.marker = 'response'
177
+ context.text = 'The hour format is 12 hour or 24 hour'
178
+ }
179
+ },
180
+ ],
181
+ }
187
182
  ],
188
- };
183
+ }
189
184
 
190
185
  function initializer({api, config, objects, kms, isModule}) {
191
186
  if (!isModule) {
@@ -201,8 +196,8 @@ function initializer({api, config, objects, kms, isModule}) {
201
196
  }
202
197
 
203
198
  knowledgeModule({
204
- config,
205
- includes: [tell, numbers, countable],
199
+ config: { name: 'time' },
200
+ includes: [tell, dimension],
206
201
  api: () => new API(),
207
202
  initializer,
208
203
 
@@ -212,7 +207,8 @@ knowledgeModule({
212
207
  name: './time.test.json',
213
208
  contents: time_tests,
214
209
  checks: {
215
- context: [defaultContextCheck({ extra: ['one', 'two', 'events', 'time', 'ampm'] })],
210
+ context: [defaultContextCheck({ extra: ['one', 'two', 'events', 'time', 'timePoint', 'ampm'] })],
216
211
  }
217
212
  },
213
+ template: { template, instance },
218
214
  })