tpmkms_4wp 8.0.0-beta.4 → 8.0.0-beta.40

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 (96) hide show
  1. package/common/animals.instance.json +2855 -1363
  2. package/common/animals.js +2 -2
  3. package/common/articles.js +108 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/avatar.js +2 -2
  6. package/common/characters.js +9 -11
  7. package/common/colors.instance.json +6980 -3523
  8. package/common/colors.js +2 -2
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.js +2 -15
  11. package/common/concept.js +17 -11
  12. package/common/countable.js +5 -5
  13. package/common/crew.instance.json +13032 -6570
  14. package/common/crew.js +4 -4
  15. package/common/crew.test.json +714 -452
  16. package/common/currency.js +7 -7
  17. package/common/dialogues.js +117 -238
  18. package/common/dimension.instance.json +265 -264
  19. package/common/dimension.js +13 -13
  20. package/common/dimension.test.json +446 -1640
  21. package/common/edible.instance.json +19910 -9988
  22. package/common/edible.js +2 -2
  23. package/common/emotions.instance.json +146 -128
  24. package/common/emotions.js +4 -4
  25. package/common/evaluate.instance.json +2 -0
  26. package/common/evaluate.js +55 -0
  27. package/common/evaluate.test.json +574 -0
  28. package/common/events.js +6 -6
  29. package/common/fastfood.instance.json +221110 -111293
  30. package/common/fastfood.js +25 -25
  31. package/common/formulas.instance.json +241 -255
  32. package/common/formulas.js +14 -14
  33. package/common/gdefaults.js +19 -19
  34. package/common/help.js +4 -4
  35. package/common/help.test.json +22 -22
  36. package/common/helpers/concept.js +9 -6
  37. package/common/helpers/dialogues.js +2 -3
  38. package/common/helpers/properties.js +48 -58
  39. package/common/helpers.js +1 -1
  40. package/common/hierarchy.js +12 -16
  41. package/common/javascript.js +8 -8
  42. package/common/kirk.instance.json +583 -289
  43. package/common/kirk.js +2 -2
  44. package/common/length.instance.json +5530 -4754
  45. package/common/length.js +2 -2
  46. package/common/math.instance.json +176 -1168
  47. package/common/math.js +11 -11
  48. package/common/meta.js +22 -29
  49. package/common/nameable.instance.json +2 -0
  50. package/common/nameable.js +136 -0
  51. package/common/nameable.test.json +2121 -0
  52. package/common/negation.instance.json +2 -0
  53. package/common/negation.js +38 -0
  54. package/common/negation.test.json +308 -0
  55. package/common/numbers.js +3 -3
  56. package/common/ordering.instance.json +340 -228
  57. package/common/ordering.js +5 -5
  58. package/common/people.instance.json +2066 -1014
  59. package/common/people.js +4 -5
  60. package/common/percentages.instance.json +2 -0
  61. package/common/percentages.js +57 -0
  62. package/common/percentages.test.json +751 -0
  63. package/common/pipboy.instance.json +7974 -6300
  64. package/common/pipboy.js +29 -32
  65. package/common/pokemon.instance.json +4207 -2069
  66. package/common/pokemon.js +4 -4
  67. package/common/pos.js +1 -1
  68. package/common/pressure.instance.json +1341 -1189
  69. package/common/pressure.js +2 -2
  70. package/common/properties.instance.json +130 -60
  71. package/common/properties.js +54 -125
  72. package/common/punctuation.js +2 -2
  73. package/common/reports.instance.json +595 -557
  74. package/common/reports.js +58 -76
  75. package/common/scorekeeper.js +14 -22
  76. package/common/sdefaults.js +13 -3
  77. package/common/sizeable.js +2 -2
  78. package/common/spock.instance.json +583 -289
  79. package/common/spock.js +2 -2
  80. package/common/stgame.js +13 -9
  81. package/common/stm.js +136 -19
  82. package/common/stm.test.json +1734 -1
  83. package/common/tell.js +10 -10
  84. package/common/temperature.instance.json +1484 -1204
  85. package/common/temperature.js +2 -2
  86. package/common/tester.js +2 -2
  87. package/common/testing.js +5 -5
  88. package/common/time.js +7 -7
  89. package/common/tokenize.js +1 -1
  90. package/common/ui.instance.json +257 -258
  91. package/common/ui.js +9 -9
  92. package/common/weight.instance.json +5212 -4233
  93. package/common/weight.js +2 -2
  94. package/common/yesno.js +1 -1
  95. package/main.js +57 -46
  96. package/package.json +24 -6
