tpmkms 8.0.0-beta.5 → 8.0.0-beta.50

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 (99) hide show
  1. package/common/animals.instance.json +2855 -1363
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/avatar.js +5 -9
  6. package/common/characters.js +22 -28
  7. package/common/colors.instance.json +6978 -3493
  8. package/common/colors.js +4 -8
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.js +5 -22
  11. package/common/concept.js +120 -118
  12. package/common/countable.js +18 -12
  13. package/common/countable.test.json +1050 -0
  14. package/common/crew.instance.json +13032 -6570
  15. package/common/crew.js +36 -41
  16. package/common/crew.test.json +714 -452
  17. package/common/currency.js +27 -45
  18. package/common/dialogues.js +158 -282
  19. package/common/dimension.instance.json +273 -272
  20. package/common/dimension.js +16 -22
  21. package/common/dimension.test.json +446 -1640
  22. package/common/edible.instance.json +19911 -9877
  23. package/common/edible.js +3 -8
  24. package/common/emotions.instance.json +146 -128
  25. package/common/emotions.js +35 -38
  26. package/common/evaluate.instance.json +2 -0
  27. package/common/evaluate.js +49 -0
  28. package/common/evaluate.test.json +574 -0
  29. package/common/events.js +9 -13
  30. package/common/fastfood.instance.json +221141 -111240
  31. package/common/fastfood.js +70 -80
  32. package/common/formulas.instance.json +251 -265
  33. package/common/formulas.js +17 -24
  34. package/common/gdefaults.js +24 -26
  35. package/common/help.js +7 -12
  36. package/common/help.test.json +22 -22
  37. package/common/helpers/concept.js +9 -6
  38. package/common/helpers/dialogues.js +2 -3
  39. package/common/helpers/properties.js +52 -58
  40. package/common/helpers.js +1 -1
  41. package/common/hierarchy.js +16 -24
  42. package/common/javascript.js +11 -18
  43. package/common/kirk.instance.json +583 -289
  44. package/common/kirk.js +5 -8
  45. package/common/length.instance.json +5530 -4754
  46. package/common/length.js +4 -8
  47. package/common/listener.js +48 -0
  48. package/common/listener.test.json +104 -0
  49. package/common/math.instance.json +192 -1184
  50. package/common/math.js +15 -19
  51. package/common/meta.js +23 -47
  52. package/common/nameable.instance.json +2 -0
  53. package/common/nameable.js +135 -0
  54. package/common/nameable.test.json +2121 -0
  55. package/common/negation.instance.json +2 -0
  56. package/common/negation.js +38 -0
  57. package/common/negation.test.json +308 -0
  58. package/common/numbers.js +6 -10
  59. package/common/ordering.instance.json +340 -160
  60. package/common/ordering.js +80 -86
  61. package/common/people.instance.json +2066 -1014
  62. package/common/people.js +8 -13
  63. package/common/percentages.instance.json +2 -0
  64. package/common/percentages.js +53 -0
  65. package/common/percentages.test.json +751 -0
  66. package/common/pipboy.instance.json +7999 -6269
  67. package/common/pipboy.js +32 -43
  68. package/common/pokemon.instance.json +4207 -2069
  69. package/common/pokemon.js +7 -20
  70. package/common/pos.js +4 -5
  71. package/common/pressure.instance.json +1341 -1189
  72. package/common/pressure.js +4 -8
  73. package/common/properties.instance.json +130 -60
  74. package/common/properties.js +56 -133
  75. package/common/punctuation.js +6 -6
  76. package/common/reports.instance.json +595 -557
  77. package/common/reports.js +64 -89
  78. package/common/scorekeeper.js +18 -30
  79. package/common/sdefaults.js +16 -7
  80. package/common/sizeable.js +5 -9
  81. package/common/spock.instance.json +583 -289
  82. package/common/spock.js +5 -8
  83. package/common/stgame.js +19 -19
  84. package/common/stm.js +163 -26
  85. package/common/stm.test.json +1734 -1
  86. package/common/tell.js +14 -18
  87. package/common/temperature.instance.json +1461 -1293
  88. package/common/temperature.js +4 -8
  89. package/common/tester.js +3 -3
  90. package/common/testing.js +8 -12
  91. package/common/time.js +20 -25
  92. package/common/tokenize.js +4 -5
  93. package/common/ui.instance.json +257 -258
  94. package/common/ui.js +11 -17
  95. package/common/weight.instance.json +5212 -4233
  96. package/common/weight.js +4 -8
  97. package/common/yesno.js +5 -5
  98. package/main.js +59 -46
  99. package/package.json +27 -5
