ekms 8.0.0-beta.5 → 8.0.0-beta.51

Sign up to get free protection for your applications and to get access to all the features.
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 +54 -62
  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 +57 -134
  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
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dimension = require('./dimension.js')
4
4
  const temperature_tests = require('./temperature.test.json')
@@ -14,16 +14,12 @@ const template = {
14
14
  ],
15
15
  }
16
16
 
17
- const createConfig = () => {
18
- const config = new Config({ name: 'temperature' }, module)
19
- config.add(dimension())
20
- return config
21
- }
22
-
23
17
  knowledgeModule({
18
+ config: { name: 'temperature' },
19
+ includes: [dimension],
20
+
24
21
  module,
25
22
  description: 'Weight dimension',
26
- createConfig,
27
23
  test: {
28
24
  name: './temperature.test.json',
29
25
  contents: temperature_tests,
package/common/tester.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const tester_tests = require('./tester.test.json')
4
4
  const ArgumentParser = require('argparse').ArgumentParser
@@ -12,7 +12,7 @@ const [args, unknown] = parser.parse_known_args()
12
12
 
13
13
  process.argv = [process.argv[0], process.argv[1], ...unknown]
14
14
 
15
- const createConfig = () => {
15
+ const createConfig = async () => {
16
16
  const config = new Config({ name: 'tester' })
17
17
  global.theprogrammablemind = {
18
18
  loadForTesting: {}
@@ -21,7 +21,7 @@ const createConfig = () => {
21
21
  global.theprogrammablemind.loadForTesting[module] = true
22
22
  const km = require(`./${module}`)
23
23
  // km.rebuild({ isModule: false }) // load the usually defaults
24
- config.add(km())
24
+ await config.add(km)
25
25
  }
26
26
  return config
27
27
  }
package/common/testing.js CHANGED
@@ -1,9 +1,9 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const testing_tests = require('./testing.test.json')
4
4
  const gdefaults = require('./gdefaults')
5
5
 
6
- let configStruct = {
6
+ const config = {
7
7
  name: 'testing',
8
8
  operators: [
9
9
  { pattern: "([testingEvaluate] ([testingValue]))" },
@@ -13,9 +13,9 @@ let configStruct = {
13
13
  {
14
14
  where: where(),
15
15
  id: 'testingEvaluate',
16
- generatorp: ({context, g}) => `${context.word} ${g(context.value)}`,
17
- semantic: ({context, e}) => {
18
- context.evalue = e(context.value)
16
+ generatorp: async ({context, g}) => `${context.word} ${await g(context.value)}`,
17
+ semantic: async ({context, e}) => {
18
+ context.evalue = await e(context.value)
19
19
  context.isResponse = true
20
20
  },
21
21
  bridge: "{ ...next(operator), value: after[0] }",
@@ -30,16 +30,12 @@ let configStruct = {
30
30
  ],
31
31
  };
32
32
 
33
- const createConfig = () => {
34
- const config = new Config(configStruct, module)
35
- config.add(gdefaults())
36
- return config
37
- }
38
-
39
33
  knowledgeModule({
34
+ config,
35
+ includes: [gdefaults],
36
+
40
37
  module,
41
38
  description: 'code for testing',
42
- createConfig,
43
39
  test: {
44
40
  name: './testing.test.json',
45
41
  contents: testing_tests
package/common/time.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const tell = require('./tell')
4
4
  const countable = require('./countable')
@@ -14,7 +14,7 @@ const pad = (v, l) => {
14
14
 
15
15
  class API {
16
16
  // gets the contexts for doing the happening
17
- semantics({context, isModule, args, kms}) {
17
+ semantics({context, args, kms}) {
18
18
  const api = kms.time.api
19
19
  const values = args({ types: ['ampm', 'time'], properties: ['one', 'two'] })
20
20
  const ampm = context[values[0]]
@@ -36,9 +36,8 @@ class API {
36
36
  initialize() {
37
37
  }
38
38
  }
39
- const api = new API()
40
39
 
41
- const configStruct = {
40
+ const config = {
42
41
  name: 'time',
43
42
  operators: [
44
43
  "([time])",
@@ -103,12 +102,12 @@ const configStruct = {
103
102
  {
104
103
  where: where(),
105
104
  match: ({context}) => context.marker == 'ampm' && context.paraphrase,
106
- apply: ({g, context, gp}) => `${gp(context.hour)} ${context.ampm}`
105
+ apply: async ({g, context, gp}) => `${await gp(context.hour)} ${context.ampm}`
107
106
  },
108
107
  {
109
108
  where: where(),
110
109
  match: ({context}) => context.marker == 'time' && context.evalue && context.format == 12,
111
- apply: ({g, context}) => {
110
+ apply: ({context}) => {
112
111
  let hh = context.evalue.getHours();
113
112
  let ampm = 'am'
114
113
  if (hh > 12) {
@@ -170,31 +169,27 @@ const configStruct = {
170
169
  ],
171
170
  };
172
171
 
173
- const createConfig = () => {
174
- const config = new Config(configStruct, module)
175
- config.stop_auto_rebuild()
176
- config.add(tell()).add(numbers()).add(countable())
177
- config.api = api
178
- config.initializer( ({config, objects, kms, isModule}) => {
179
- if (!isModule) {
180
- kms.time.api.newDate = () => new Date("December 25, 1995 1:59:58 pm" )
181
- }
182
- Object.assign(objects, {
183
- format: 12 // or 24
184
- });
185
- config.addSemantic({
186
- match: ({context, hierarchy, args}) => context.happening && context.marker == 'is' && args({ types: ['ampm', 'time'], properties: ['one', 'two'] }),
187
- apply: api.semantics
188
- })
172
+ const initializer = ({api, config, objects, kms, isModule}) => {
173
+ if (!isModule) {
174
+ kms.time.api.newDate = () => new Date("December 25, 1995 1:59:58 pm" )
175
+ }
176
+ Object.assign(objects, {
177
+ format: 12 // or 24
178
+ });
179
+ config.addSemantic({
180
+ match: ({context, hierarchy, args}) => context.happening && context.marker == 'is' && args({ types: ['ampm', 'time'], properties: ['one', 'two'] }),
181
+ apply: api.semantics
189
182
  })
190
- config.restart_auto_rebuild()
191
- return config
192
183
  }
193
184
 
194
185
  knowledgeModule({
186
+ config,
187
+ includes: [tell, numbers, countable],
188
+ api: () => new API(),
189
+ initializer,
190
+
195
191
  module,
196
192
  description: 'Time related concepts',
197
- createConfig,
198
193
  test: {
199
194
  name: './time.test.json',
200
195
  contents: time_tests,
@@ -1,8 +1,8 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const tokenize_tests = require('./tokenize.test.json')
4
4
 
5
- let configStruct = {
5
+ const config = {
6
6
  name: 'tokenize',
7
7
  operators: [
8
8
  "([unknown])",
@@ -31,11 +31,10 @@ let configStruct = {
31
31
  },
32
32
  };
33
33
 
34
- createConfig = () => new Config(configStruct, module)
35
-
36
34
  knowledgeModule( {
35
+ config,
36
+
37
37
  module,
38
- createConfig,
39
38
  description: 'tokenize',
40
39
  test: {
41
40
  name: './tokenize.test.json',