tpmkms_4wp 9.5.1-beta.3 → 9.5.1-beta.31

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 (114) hide show
  1. package/common/animals.instance.json +21 -61
  2. package/common/asking.js +112 -102
  3. package/common/avatar.test.json +1001 -860
  4. package/common/can.instance.json +2174 -0
  5. package/common/can.js +254 -0
  6. package/common/can.test.json +51307 -0
  7. package/common/characters.js +3 -3
  8. package/common/colors.instance.json +10 -10
  9. package/common/comparable.instance.json +2 -2
  10. package/common/concept.js +19 -22
  11. package/common/concept.test.json +54 -40
  12. package/common/conjunction.js +13 -5
  13. package/common/conjunction.test.json +32 -42
  14. package/common/crew.instance.json +164 -150
  15. package/common/crew.js +1 -1
  16. package/common/currency.js +1 -1
  17. package/common/dateTimeSelectors.instance.json +2 -2
  18. package/common/dateTimeSelectors.js +3 -3
  19. package/common/dateTimeSelectors.test.json +76935 -35739
  20. package/common/dates.instance.json +3 -3
  21. package/common/dates.test.json +284 -287
  22. package/common/dialogues.js +41 -119
  23. package/common/dialogues.test.json +1171 -996
  24. package/common/dimension.instance.json +21374 -562
  25. package/common/dimension.js +145 -51
  26. package/common/dimension.test.json +8753 -3495
  27. package/common/drone.instance.json +23710 -0
  28. package/common/drone.js +429 -0
  29. package/common/drone.test.json +61113 -0
  30. package/common/edible.instance.json +23 -95
  31. package/common/emotions.instance.json +53 -80
  32. package/common/emotions.js +1 -1
  33. package/common/english_helpers.js +277 -67
  34. package/common/fastfood.instance.json +180 -372
  35. package/common/fastfood.js +4 -4
  36. package/common/fastfood.test.json +6970 -6829
  37. package/common/formulas.instance.json +1 -1
  38. package/common/gdefaults.js +94 -17
  39. package/common/help.js +11 -11
  40. package/common/help.test.json +65 -11
  41. package/common/helpers/concept.js +1 -1
  42. package/common/helpers/conjunction.js +54 -44
  43. package/common/helpers/dateTimeSelectors.js +2 -2
  44. package/common/helpers/dialogues.js +7 -2
  45. package/common/helpers/formulas.js +13 -11
  46. package/common/helpers/menus.js +12 -12
  47. package/common/helpers/meta.js +8 -8
  48. package/common/helpers/properties.js +104 -23
  49. package/common/helpers.js +114 -48
  50. package/common/hierarchy.js +6 -4
  51. package/common/kirk.instance.json +1 -1
  52. package/common/kirk.test.json +600 -424
  53. package/common/latin.instance.json +10 -10
  54. package/common/latin.js +5 -5
  55. package/common/length.instance.json +27612 -2890
  56. package/common/length.js +6 -1
  57. package/common/length.test.json +45315 -3925
  58. package/common/math.instance.json +20 -20
  59. package/common/math.js +45 -44
  60. package/common/menus.instance.json +6 -9
  61. package/common/menus.js +2 -9
  62. package/common/meta.js +50 -33
  63. package/common/nameable.js +13 -6
  64. package/common/nameable.test.json +436 -0
  65. package/common/numbers.js +1 -1
  66. package/common/ordering.instance.json +20 -30
  67. package/common/ordering.js +1 -1
  68. package/common/ordering.test.json +414 -426
  69. package/common/people.instance.json +82 -348
  70. package/common/people.js +1 -1
  71. package/common/people.test.json +952 -681
  72. package/common/pipboy.instance.json +16 -16
  73. package/common/pokemon.instance.json +8 -8
  74. package/common/pokemon.js +1 -1
  75. package/common/pressure.instance.json +3579 -1610
  76. package/common/pressure.test.json +433 -477
  77. package/common/properties.instance.json +6 -17
  78. package/common/properties.js +19 -6
  79. package/common/properties.test.json +8746 -6638
  80. package/common/rates.instance.json +59 -0
  81. package/common/rates.js +97 -0
  82. package/common/rates.test.json +27702 -0
  83. package/common/reminders.js +1 -1
  84. package/common/reminders.test.json +64635 -25787
  85. package/common/reports.instance.json +3 -3
  86. package/common/reports.js +18 -16
  87. package/common/scorekeeper.js +4 -4
  88. package/common/sdefaults.js +22 -2
  89. package/common/spock.instance.json +1 -1
  90. package/common/spock.test.json +606 -430
  91. package/common/stgame.js +1 -1
  92. package/common/stm.js +15 -4
  93. package/common/tell.js +1 -1
  94. package/common/temperature.instance.json +3786 -1705
  95. package/common/temperature.test.json +433 -477
  96. package/common/tester.js +3 -3
  97. package/common/time.instance.json +24762 -0
  98. package/common/time.js +137 -141
  99. package/common/time.test.json +31876 -3757
  100. package/common/tokenize.js +1 -1
  101. package/common/ui.instance.json +2 -5
  102. package/common/ui.js +1 -8
  103. package/common/weight.instance.json +10359 -4077
  104. package/common/weight.test.json +2601 -2263
  105. package/common/words.instance.json +9 -0
  106. package/common/words.js +53 -0
  107. package/common/words.test.json +2 -0
  108. package/common/wp.instance.json +336 -8
  109. package/common/wp.js +8 -4
  110. package/common/wp.test.json +7385 -6906
  111. package/main.js +4 -2
  112. package/package.json +18 -5
  113. package/common/listener.js +0 -50
  114. 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,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
  })