tpmkms_4wp 9.5.1 → 9.6.0-beta.1

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 (135) hide show
  1. package/common/animals.instance.json +151 -61
  2. package/common/animals.js +3 -5
  3. package/common/asking.js +116 -106
  4. package/common/avatar.test.json +1001 -860
  5. package/common/can.instance.json +2194 -0
  6. package/common/can.js +251 -0
  7. package/common/can.test.json +51307 -0
  8. package/common/characters.js +5 -5
  9. package/common/colors.instance.json +152 -12
  10. package/common/colors.js +3 -6
  11. package/common/comparable.instance.json +33 -3
  12. package/common/comparable.js +3 -6
  13. package/common/concept.js +25 -27
  14. package/common/concept.test.json +180 -144
  15. package/common/conjunction.js +13 -5
  16. package/common/conjunction.test.json +32 -42
  17. package/common/crew.instance.json +433 -173
  18. package/common/crew.js +4 -7
  19. package/common/crew.test.json +4148 -3324
  20. package/common/currency.js +1 -1
  21. package/common/dateTimeSelectors.instance.json +2 -2
  22. package/common/dateTimeSelectors.js +6 -9
  23. package/common/dateTimeSelectors.test.json +76935 -35739
  24. package/common/dates.instance.json +53 -3
  25. package/common/dates.js +3 -6
  26. package/common/dates.test.json +284 -287
  27. package/common/dialogues.js +43 -122
  28. package/common/dialogues.test.json +1248 -1152
  29. package/common/dimension.instance.json +21493 -561
  30. package/common/dimension.js +150 -55
  31. package/common/dimension.test.json +10979 -4625
  32. package/common/drone.instance.json +24709 -0
  33. package/common/drone.js +662 -0
  34. package/common/drone.test.json +30522 -0
  35. package/common/drone_v1.instance.json +24703 -0
  36. package/common/drone_v1.js +596 -0
  37. package/common/drone_v1.test.json +115538 -0
  38. package/common/edible.instance.json +388 -32
  39. package/common/edible.js +3 -5
  40. package/common/emotions.instance.json +85 -76
  41. package/common/emotions.js +4 -7
  42. package/common/emotions.test.json +242 -174
  43. package/common/english_helpers.js +336 -0
  44. package/common/errors.js +6 -6
  45. package/common/evaluate.js +2 -2
  46. package/common/events.js +8 -8
  47. package/common/fastfood.instance.json +1071 -393
  48. package/common/fastfood.js +14 -16
  49. package/common/fastfood.test.json +6970 -6829
  50. package/common/formulas.instance.json +11 -1
  51. package/common/formulas.js +3 -2
  52. package/common/gdefaults.js +111 -17
  53. package/common/help.js +12 -12
  54. package/common/help.test.json +65 -11
  55. package/common/helpers/concept.js +1 -1
  56. package/common/helpers/conjunction.js +54 -44
  57. package/common/helpers/dateTimeSelectors.js +2 -2
  58. package/common/helpers/dialogues.js +10 -2
  59. package/common/helpers/formulas.js +13 -11
  60. package/common/helpers/menus.js +12 -12
  61. package/common/helpers/meta.js +9 -9
  62. package/common/helpers/properties.js +186 -64
  63. package/common/helpers.js +167 -48
  64. package/common/hierarchy.js +12 -10
  65. package/common/kirk.instance.json +11 -1
  66. package/common/kirk.js +4 -6
  67. package/common/kirk.test.json +600 -424
  68. package/common/latin.instance.json +12 -12
  69. package/common/latin.js +12 -14
  70. package/common/length.instance.json +34660 -3158
  71. package/common/length.js +11 -6
  72. package/common/length.test.json +54357 -2557
  73. package/common/math.instance.json +39 -29
  74. package/common/math.js +49 -47
  75. package/common/menus.instance.json +77 -10
  76. package/common/menus.js +4 -13
  77. package/common/meta.js +80 -65
  78. package/common/nameable.js +36 -22
  79. package/common/nameable.test.json +436 -0
  80. package/common/numbers.js +1 -1
  81. package/common/ordering.instance.json +107 -19
  82. package/common/ordering.js +4 -6
  83. package/common/ordering.test.json +835 -417
  84. package/common/people.instance.json +176 -348
  85. package/common/people.js +9 -9
  86. package/common/people.test.json +4135 -3606
  87. package/common/pipboy.instance.json +187 -17
  88. package/common/pipboy.js +4 -4
  89. package/common/pokemon.instance.json +143 -13
  90. package/common/pokemon.js +4 -6
  91. package/common/pressure.instance.json +3610 -1601
  92. package/common/pressure.js +3 -5
  93. package/common/pressure.test.json +433 -477
  94. package/common/properties.instance.json +16 -17
  95. package/common/properties.js +32 -13
  96. package/common/properties.test.json +9565 -6951
  97. package/common/rates.instance.json +59 -0
  98. package/common/rates.js +95 -0
  99. package/common/rates.test.json +27702 -0
  100. package/common/reminders.instance.json +4 -4
  101. package/common/reminders.js +8 -11
  102. package/common/reminders.test.json +64635 -25787
  103. package/common/reports.instance.json +23 -3
  104. package/common/reports.js +21 -21
  105. package/common/scorekeeper.js +9 -12
  106. package/common/sdefaults.js +22 -2
  107. package/common/spock.instance.json +11 -1
  108. package/common/spock.js +4 -7
  109. package/common/spock.test.json +606 -430
  110. package/common/stgame.js +1 -1
  111. package/common/stm.js +41 -24
  112. package/common/tell.js +1 -1
  113. package/common/temperature.instance.json +3163 -1154
  114. package/common/temperature.js +3 -5
  115. package/common/temperature.test.json +433 -477
  116. package/common/tester.js +3 -3
  117. package/common/time.instance.json +24852 -0
  118. package/common/time.js +138 -141
  119. package/common/time.test.json +31876 -3757
  120. package/common/tokenize.js +5 -2
  121. package/common/ui.instance.json +12 -5
  122. package/common/ui.js +4 -13
  123. package/common/weight.instance.json +10501 -4099
  124. package/common/weight.js +3 -5
  125. package/common/weight.test.json +2601 -2263
  126. package/common/words.instance.json +9 -0
  127. package/common/words.js +50 -0
  128. package/common/words.test.json +2 -0
  129. package/common/wp.instance.json +548 -8
  130. package/common/wp.js +10 -8
  131. package/common/wp.test.json +7385 -6906
  132. package/main.js +6 -2
  133. package/package.json +25 -6
  134. package/common/listener.js +0 -50
  135. package/common/listener.test.json +0 -142
package/common/time.js CHANGED
@@ -1,17 +1,23 @@
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
- const pad = (v, l) => {
9
+ function pad(v, l) {
10
10
  const s = String(v)
11
11
  const n = l - s.length
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,149 +51,138 @@ 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
- const 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
- const initializer = ({api, config, objects, kms, isModule}) => {
185
+ function initializer({api, config, objects, kms, isModule}) {
191
186
  if (!isModule) {
192
187
  kms.time.api.newDate = () => new Date("December 25, 1995 1:59:58 pm" )
193
188
  }
@@ -201,8 +196,8 @@ const 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,9 @@ 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
+ instance,
214
+ template,
218
215
  })