ekms 8.0.0-beta.42 → 8.0.0-beta.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/common/animals.js +17 -20
  2. package/common/articles.js +6 -11
  3. package/common/avatar.js +5 -9
  4. package/common/characters.js +22 -26
  5. package/common/colors.instance.json +28 -0
  6. package/common/colors.js +4 -8
  7. package/common/comparable.js +5 -9
  8. package/common/concept.js +120 -124
  9. package/common/countable.js +5 -9
  10. package/common/crew.js +36 -41
  11. package/common/currency.js +25 -43
  12. package/common/dialogues.js +46 -49
  13. package/common/dimension.instance.json +8 -8
  14. package/common/dimension.js +7 -13
  15. package/common/edible.instance.json +112 -0
  16. package/common/edible.js +3 -8
  17. package/common/emotions.js +35 -38
  18. package/common/evaluate.js +5 -11
  19. package/common/events.js +6 -10
  20. package/common/fastfood.instance.json +401 -317
  21. package/common/fastfood.js +53 -63
  22. package/common/formulas.instance.json +10 -10
  23. package/common/formulas.js +7 -14
  24. package/common/gdefaults.js +8 -10
  25. package/common/help.js +7 -12
  26. package/common/hierarchy.js +8 -12
  27. package/common/javascript.js +7 -14
  28. package/common/kirk.js +5 -8
  29. package/common/length.js +4 -8
  30. package/common/listener.js +5 -11
  31. package/common/math.instance.json +16 -16
  32. package/common/math.js +6 -10
  33. package/common/meta.js +5 -22
  34. package/common/nameable.js +6 -13
  35. package/common/negation.js +5 -5
  36. package/common/numbers.js +5 -9
  37. package/common/ordering.instance.json +68 -0
  38. package/common/ordering.js +80 -86
  39. package/common/people.js +8 -12
  40. package/common/percentages.js +5 -9
  41. package/common/pipboy.instance.json +84 -28
  42. package/common/pipboy.js +7 -15
  43. package/common/pokemon.js +7 -20
  44. package/common/pos.js +4 -5
  45. package/common/pressure.js +4 -8
  46. package/common/properties.js +6 -12
  47. package/common/punctuation.js +5 -5
  48. package/common/reports.instance.json +1 -1
  49. package/common/reports.js +9 -14
  50. package/common/scorekeeper.js +8 -12
  51. package/common/sdefaults.js +4 -5
  52. package/common/sizeable.js +5 -9
  53. package/common/spock.js +5 -8
  54. package/common/stgame.js +18 -23
  55. package/common/stm.js +9 -15
  56. package/common/tell.js +9 -13
  57. package/common/temperature.instance.json +0 -112
  58. package/common/temperature.js +4 -8
  59. package/common/tester.js +1 -1
  60. package/common/testing.js +5 -9
  61. package/common/time.js +18 -23
  62. package/common/tokenize.js +4 -5
  63. package/common/ui.js +6 -12
  64. package/common/weight.js +4 -8
  65. package/common/yesno.js +5 -5
  66. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, ensureTestFile, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, ensureTestFile, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck, propertyToArray } = require('./helpers')
3
3
  const edible = require('./edible')
4
4
  const events = require('./events')
@@ -935,75 +935,65 @@ class State {
935
935
  }
936
936
  }
937
937
 