package/common/math.js CHANGED
@@ -33,22 +33,22 @@ const mathematicalOperator = (name, words, apply, before = []) => [
33
33
  id: `${name}Operator`, level: 0,
34
34
  bridge: `{ ...next(operator), marker: next(operator('${name}Expression')), types: lub(append(['mathematicalExpression'], operator.types, before[0].types, after[0].types)), value: null, x: before[0], y: after[0], number: 'one', isResponse: true, evaluate: true }` ,
35
35
  // bridge: `{ ...next(operator), marker: next(operator('${name}Expression')), value: null, x: before[0], y: after[0], number: 'one', isResponse: true, evaluate: true }` ,
36
- isA: ['mathematicalOperator'],
36
+ isA: ['mathematical_operator'],
37
37
  before,
38
38
  localHierarchy: [ ['unknown', 'number'] ],
39
39
  // levelSpecificHierarchy: [[1, 'mathematicalExpression']],
40
40
  words,
41
- generatorp: ({gp, context}) => context.word,
41
+ generatorp: ({context}) => context.word,
42
42
  },
43
43
  {
44
44
  where: where(),
45
45
  id: `${name}Expression`, level: 0,
46
46
  bridge: "{ ...next(operator) }" ,
47
47
  isA: ['mathematicalExpression'],
48
- generatorp: ({gp, context}) => `${gp(context.x)} ${context.word} ${gp(context.y)}`,
49
- evaluator: ({e, context}) => {
50
- const x = toValue(e(context.x))
51
- const y = toValue(e(context.y))
48
+ generatorp: async ({gp, context}) => `${await gp(context.x)} ${context.word} ${await gp(context.y)}`,
49
+ evaluator: async ({e, context}) => {
50
+ const x = toValue(await e(context.x))
51
+ const y = toValue(await e(context.y))
52
52
  if (!x || !y) {
53
53
  // context.evalue = { ...context, paraphrase: true, x: { ...context.x, value: x }, y: { ...context.y, value: y } }
54
54
  context.isResponse = false
@@ -73,7 +73,7 @@ let configStruct = {
73
73
  name: 'math',
74
74
  operators: [
75
75
  "([mathematicalExpression])",
76
- "([mathematicalOperator])",
76
+ "([mathematical_operator])",
77
77
  "(([number|]) [plusOperator] ([number|]))",
78
78
  "(([number|]) [minusOperator] ([number|]))",
79
79
  "(([number|]) [timesOperator] ([number|]))",
@@ -92,7 +92,7 @@ let configStruct = {
92
92
  isA: ['concept', 'number'],
93
93
  },
94
94
  {
95
- id: "mathematicalOperator",
95
+ id: "mathematical_operator",
96
96
  before: ['verby'],
97
97
  after: ['adjective'],
98
98
  },
@@ -108,14 +108,14 @@ let configStruct = {
108
108
  const template = {
109
109
  configs: [
110
110
  "mathematical modifies operator",
111
- "* + / and - are mathematical operators",
112
111
  configStruct,
112
+ // "* + / and - are mathematical operators",
113
113
  ]
114
114
  }
115
115
 
116
- const createConfig = () => {
116
+ const createConfig = async () => {
117
117
  const config = new Config({ name: 'math' }, module)
118
- config.add(numbers(), dialogues(), punctuation(), countable(), comparable())
118
+ await config.add(numbers, dialogues, punctuation, countable, comparable)
119
119
  return config
120
120
  }
121
121
 
package/common/meta.js CHANGED
@@ -130,8 +130,8 @@ let configStruct = {
130
130
  {
131
131
  where: where(),
132
132
  match: ({context}) => context.marker == 'orList' && context.paraphrase,
133
- apply: ({context, gs}) => {
134
- return gs(context.value, ', ', ' or ')
133
+ apply: async ({context, gs}) => {
134
+ return await gs(context.value, ', ', ' or ')
135
135
  },
136
136
  priority: -1,
137
137
  },
@@ -139,10 +139,8 @@ let configStruct = {
139
139
  priority: -1,
140
140
  where: where(),
141
141
  match: ({context}) => context.marker == 'means' && context.paraphrase,
142
- apply: ({context, g}) => {
143
- // const before = g({ ...context.from, paraphrase: true, debug: true})
144
- const before = g({ ...context.from, paraphrase: true})
145
- return `${g({ ...context.from, paraphrase: true})} means ${g(context.to)}`
142
+ apply: async ({context, g}) => {
143
+ return `${await g({ ...context.from, paraphrase: true})} means ${await g(context.to)}`
146
144
  }
147
145
  },
148
146
  {
@@ -160,8 +158,8 @@ let configStruct = {
160
158
  {
161
159
  where: where(),
162
160
  match: ({context}) => context.marker === 'if',
163
- apply: ({context, g}) => {
164
- return `if ${g(context.antecedant)} then ${g(context.consequence)}`
161
+ apply: async ({context, g}) => {
162
+ return `if ${await g(context.antecedant)} then ${await g(context.consequence)}`
165
163
  },
166
164
  priority: -1,
167
165
  },
@@ -182,10 +180,10 @@ let configStruct = {
182
180
  {
183
181
  where: where(),
184
182
  match: ({context}) => context.marker == 'orList',
185
- apply: ({context, s}) => {
183
+ apply: async ({context, s}) => {
186
184
  const response = []
187
185
  for (const value of context.value) {
188
- response.push(s(value))
186
+ response.push(await s(value))
189
187
  }
190
188
  context.evalue = {
191
189
  marker: 'orList',
@@ -205,7 +203,7 @@ let configStruct = {
205
203
  const apply = (DEFINITIONs, DERIVED) => {
206
204
  const mappingss = translationMappings(DEFINITIONs, DERIVED)
207
205
  const invertMappings = (mappings) => mappings.map( ({ from, to }) => { return { to: from, from: to } } )
208
- return ({context, s, g, config}) => {
206
+ return async ({context, s, config}) => {
209
207
  DEFINITIONs = _.cloneDeep(DEFINITIONs)
210
208
  //const mappings = mappingss[0]
211
209
  let toPrimes = []
@@ -215,8 +213,7 @@ let configStruct = {
215
213
  }
216
214
  // next move add debug arg to s and g
217
215
  TO.query = true
218
- toPrimes.push([s(TO), mappings])
219
- // toPrime = s(TO, { debug: { apply: true } })
216
+ toPrimes.push([await s(TO), mappings])
220
217
  }
221
218
 
222
219
  let hasResponse = false
@@ -271,7 +268,7 @@ let configStruct = {
271
268
  // match: match(context),
272
269
  where: where(),
273
270
  match: match(context),
274
- apply: apply(antecedants, _.cloneDeep(context.consequence)) ,
271
+ apply: apply(antecedants, _.cloneDeep(context.consequence)),
275
272
  }
276
273
  config.addSemantic(semantic)
277
274
  }
@@ -280,17 +277,14 @@ let configStruct = {
280
277
  notes: 'from means to where from is unknown',
281
278
  where: where(),
282
279
  match: ({context}) => context.marker == 'means' && context.from.marker == 'unknown',
283
- apply: ({config, context, kms, e, isTest}) => {
280
+ apply: async ({config, context, kms, e, isTest}) => {
284
281
  if (false && isTest) {
285
282
  return
286
283
  } else if (kms.dialogues) {
287
284
  if (context.to.value) {
288
285
  kms.stm.api.setVariable(context.from.value, context.to.value)
289
286
  } else {
290
- // config.addWord(context.from.word,
291
287
  kms.dialogues.api.makeObject({ context: context.from, types: context.to.types || [], config });
292
- // kms.dialogues.api.makeObject({ context: context.from, types: [], config });
293
- // const r = e(context.to)
294
288
  kms.stm.api.setVariable(context.from.value, context.to)
295
289
  }
296
290
  }
@@ -300,17 +294,17 @@ let configStruct = {
300
294
  notes: 'x means y where x and y have known markers',
301
295
  where: where(),
302
296
  match: ({context}) => context.marker == 'means',
303
- apply: ({config, context, g}) => {
297
+ apply: async ({config, context, g}) => {
304
298
  // setup the write semantic
305
299
  {
306
300
  const matchByMarker = (defContext) => ({context}) => context.marker == defContext.from.marker && !context.query && !context.objects
307
301
  const matchByValue = (defContext) => ({context}) => context.evalue == defContext.from.value && !context.query && !context.objects
308
- const apply = (mappings, TO) => ({context, s}) => {
302
+ const apply = (mappings, TO) => async ({context, s}) => {
309
303
  TO = _.cloneDeep(TO)
310
304
  for (let { from, to } of mappings) {
311
305
  hashIndexesSet(TO, to, hashIndexesGet(context, from))
312
306
  }
313
- toPrime = s(TO)
307
+ toPrime = await s(TO)
314
308
  context.result = toPrime.result
315
309
  }
316
310
  const mappings = translationMapping(context.from, context.to)
@@ -332,7 +326,7 @@ let configStruct = {
332
326
  {
333
327
  const matchByMarker = (defContext) => ({context, uuid}) => context.marker == defContext.from.marker && (context.query || context.evaluate) && !context[`disable${uuid}`]
334
328
  const matchByValue = (defContext) => ({context, uuid}) => context.value == defContext.from.value && (context.query || context.evaluate) && !context[`disable${uuid}`]
335
- const apply = (mappings, TO) => ({uuid, context, s, g, config}) => {
329
+ const apply = (mappings, TO) => async ({uuid, context, s, g, config}) => {
336
330
  TO = _.cloneDeep(TO)
337
331
  for (let { from, to } of mappings) {
338
332
  hashIndexesSet(TO, to, hashIndexesGet(context, from))
@@ -345,8 +339,7 @@ let configStruct = {
345
339
  TO.evaluate = context.evaluate
346
340
  }
347
341
  TO[`disable${uuid}`] = true
348
- // toPrime = s(TO, { debug: { apply: true } })
349
- toPrime = s(TO)
342
+ toPrime = await s(TO)
350
343
  if (context.query) {
351
344
  if (toPrime.evalue) {
352
345
  context.evalue = toPrime.evalue
@@ -359,7 +352,7 @@ let configStruct = {
359
352
  }
360
353
  const mappings = translationMapping(context.from, context.to)
361
354
  let match = matchByMarker(context)
362
- context.metaInfo = `The mapping from from the expression being defined "${g({...context.from, paraphrase: true})}" to the definition phrase "${g({...context.to, paraphrase: true})}" is ${JSON.stringify(mappings)}`
355
+ context.metaInfo = `The mapping from from the expression being defined "${await g({...context.from, paraphrase: true})}" to the definition phrase "${await g({...context.to, paraphrase: true})}" is ${JSON.stringify(mappings)}`
363
356
  if (context.from.value) {
364
357
  match = matchByValue(context)
365
358
  }
@@ -378,12 +371,12 @@ let configStruct = {
378
371
  ],
379
372
  };
380
373
 
381
- const createConfig = () => {
374
+ const createConfig = async () => {
382
375
  const config = new Config(configStruct, module)
383
376
  config.stop_auto_rebuild()
384
- config.add(gdefaults())
377
+ await config.add(gdefaults)
385
378
 
386
- config.initializer( ({config, addGenerator, isModule}) => {
379
+ await config.initializer( ({config, addGenerator, isModule}) => {
387
380
  if (!isModule) {
388
381
  addGenerator({
389
382
  where: where(),
@@ -393,7 +386,7 @@ const createConfig = () => {
393
386
  }
394
387
  })
395
388
 
396
- config.restart_auto_rebuild()
389
+ await config.restart_auto_rebuild()
397
390
  return config
398
391
  }
399
392
 
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -0,0 +1,136 @@
1
+ const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheck } = require('./helpers')
3
+ const helpers = require('./helpers')
4
+ const stm = require('./stm')
5
+ const nameable_tests = require('./nameable.test.json')
6
+
7
+ class API {
8
+ initialize({ objects, km, kms }) {
9
+ this.objects = objects
10
+ this.objects.named = {}
11
+ }
12
+
13
+ // report is a context
14
+ setName(context, name) {
15
+ if (!context.stm) {
16
+ context.stm = {}
17
+ }
18
+ if (!context.stm.names) {
19
+ context.stm.names = []
20
+ }
21
+ context.stm.names.push(name)
22
+ }
23
+
24
+ get(type, name) {
25
+ return this.args.kms.stm.api.mentions({
26
+ context: type,
27
+ condition: (context) => {
28
+ if (context.stm && context.stm.names) {
29
+ return context.stm.names.includes(name)
30
+ }
31
+ }
32
+ })
33
+ }
34
+
35
+ getNamesByType(type) {
36
+ const contexts = this.args.kms.stm.api.getByType(type)
37
+ const names = new Set()
38
+ for (const context of contexts) {
39
+ if (context.stm.names) {
40
+ for (const name of context.stm.names) {
41
+ names.add(name)
42
+ }
43
+ }
44
+ }
45
+ return [...names]
46
+ }
47
+
48
+ getNames() {
49
+ const current = this.current()
50
+ console.log('getReportNames current', JSON.stringify(current, null, 2))
51
+ return Object.keys(this.objects.namedReports).map( (name) => {
52
+ const selected = (current.names || []).includes(name)
53
+ return { name, selected, id: name }
54
+ })
55
+ }
56
+
57
+ setCurrent(name) {
58
+ const context = this.objects.named[name]
59
+ if (context) {
60
+ this.args.km('stm').api.mentioned({ context })
61
+ }
62
+ }
63
+ }
64
+
65
+ const api = new API()
66
+
67
+ const configStruct = {
68
+ name: 'nameable',
69
+ operators: [
70
+ "([call] ([nameable]) (name))",
71
+ { pattern: "([getNamesByType] (type))", development: true },
72
+ { pattern: "([m1])", development: true },
73
+ // { pattern: "([testPullFromContext] ([memorable]))", development: true }
74
+ ],
75
+ words: {
76
+ literals: {
77
+ // "m1": [{"id": "memorable", development: true, "initial": "{ value: 'm1' }" }],
78
+ // "m2": [{"id": "memorable", development: true, "initial": "{ value: 'm2' }" }],
79
+ },
80
+ },
81
+ bridges: [
82
+ {
83
+ id: 'm1',
84
+ isA: ['memorable', 'nameable'],
85
+ development: true,
86
+ },
87
+ {
88
+ id: 'getNamesByType',
89
+ development: true,
90
+ isA: ['verby'],
91
+ bridge: "{ ...next(operator), type: after[0] }",
92
+ semantic: async ({context, api}) => {
93
+ context.response = api.getNamesByType(context.type.value).join(" ")
94
+ context.isResponse = true
95
+ }
96
+ },
97
+ {
98
+ id: 'call',
99
+ isA: ['verby'],
100
+ bridge: "{ ...next(operator), nameable: after[0], name: after[1] }",
101
+ generatorp: async ({context, g}) => `call ${await g(context.nameable)} ${await g(context.name)}`,
102
+ semantic: async ({config, context, api, e}) => {
103
+ // TODO find report being referred to
104
+ const nameable = (await e(context.nameable)).evalue
105
+ const name = context.name.text
106
+ config.addWord(name, { id: nameable.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
107
+ api.setName(nameable, name)
108
+ }
109
+ },
110
+ { id: 'nameable', words: helpers.words('nameable')},
111
+ ]
112
+ }
113
+
114
+ let createConfig = async () => {
115
+ const config = new Config(configStruct, module)
116
+ config.stop_auto_rebuild()
117
+ await config.setApi(api)
118
+ await config.add(stm)
119
+
120
+ await config.restart_auto_rebuild()
121
+ return config
122
+ }
123
+
124
+ knowledgeModule( {
125
+ module,
126
+ description: 'namable objects',
127
+ createConfig,
128
+ test: {
129
+ name: './nameable.test.json',
130
+ contents: nameable_tests,
131
+ checks: {
132
+ context: [...defaultContextCheck, 'pullFromContext'],
133
+ objects: ['mentioned', { km: 'stm' }],
134
+ },
135
+ },
136
+ })