package/common/animals.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { defaultContextCheck } = require('./helpers')
2
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
3
3
  const hierarchy = require('./hierarchy')
4
4
  const animals_tests = require('./animals.test.json')
5
5
  const animals_instance = require('./animals.instance.json')
@@ -25,26 +25,23 @@ const template = {
25
25
  ],
26
26
  }
27
27
 
28
- const createConfig = () => {
29
- const config = new Config({ name: 'animals' }, module)
30
- config.add(hierarchy())
31
- return config
32
- }
33
-
34
28
  knowledgeModule( {
35
- module,
36
- description: 'animals related concepts',
37
- createConfig, newWay: true,
38
- test: {
39
- name: './animals.test.json',
40
- contents: animals_tests,
41
- checks: {
42
- context: defaultContextCheck,
43
- },
29
+ config: { name: 'animals' },
30
+ includes: [hierarchy],
44
31
 
32
+ module,
33
+ description: 'animals related concepts',
34
+ newWay: true,
35
+ test: {
36
+ name: './animals.test.json',
37
+ contents: animals_tests,
38
+ checks: {
39
+ context: defaultContextCheck,
45
40
  },
46
- template: {
47
- template,
48
- instance: animals_instance
49
- }
41
+
42
+ },
43
+ template: {
44
+ template,
45
+ instance: animals_instance
46
+ }
50
47
  })
@@ -0,0 +1,103 @@
1
+ const { knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
2
+ const gdefaults = require('./gdefaults.js')
3
+ const pos = require('./pos.js')
4
+ const { defaultContextCheck } = require('./helpers')
5
+ const tests = require('./articles.test.json')
6
+
7
+ let config = {
8
+ name: 'articles',
9
+ operators: [
10
+ "([thisitthat|])",
11
+ "([it])",
12
+ "([this])",
13
+ "([that])",
14
+ "([queryable])",
15
+ /*
16
+ "(<what> ([whatAble|]))",
17
+ "([what:optional])",
18
+ */
19
+ "(<the|> ([theAble]))",
20
+ "(<a|a,an> ([theAble|]))",
21
+ ],
22
+ bridges: [
23
+ // { id: "what", level: 0, optional: "{ ...next(operator), query: ['what'], determined: true }", bridge: "{ ...after, query: ['what'], modifiers: ['what'], what: operator }" },
24
+ // { id: "whatAble", level: 0, bridge: "{ ...next(operator) }" },
25
+ {
26
+ id: 'the',
27
+ level: 0,
28
+ bridge: '{ ...after[0], focusableForPhrase: true, pullFromContext: true, concept: true, wantsValue: true, determiner: "the", modifiers: append(["determiner"], after[0].modifiers)}'
29
+ },
30
+ {
31
+ id: "a",
32
+ level: 0,
33
+ // bridge: "{ ...after[0], pullFromContext: false, instance: true, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
34
+ bridge: "{ ...after[0], pullFromContext: false, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
35
+ },
36
+ { id: "queryable" },
37
+ {
38
+ id: "theAble",
39
+ children: ['noun'],
40
+ bridge: "{ ...next(operator) }"
41
+ },
42
+
43
+ {
44
+ id: "thisitthat",
45
+ level: 0,
46
+ isA: ['queryable'],
47
+ before: ['verby'],
48
+ bridge: "{ ...next(operator) }"
49
+ },
50
+ {
51
+ id: "it",
52
+ level: 0,
53
+ isA: ['thisitthat'],
54
+ bridge: "{ ...next(operator), pullFromContext: true, unknown: true, determined: true }"
55
+ },
56
+ {
57
+ id: "this",
58
+ level: 0,
59
+ isA: ['thisitthat'],
60
+ bridge: "{ ...next(operator), unknown: true, pullFromContext: true }"
61
+ },
62
+ {
63
+ id: "that",
64
+ level: 0,
65
+ isA: ['thisitthat'],
66
+ bridge: "{ ...next(operator), unknown: true, pullFromContext: true }"
67
+ },
68
+ ],
69
+ words: {
70
+ "literals": {
71
+ "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
72
+ }
73
+ },
74
+ hierarchy: [
75
+ ['it', 'pronoun'],
76
+ ['this', 'pronoun'],
77
+ // ['questionMark', 'isEd'],
78
+ ['a', 'articlePOS'],
79
+ ['the', 'articlePOS'],
80
+ ['it', 'queryable'],
81
+ // ['it', 'toAble'],
82
+ ['this', 'queryable'],
83
+ ],
84
+
85
+ };
86
+
87
+ knowledgeModule( {
88
+ config,
89
+ includes: [pos, gdefaults],
90
+
91
+ module,
92
+ description: 'articles',
93
+ newWay: true,
94
+ test: {
95
+ name: './articles.test.json',
96
+ contents: tests,
97
+ checks: {
98
+ objects: ['onNevermindWasCalled', 'nevermindType', 'idSuffix'],
99
+ context: defaultContextCheck,
100
+ },
101
+
102
+ },
103
+ })
@@ -0,0 +1,310 @@
1
+ [
2
+ {
3
+ "associations": [
4
+ [
5
+ [
6
+ "the",
7
+ 0
8
+ ],
9
+ [
10
+ "theAble",
11
+ 0
12
+ ]
13
+ ]
14
+ ],
15
+ "config": {
16
+ },
17
+ "contexts": [
18
+ {
19
+ "concept": true,
20
+ "dead": true,
21
+ "default": true,
22
+ "determiner": "the",
23
+ "focusableForPhrase": true,
24
+ "level": 1,
25
+ "marker": "theAble",
26
+ "modifiers": [
27
+ "determiner"
28
+ ],
29
+ "pullFromContext": true,
30
+ "range": {
31
+ "end": 10,
32
+ "start": 0
33
+ },
34
+ "text": "the theable",
35
+ "topLevel": true,
36
+ "types": [
37
+ "theAble"
38
+ ],
39
+ "value": "theAble",
40
+ "wantsValue": true,
41
+ "word": "theable"
42
+ }
43
+ ],
44
+ "developerTest": false,
45
+ "generatedParenthesized": [
46
+ ""
47
+ ],
48
+ "metadata": {
49
+ "opChoices": [
50
+ {
51
+ "counter": 1,
52
+ "op": [
53
+ "theAble",
54
+ 0
55
+ ],
56
+ "ops": [
57
+ [
58
+ "the",
59
+ 0
60
+ ],
61
+ [
62
+ "theAble",
63
+ 0
64
+ ]
65
+ ]
66
+ },
67
+ {
68
+ "counter": 2,
69
+ "op": [
70
+ "the",
71
+ 0
72
+ ],
73
+ "ops": [
74
+ [
75
+ "the",
76
+ 0
77
+ ]
78
+ ]
79
+ }
80
+ ]
81
+ },
82
+ "objects": {
83
+ "nameToUUID": {
84
+ "articles": "articles1",
85
+ "gdefaults": "gdefaults2",
86
+ "pos": "pos2",
87
+ "tokenize": "tokenize2"
88
+ },
89
+ "namespaced": {
90
+ "articles1": {
91
+ },
92
+ "gdefaults2": {
93
+ },
94
+ "pos2": {
95
+ },
96
+ "tokenize2": {
97
+ }
98
+ },
99
+ "processed": [
100
+ {
101
+ "context": {
102
+ "concept": true,
103
+ "dead": true,
104
+ "default": true,
105
+ "determiner": "the",
106
+ "focusableForPhrase": true,
107
+ "level": 1,
108
+ "marker": "theAble",
109
+ "modifiers": [
110
+ "determiner"
111
+ ],
112
+ "pullFromContext": true,
113
+ "range": {
114
+ "end": 10,
115
+ "start": 0
116
+ },
117
+ "text": "the theable",
118
+ "topLevel": true,
119
+ "types": [
120
+ "theAble"
121
+ ],
122
+ "value": "theAble",
123
+ "wantsValue": true,
124
+ "word": "theable"
125
+ },
126
+ "generatedParenthesized": "",
127
+ "paraphrases": "the theable",
128
+ "paraphrasesParenthesized": "(the (theable))",
129
+ "responses": [
130
+ ""
131
+ ]
132
+ }
133
+ ]
134
+ },
135
+ "paraphrases": [
136
+ "the theable"
137
+ ],
138
+ "paraphrasesParenthesized": [
139
+ "(the (theable))"
140
+ ],
141
+ "query": "the theable",
142
+ "responses": [
143
+ ""
144
+ ]
145
+ },
146
+ {
147
+ "associations": [
148
+ [
149
+ [
150
+ "a",
151
+ 0
152
+ ],
153
+ [
154
+ "theAble",
155
+ 0
156
+ ]
157
+ ]
158
+ ],
159
+ "config": {
160
+ },
161
+ "contexts": [
162
+ {
163
+ "concept": true,
164
+ "dead": true,
165
+ "default": true,
166
+ "determiner": {
167
+ "default": true,
168
+ "level": 0,
169
+ "marker": "a",
170
+ "range": {
171
+ "end": 0,
172
+ "start": 0
173
+ },
174
+ "text": "a",
175
+ "word": "a"
176
+ },
177
+ "level": 1,
178
+ "marker": "theAble",
179
+ "modifiers": [
180
+ "determiner"
181
+ ],
182
+ "number": "one",
183
+ "pullFromContext": false,
184
+ "range": {
185
+ "end": 8,
186
+ "start": 0
187
+ },
188
+ "text": "a theable",
189
+ "topLevel": true,
190
+ "types": [
191
+ "theAble"
192
+ ],
193
+ "value": "theAble",
194
+ "wantsValue": true,
195
+ "word": "theable"
196
+ }
197
+ ],
198
+ "developerTest": false,
199
+ "generatedParenthesized": [
200
+ ""
201
+ ],
202
+ "metadata": {
203
+ "opChoices": [
204
+ {
205
+ "counter": 1,
206
+ "op": [
207
+ "theAble",
208
+ 0
209
+ ],
210
+ "ops": [
211
+ [
212
+ "a",
213
+ 0
214
+ ],
215
+ [
216
+ "theAble",
217
+ 0
218
+ ]
219
+ ]
220
+ },
221
+ {
222
+ "counter": 2,
223
+ "op": [
224
+ "a",
225
+ 0
226
+ ],
227
+ "ops": [
228
+ [
229
+ "a",
230
+ 0
231
+ ]
232
+ ]
233
+ }
234
+ ]
235
+ },
236
+ "objects": {
237
+ "nameToUUID": {
238
+ "articles": "articles1",
239
+ "gdefaults": "gdefaults2",
240
+ "pos": "pos2",
241
+ "tokenize": "tokenize2"
242
+ },
243
+ "namespaced": {
244
+ "articles1": {
245
+ },
246
+ "gdefaults2": {
247
+ },
248
+ "pos2": {
249
+ },
250
+ "tokenize2": {
251
+ }
252
+ },
253
+ "processed": [
254
+ {
255
+ "context": {
256
+ "concept": true,
257
+ "dead": true,
258
+ "default": true,
259
+ "determiner": {
260
+ "default": true,
261
+ "level": 0,
262
+ "marker": "a",
263
+ "range": {
264
+ "end": 0,
265
+ "start": 0
266
+ },
267
+ "text": "a",
268
+ "word": "a"
269
+ },
270
+ "level": 1,
271
+ "marker": "theAble",
272
+ "modifiers": [
273
+ "determiner"
274
+ ],
275
+ "number": "one",
276
+ "pullFromContext": false,
277
+ "range": {
278
+ "end": 8,
279
+ "start": 0
280
+ },
281
+ "text": "a theable",
282
+ "topLevel": true,
283
+ "types": [
284
+ "theAble"
285
+ ],
286
+ "value": "theAble",
287
+ "wantsValue": true,
288
+ "word": "theable"
289
+ },
290
+ "generatedParenthesized": "",
291
+ "paraphrases": "a theable",
292
+ "paraphrasesParenthesized": "((a) (theable))",
293
+ "responses": [
294
+ ""
295
+ ]
296
+ }
297
+ ]
298
+ },
299
+ "paraphrases": [
300
+ "a theable"
301
+ ],
302
+ "paraphrasesParenthesized": [
303
+ "((a) (theable))"
304
+ ],
305
+ "query": "a theable",
306
+ "responses": [
307
+ ""
308
+ ]
309
+ }
310
+ ]
package/common/avatar.js CHANGED
@@ -1,11 +1,11 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require('./dialogues')
4
4
  const hierarchy = require('./hierarchy')
5
5
  const emotions = require('./emotions')
6
6
  const avatar_tests = require('./avatar.test.json')
7
7
 
8
- let configStruct = {
8
+ let config = {
9
9
  name: 'avatar',
10
10
 
11
11
  // TODO make different response for answerNotKnown based on emotions
@@ -68,16 +68,12 @@ let configStruct = {
68
68
 
69
69
  };
70
70
 
71
- const createConfig = () => {
72
- const config = new Config(configStruct, module)
73
- config.add(hierarchy(), emotions())
74
- return config
75
- }
76
-
77
71
  knowledgeModule( {
72
+ config,
73
+ includes: [hierarchy, emotions],
74
+
78
75
  module,
79
76
  description: 'avatar for dialogues',
80
- createConfig,
81
77
  test: {
82
78
  name: './avatar.test.json',
83
79
  contents: avatar_tests,
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, process:clientProcess } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const gdefaults = require('./gdefaults.js')
4
4
  const createCurrencyKM = require('./currency.js')
@@ -28,7 +28,7 @@ const getHelp = (config, indent=2) => {
28
28
  -> get response back: sally said: blah
29
29
  */
30
30
 
31
- let configStruct = {
31
+ let config = {
32
32
  name: 'characters',
33
33
 
34
34
  operators: [
@@ -126,7 +126,8 @@ class Sally {
126
126
  }
127
127
  */
128
128
  this.timeKM.server(config.getServer(), config.getAPIKey())
129
- return this.timeKM.process(utterance)
129
+ // return this.timeKM.process(utterance)
130
+ return clientProcess(this.timeKM, utterance)
130
131
  }
131
132
 
132
133
  response({context, result}) {
@@ -150,7 +151,9 @@ class Bob {
150
151
 
151
152
  process(config, utterance) {
152
153
  this.currencyKM.server(config.getServer(), config.getAPIKey())
153
- return this.currencyKM.process(utterance, { credentials: this.credentials })
154
+ // return this.currencyKM.process(utterance, { credentials: this.credentials })
155
+ // return clientProcess(this.currencyKM.process, utterance, { credentials: this.credentials })
156
+ return clientProcess(this.currencyKM, utterance)
154
157
  }
155
158
 
156
159
  response({context, result}) {
@@ -173,36 +176,27 @@ const initializeApi = (config, api) => {
173
176
  }
174
177
 
175
178
 
176
- const createConfig = () => {
177
- const timeKM = createTimeKM()
178
- const currencyKM = createCurrencyKM()
179
- const api = new Sally(timeKM)
180
- const api2 = new Bob(currencyKM)
181
-
182
- const config = new Config(configStruct, module)
183
- config.stop_auto_rebuild()
184
- config.add(gdefaults())
185
-
186
- config.multiApi = initializeApi
187
- config.initializer( ({isModule, config, km}) => {
188
- if (!isModule) {
189
- // config.api = api2
190
- // config.api = api
191
- const config = km('characters')
192
- config.api = api2
193
- config.api = api
194
- }
195
- })
196
- config.restart_auto_rebuild()
197
- return config
179
+ const initializer = async ({isModule, km}) => {
180
+ if (!isModule) {
181
+ const timeKM = await createTimeKM()
182
+ const currencyKM = await createCurrencyKM()
183
+ const config = km('characters')
184
+ const api = new Sally(timeKM)
185
+ const api2 = new Bob(currencyKM)
186
+ await config.setApi(() => api2)
187
+ await config.setApi(() => api)
188
+ }
198
189
  }
199
-
200
190
  // mode this to non-module init only
201
191
  knowledgeModule({
192
+ config,
193
+ includes: [gdefaults],
194
+ initializer,
195
+ multiApiInitializer: initializeApi,
196
+
202
197
  module,
203
198
  description: 'this module is for creating a team of characters that can respond to commands',
204
199
  demo: "https://youtu.be/eA25GZ0ZAHo",
205
- createConfig,
206
200
  test: {
207
201
  name: './characters.test.json',
208
202
  contents: characters_tests,