938
- const createConfig = async (additionalConfig) => {
939
- const config = new Config({
940
- name: 'fastfood',
941
- operators: [
942
- "([orderNoun|order])",
943
- "([showOrder|show] ([orderNoun/1]))",
944
- ],
945
- // flatten: ['list'],
946
- // TODO use node naming not python
947
- semantics: [
948
- {
949
- where: where(),
950
- priority: -10,
951
- match: ({context}) => context.marker == 'compound_operator',
952
- apply: async ({context, s}) => {
953
- context.marker = 'list'
954
- context.flatten = true
955
- await s(context)
956
- }
957
- },
958
- {
959
- where: where(),
960
- match: ({context, isAListable}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !context.evaluate,
961
- apply: ({context, km, api, instance}) => {
962
- for (const element of propertyToArray(context)) {
963
- km('fastfood').api.state.add(element)
964
- }
965
- }
966
- },
967
- ],
968
- floaters: ['quantity'],
969
- bridges: [
970
- {
971
- id: 'orderNoun',
972
- parents: ['noun', 'queryable'],
973
- evaluator: ({context, api}) => {
974
- context.evalue = { marker: 'list', value: api.objects.items }
975
- api.show()
938
+ const config = {
939
+ name: 'fastfood',
940
+ operators: [
941
+ "([orderNoun|order])",
942
+ "([showOrder|show] ([orderNoun/1]))",
943
+ ],
944
+ // flatten: ['list'],
945
+ // TODO use node naming not python
946
+ semantics: [
947
+ {
948
+ where: where(),
949
+ priority: -10,
950
+ match: ({context}) => context.marker == 'compound_operator',
951
+ apply: async ({context, s}) => {
952
+ context.marker = 'list'
953
+ context.flatten = true
954
+ await s(context)
955
+ }
956
+ },
957
+ {
958
+ where: where(),
959
+ match: ({context, isAListable}) => isAListable(context, 'edible') && context.marker !== 'edible' && !context.same && !context.isResponse && !context.evaluate,
960
+ apply: ({context, km, api, instance}) => {
961
+ for (const element of propertyToArray(context)) {
962
+ km('fastfood').api.state.add(element)
976
963
  }
964
+ }
965
+ },
966
+ ],
967
+ floaters: ['quantity'],
968
+ bridges: [
969
+ {
970
+ id: 'orderNoun',
971
+ parents: ['noun', 'queryable'],
972
+ evaluator: ({context, api}) => {
973
+ context.evalue = { marker: 'list', value: api.objects.items }
974
+ api.show()
975
+ }
976
+ },
977
+ {
978
+ id: 'showOrder',
979
+ parents: ['verby'],
980
+ bridge: "{ ...next(operator), order: after[0] }",
981
+ generatorp: async ({context, g}) => `show ${await g(context.order)}`,
982
+ semantic: ({api}) => {
983
+ api.state.show()
977
984
  },
978
- {
979
- id: 'showOrder',
980
- parents: ['verby'],
981
- bridge: "{ ...next(operator), order: after[0] }",
982
- generatorp: async ({context, g}) => `show ${await g(context.order)}`,
983
- semantic: ({api}) => {
984
- api.state.show()
985
- },
986
- },
987
- ],
988
- }, module)
989
- config.stop_auto_rebuild()
990
- await config.add(edible, countable, events, sizeable)
991
- await config.setApi(api)
992
- await config.initializer( ({api}) => {
993
- api.state = new State(api)
994
- })
995
- if (additionalConfig) {
996
- additionalConfig(config)
997
- }
998
- await config.restart_auto_rebuild()
999
- return config
985
+ },
986
+ ],
1000
987
  }
1001
988
 
1002
989
  knowledgeModule( {
990
+ config,
991
+ includes: [edible, countable, events, sizeable],
992
+ api: () => new API(),
993
+ initializer: ({api}) => { api.state = new State(api) },
994
+
1003
995
  module,
1004
996
  description: 'fastfood related concepts',
1005
- createConfig,
1006
- acceptsAdditionalConfig: true,
1007
997
  test: {
1008
998
  name: './fastfood.test.json',
1009
999
  contents: fastfood_tests,
@@ -29,14 +29,14 @@
29
29
  ],
30
30
  "semantics": [
31
31
  {
32
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:109",
32
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
33
33
  "match": "({context, api}) => context.evaluate && api.get(context)",
34
34
  "apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n // console.log('greg24 -----------', JSON.stringify(formula, null, 2))\n context.evalue = await e(formula) \n }"
35
35
  }
36
36
  ],
37
37
  "bridges": [
38
38
  {
39
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:120",
39
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
40
40
  "id": "formulaForVariable",
41
41
  "isA": [
42
42
  "preposition",
@@ -48,7 +48,7 @@
48
48
  "evaluator": "({context, api, objects}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n context.evalue = { marker: 'list', value: formulas }\n }"
49
49
  },
50
50
  {
51
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:132",
51
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
52
52
  "id": "solve",
53
53
  "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }",
54
54
  "generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`",
@@ -74,7 +74,7 @@
74
74
  ]
75
75
  },
76
76
  {
77
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:159",
77
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
78
78
  "id": "calculate",
79
79
  "isA": [
80
80
  "verby"
@@ -90,7 +90,7 @@
90
90
  "semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression)\n context.isResponse = true\n }"
91
91
  },
92
92
  {
93
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:171",
93
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
94
94
  "id": "equals",
95
95
  "bridge": "{ ...next(operator), left: before[0], right: after[0] }",
96
96
  "words": [
@@ -868,12 +868,12 @@
868
868
  ],
869
869
  "semantics": [
870
870
  {
871
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:109"
871
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5"
872
872
  }
873
873
  ],
874
874
  "bridges": [
875
875
  {
876
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:120",
876
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
877
877
  "id": "formulaForVariable",
878
878
  "isA": [
879
879
  "preposition",
@@ -883,7 +883,7 @@
883
883
  "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }"
884
884
  },
885
885
  {
886
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:132",
886
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
887
887
  "id": "solve",
888
888
  "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }"
889
889
  },
@@ -907,7 +907,7 @@
907
907
  ]
908
908
  },
909
909
  {
910
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:159",
910
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
911
911
  "id": "calculate",
912
912
  "isA": [
913
913
  "verby"
@@ -921,7 +921,7 @@
921
921
  ]
922
922
  },
923
923
  {
924
- "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:171",
924
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
925
925
  "id": "equals",
926
926
  "bridge": "{ ...next(operator), left: before[0], right: after[0] }",
927
927
  "words": [
@@ -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 dialogues = require('./dialogues.js')
4
4
  const pos = require('./pos.js')
@@ -91,7 +91,7 @@ class API {
91
91
  }
92
92
  */
93
93
 
94
- let configStruct = {
94
+ let config = {
95
95
  name: 'formulas',
96
96
  operators: [
97
97
  // TODO notations like (([arg1:]) [op] ([arg2:nameOfArg2}|word1])) -> just make the bridge + operators. put this in the bridge def / also calculate generators
@@ -188,24 +188,17 @@ let configStruct = {
188
188
  const template = {
189
189
  configs: [
190
190
  "formulas are concepts",
191
- configStruct,
191
+ config,
192
192
  ]
193
193
  }
194
194
 
195
- const createConfig = async () => {
196
- const api = new API()
197
- config = new Config({ name: 'formulas' }, module)
198
- config.stop_auto_rebuild()
199
- await config.add(dialogues, pos, math, hierarchy, comparable, countable)
200
- await config.setApi(api)
201
- await config.restart_auto_rebuild()
202
- return config
203
- }
204
-
205
195
  knowledgeModule({
196
+ config: { name: 'formulas' },
197
+ includes: [dialogues, pos, math, hierarchy, comparable, countable],
198
+ api: () => new API(),
199
+
206
200
  module,
207
201
  description: 'Formulas using math',
208
- createConfig,
209
202
  template: { template, instance },
210
203
  test: {
211
204
  name: './formulas.test.json',
@@ -1,11 +1,11 @@
1
1
  const pluralize = require('pluralize')
2
2
  const { defaultContextCheck } = require('./helpers')
3
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
3
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
5
  const gdefaults_tests = require('./gdefaults.test.json')
6
6
  const { isMany } = require('./helpers.js')
7
7
 
8
- let configStruct = {
8
+ let config = {
9
9
  name: 'gdefaults',
10
10
  generators: [
11
11
  /* TODO save for later
@@ -181,10 +181,7 @@ let configStruct = {
181
181
  ],
182
182
  };
183
183
 
184
- const createConfig = async () => {
185
- const config = new Config(configStruct, module)
186
- await config.add(tokenize)
187
- await config.initializer( ({config}) => {
184
+ const initializer = ({config}) => {
188
185
  config.addArgs((args) => {
189
186
  return {
190
187
  number: (context) => isMany(context) ? "many" : "one",
@@ -198,14 +195,15 @@ const createConfig = async () => {
198
195
  },
199
196
  }
200
197
  })
201
- })
202
- return config
203
- }
198
+ }
204
199
 
205
200
  knowledgeModule({
201
+ config,
202
+ includes: [tokenize],
203
+ initializer,
204
+
206
205
  module,
207
206
  description: 'defaults for generators',
208
- createConfig,
209
207
  test: {
210
208
  name: './gdefaults.test.json',
211
209
  contents: gdefaults_tests,
package/common/help.js CHANGED
@@ -22,7 +22,7 @@ const getHelp = (config, indent=2) => {
22
22
  return help
23
23
  }
24
24
 
25
- const configStruct = {
25
+ const config = {
26
26
  name: 'help',
27
27
  operators: [
28
28
  "([help] ([withKM|with] ([km]))?)",
@@ -82,12 +82,7 @@ const configStruct = {
82
82
  },
83
83
  };
84
84
 
85
- const createConfig = async () => {
86
- const config = new Config(configStruct, module)
87
- config.stop_auto_rebuild()
88
- await config.add(dialogues)
89
-
90
- await config.initializer( ({ config, addWord, kms }) => {
85
+ const initializer = ({ config, addWord, kms }) => {
91
86
  const names = new Set()
92
87
  for (let name in kms) {
93
88
  names.add(name);
@@ -95,15 +90,15 @@ const createConfig = async () => {
95
90
  for (let name of names) {
96
91
  addWord(name, {id: "km", initial: `{ value: '${name}', word: '${name}' }`})
97
92
  }
98
- })
99
- await config.restart_auto_rebuild()
100
- return config
101
- }
93
+ }
102
94
 
103
95
  knowledgeModule({
96
+ config,
97
+ includes: [dialogues],
98
+ initializer,
99
+
104
100
  module,
105
101
  description: 'Help the user with the current knowledge modules',
106
- createConfig,
107
102
  test: {
108
103
  name: './help.test.json',
109
104
  contents: help_tests,
@@ -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 properties = require('./properties')
4
4
  const hierarchy_tests = require('./hierarchy.test.json')
@@ -32,7 +32,7 @@ const getTypes = ( km, concept, instance ) => {
32
32
 
33
33
  // TODO the types of rank are x y z ....
34
34
  // TODO x is a kind of y
35
- let configStruct = {
35
+ let config = {
36
36
  name: 'hierarchy',
37
37
  operators: [
38
38
  // "([hierarchyAble|])",
@@ -284,23 +284,19 @@ let configStruct = {
284
284
  ]
285
285
  };
286
286
 
287
- const createConfig = async () => {
288
- const config = new Config(configStruct, module)
289
- config.stop_auto_rebuild()
290
- await config.add(properties)
291
- await config.initializer( ({apis, hierarchy}) => {
287
+ const initializer = ({apis, hierarchy}) => {
292
288
  apis('stm').addIsA( (child, parent) => {
293
289
  return hierarchy.isA(child, parent)
294
290
  })
295
- })
296
- await config.restart_auto_rebuild()
297
- return config
298
- }
291
+ }
299
292
 
300
293
  knowledgeModule( {
294
+ config,
295
+ includes: [properties],
296
+ initializer,
297
+
301
298
  module,
302
299
  description: 'hierarchy of objects',
303
- createConfig,
304
300
  test: {
305
301
  name: './hierarchy.test.json',
306
302
  contents: hierarchy_tests,
@@ -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 dialogues = require('./dialogues')
4
4
  const javascript_tests = require('./javascript.test.json')
5
5
 
6
- let configStruct = {
6
+ let config = {
7
7
  name: 'javascript',
8
8
  operators: [
9
9
  "((<let> ([variable|])) [assignment|] (value))",
@@ -60,22 +60,15 @@ let configStruct = {
60
60
  ],
61
61
  };
62
62
 
63
- const createConfig = async () => {
64
- const config = new Config(configStruct, module)
65
- config.stop_auto_rebuild()
66
- await config.add(dialogues)
67
-
68
- await config.initializer( ({objects, uuid}) => {
63
+ knowledgeModule( {
64
+ config,
65
+ includes: [dialogues],
66
+ initializer: ({objects, uuid}) => {
69
67
  objects.variables = {}
70
- })
71
- await config.restart_auto_rebuild()
72
- return config
73
- }
68
+ },
74
69
 
75
- knowledgeModule( {
76
70
  module,
77
71
  description: 'javascript interpreter',
78
- createConfig,
79
72
  test: {
80
73
  name: './javascript.test.json',
81
74
  contents: javascript_tests,
package/common/kirk.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 crew = require('./crew')
4
4
  const kirk_tests = require('./kirk.test.json')
@@ -14,18 +14,15 @@ const template = {
14
14
  // TODO what is the name of you
15
15
  // TODO crew members -> who are the crew members
16
16
 
17
- const createConfig = async () => {
18
- const config = new Config({ name: 'kirk', }, module)
19
- await config.add(crew)
20
- return config
21
- }
22
-
23
17
  kirk_instance.base = 'crew'
18
+
24
19
  // config.load(template, kirk_instance)
25
20
  knowledgeModule( {
21
+ config: { name: 'kirk', },
22
+ includes: [crew],
23
+
26
24
  module,
27
25
  description: 'Captain Kirk Simulator using a KM template',
28
- createConfig,
29
26
  test: {
30
27
  name: './kirk.test.json',
31
28
  contents: kirk_tests,
package/common/length.js CHANGED
@@ -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 length_tests = require('./length.test.json')
@@ -36,16 +36,12 @@ const template = {
36
36
  ],
37
37
  }
38
38
 
39
- const createConfig = async () => {
40
- const config = new Config({ name: 'length' }, module)
41
- await config.add(dimension)
42
- return config
43
- }
44
-
45
39
  knowledgeModule({
40
+ config: { name: 'length' },
41
+ includes: [dimension],
42
+
46
43
  module,
47
44
  description: 'Length dimension',
48
- createConfig,
49
45
  test: {
50
46
  name: './length.test.json',
51
47
  contents: length_tests,
@@ -1,10 +1,10 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const helpers = require('./helpers')
4
4
  const gdefaults = require('./gdefaults')
5
5
  const listener_tests = require('./listener.test.json')
6
6
 
7
- const configStruct = {
7
+ const config = {
8
8
  name: 'listener',
9
9
  operators: [
10
10
  { pattern: "([call])", development: true },
@@ -31,18 +31,12 @@ const configStruct = {
31
31
  ],
32
32
  }
33
33
 
34
- let createConfig = async () => {
35
- const config = new Config(configStruct, module)
36
- config.stop_auto_rebuild()
37
- await config.add(gdefaults)
38
- await config.restart_auto_rebuild()
39
- return config
40
- }
41
-
42
34
  knowledgeModule( {
35
+ config,
36
+ includes: [gdefaults],
37
+
43
38
  module,
44
39
  description: 'test of listeners',
45
- createConfig,
46
40
  test: {
47
41
  name: './listener.test.json',
48
42
  contents: listener_tests,