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
package/common/crew.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 avatar = require('./avatar')
4
4
  const animals = require('./animals')
@@ -37,53 +37,48 @@ const template = {
37
37
  ],
38
38
  };
39
39
 
40
- const createConfig = async () => {
41
- const config = new Config({ name: 'crew', }, module)
42
- config.stop_auto_rebuild()
43
- await config.add(avatar, animals)
44
- crew_instance.base = 'avatar'
45
- await config.initializer( ({config, apis}) => {
46
- const api = apis('properties')
47
- const conceptApi = apis('concept')
48
- // conceptApi.kindOfConcept({ config, modifiers: ['photon'], object: 'torpedo' })
49
- // conceptApi.kindOfConcept({ config, modifiers: ['crew'], object: 'member' })
50
- api.createActionPrefix({
51
- operator: 'arm',
52
- create: ['arm', 'weapon'],
53
- after: [{tag: 'weapon', id: 'weapon'}],
54
- config },
55
- /*
56
- ({context, km}) => {
57
- const value = {
58
- "marker": "unknown",
59
- "types": [
60
- "unknown"
61
- ],
62
- "unknown": true,
63
- "value": "armed",
64
- "word": "armed",
65
- "response": true
66
- }
67
- km("properties").api.setProperty(context.weapon.value, 'status', value, true)
40
+ const initializer = ({config, apis}) => {
41
+ const api = apis('properties')
42
+ const conceptApi = apis('concept')
43
+ // conceptApi.kindOfConcept({ config, modifiers: ['photon'], object: 'torpedo' })
44
+ // conceptApi.kindOfConcept({ config, modifiers: ['crew'], object: 'member' })
45
+ api.createActionPrefix({
46
+ operator: 'arm',
47
+ create: ['arm', 'weapon'],
48
+ after: [{tag: 'weapon', id: 'weapon'}],
49
+ config },
50
+ /*
51
+ ({context, km}) => {
52
+ const value = {
53
+ "marker": "unknown",
54
+ "types": [
55
+ "unknown"
56
+ ],
57
+ "unknown": true,
58
+ "value": "armed",
59
+ "word": "armed",
60
+ "response": true
68
61
  }
69
- */
70
- )
71
-
72
- api.createActionPrefix({
73
- operator: 'disarm',
74
- create: ['disarm'/*, 'weapon'*/],
75
- after: [{tag: 'weapon', id: 'weapon'}],
76
- config })
77
- })
78
- await config.restart_auto_rebuild()
79
- return config
62
+ km("properties").api.setProperty(context.weapon.value, 'status', value, true)
63
+ }
64
+ */
65
+ )
66
+
67
+ api.createActionPrefix({
68
+ operator: 'disarm',
69
+ create: ['disarm'/*, 'weapon'*/],
70
+ after: [{tag: 'weapon', id: 'weapon'}],
71
+ config })
80
72
  }
81
73
 
82
74
  // config.load(template, crew_instance)
83
75
  knowledgeModule( {
76
+ config: { name: 'crew', },
77
+ includes: [avatar, animals],
78
+ initializer,
79
+
84
80
  module,
85
81
  description: 'Knowledge about the enterprise and crew using a KM template',
86
- createConfig,
87
82
  test: {
88
83
  name: './crew.test.json',
89
84
  contents: crew_tests,
@@ -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 numbersKM = require('./numbers.js')
4
4
  const currency_tests = require('./currency.test.json')
@@ -40,7 +40,7 @@ class API {
40
40
 
41
41
  const api = new API()
42
42
 
43
- let configStruct = {
43
+ let config = {
44
44
  name: 'currency',
45
45
  operators: [
46
46
  "(([number]) [currency])",
@@ -90,52 +90,34 @@ let configStruct = {
90
90
  ],
91
91
  };
92
92
 
93
- const createConfig = async () => {
94
- const config = new Config(configStruct, module)
95
- config.stop_auto_rebuild()
96
- await config.add(numbersKM)
97
- await config.setApi(api)
98
- await config.initializer( ({config, objects, apis, addWord, addGenerator, baseConfig, uuid}) => {
99
- // const api = config.km('currency').api
100
- // const api = kms.currency.api
101
- const api = apis('currency')
102
- units = api.getUnits()
103
- for (word in units) {
104
- def = {"id": "currency", "initial": { units: units[word] }, uuid}
105
- addWord(word, def)
106
- }
107
- /*
108
- for (word in units) {
109
- words = config.get('words')
110
- def = {"id": "currency", "initial": { units: units[word] }, uuid}
111
- if (words[word]) {
112
- words[word].push(def)
113
- } else {
114
- words[word] = [def]
115
- }
116
- }
117
- */
118
-
119
- unitWords = api.getUnitWords();
120
- for (let words of unitWords) {
121
- addGenerator({
122
- match: ({context}) => context.marker == 'currency' && context.units == words.units && context.value == 1 && context.isAbstract,
123
- apply: ({context, g}) => words.one, uuid
124
- });
125
- addGenerator({
126
- match: ({context}) => context.marker == 'currency' && context.units == words.units && !isNaN(context.value) && (context.value != 1) && context.isAbstract,
127
- apply: ({context, g}) => words.many, uuid
128
- })
129
- }
130
- })
131
- await config.restart_auto_rebuild()
132
- return config
93
+ const initializer = ({config, objects, apis, addWord, addGenerator, baseConfig, uuid}) => {
94
+ const api = apis('currency')
95
+ units = api.getUnits()
96
+ for (word in units) {
97
+ def = {"id": "currency", "initial": { units: units[word] }, uuid}
98
+ addWord(word, def)
99
+ }
100
+ unitWords = api.getUnitWords();
101
+ for (let words of unitWords) {
102
+ addGenerator({
103
+ match: ({context}) => context.marker == 'currency' && context.units == words.units && context.value == 1 && context.isAbstract,
104
+ apply: ({context, g}) => words.one, uuid
105
+ });
106
+ addGenerator({
107
+ match: ({context}) => context.marker == 'currency' && context.units == words.units && !isNaN(context.value) && (context.value != 1) && context.isAbstract,
108
+ apply: ({context, g}) => words.many, uuid
109
+ })
110
+ }
133
111
  }
134
112
 
135
113
  knowledgeModule({
114
+ config,
115
+ includes: [numbersKM],
116
+ api: () => api,
117
+ initializer,
118
+
136
119
  module,
137
120
  description: 'Ways of specifying currency amount',
138
- createConfig,
139
121
  test: {
140
122
  name: './currency.test.json',
141
123
  contents: currency_tests,
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
2
2
  const meta = require('./meta.js')
3
3
  const gdefaults = require('./gdefaults.js')
4
4
  const sdefaults = require('./sdefaults.js')
@@ -35,7 +35,7 @@ const warningSameNotEvaluated = (log, one) => {
35
35
  }
36
36
 
37
37
  // TODO implement what / what did you say ...
38
- let configStruct = {
38
+ let config = {
39
39
  name: 'dialogues',
40
40
  operators: [
41
41
  "([makeObject] (word))",
@@ -897,59 +897,56 @@ const getAsk = (config) => (uuid) => {
897
897
  }
898
898
 
899
899
 
900
- const createConfig = async () => {
901
- const config = new Config(configStruct, module)
902
- config.stop_auto_rebuild()
903
- await config.setApi(api)
904
- await config.add(articles, gdefaults, sdefaults, pos, negation, stm, meta, punctuation)
905
- await config.initializer( ({objects, config, isModule}) => {
906
- /* TODO add this beck in. some stuff from config needs to be here
907
- config.addArgs((args) => ({
908
- e: (context) => config.api.getEvaluator(args.s, args.log, context),
909
- }))
910
- */
911
- config.addArgs(({config, api, isA}) => ({
912
- isAListable: (context, type) => {
913
- if (context.marker == 'list' || context.listable) {
914
- return context.value.every( (element) => isA(element.marker, type) )
915
- } else {
916
- return isA(context.marker, type)
917
- }
918
- },
919
- toContext: (v) => {
920
- if (Array.isArray(v)) {
921
- return { marker: 'list', level: 1, value: v }
922
- }
923
- if (v.marker == 'list') {
924
- return v
925
- }
900
+ const initializer = ({objects, config, isModule}) => {
901
+ /* TODO add this beck in. some stuff from config needs to be here
902
+ config.addArgs((args) => ({
903
+ e: (context) => config.api.getEvaluator(args.s, args.log, context),
904
+ }))
905
+ */
906
+ config.addArgs(({config, api, isA}) => ({
907
+ isAListable: (context, type) => {
908
+ if (context.marker == 'list' || context.listable) {
909
+ return context.value.every( (element) => isA(element.marker, type) )
910
+ } else {
911
+ return isA(context.marker, type)
912
+ }
913
+ },
914
+ toContext: (v) => {
915
+ if (Array.isArray(v)) {
916
+ return { marker: 'list', level: 1, value: v }
917
+ }
918
+ if (v.marker == 'list') {
926
919
  return v
927
- },
928
- getUUIDScoped: (uuid) => { return {
929
- ask: getAsk(config)(uuid),
930
- }
931
- },
932
- toScopedId: (context) => {
933
- return api('dialogues').toScopedId(context)
934
- },
935
- }))
936
- objects.mentioned = []
937
- objects.variables = {
938
- }
939
- if (isModule) {
940
- } else {
941
- config.addWord("canbedoquestion", { id: "canBeDoQuestion", "initial": "{}" })
942
- config.addWord("doesable", { id: "doesAble", "initial": "{}" })
943
- }
944
- })
945
- await config.restart_auto_rebuild()
946
- return config
920
+ }
921
+ return v
922
+ },
923
+ getUUIDScoped: (uuid) => { return {
924
+ ask: getAsk(config)(uuid),
925
+ }
926
+ },
927
+ toScopedId: (context) => {
928
+ return api('dialogues').toScopedId(context)
929
+ },
930
+ }))
931
+ objects.mentioned = []
932
+ objects.variables = {
933
+ }
934
+ if (isModule) {
935
+ } else {
936
+ config.addWord("canbedoquestion", { id: "canBeDoQuestion", "initial": "{}" })
937
+ config.addWord("doesable", { id: "doesAble", "initial": "{}" })
938
+ }
947
939
  }
948
940
 
949
941
  knowledgeModule( {
942
+ config,
943
+ includes: [articles, gdefaults, sdefaults, pos, negation, stm, meta, punctuation],
944
+ initializer,
945
+ api: () => new API(),
946
+
950
947
  module,
951
948
  description: 'framework for dialogues',
952
- createConfig, newWay: true,
949
+ newWay: true,
953
950
  test: {
954
951
  name: './dialogues.test.json',
955
952
  contents: dialogues_tests,
@@ -41,14 +41,14 @@
41
41
  ],
42
42
  "generators": [
43
43
  {
44
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:77",
44
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
45
45
  "match": "({context}) => context.marker == 'noconversion'",
46
46
  "apply": "async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`"
47
47
  }
48
48
  ],
49
49
  "bridges": [
50
50
  {
51
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:84",
51
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
52
52
  "id": "dimension",
53
53
  "isA": [],
54
54
  "generatorpr": {}
@@ -64,7 +64,7 @@
64
64
  "id": "amount"
65
65
  },
66
66
  {
67
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:104",
67
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
68
68
  "id": "degree",
69
69
  "words": [
70
70
  {
@@ -84,7 +84,7 @@
84
84
  "bridge": "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
85
85
  },
86
86
  {
87
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:117",
87
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
88
88
  "id": "convertToUnits",
89
89
  "bridge": "{ ...next(operator), from: before[0], to: after[0] }",
90
90
  "isA": [
@@ -1063,12 +1063,12 @@
1063
1063
  ],
1064
1064
  "generators": [
1065
1065
  {
1066
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:77"
1066
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5"
1067
1067
  }
1068
1068
  ],
1069
1069
  "bridges": [
1070
1070
  {
1071
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:84",
1071
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
1072
1072
  "id": "dimension",
1073
1073
  "isA": [],
1074
1074
  "generatorpr": {}
@@ -1084,7 +1084,7 @@
1084
1084
  "id": "amount"
1085
1085
  },
1086
1086
  {
1087
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:104",
1087
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
1088
1088
  "id": "degree",
1089
1089
  "words": [
1090
1090
  {
@@ -1103,7 +1103,7 @@
1103
1103
  "bridge": "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
1104
1104
  },
1105
1105
  {
1106
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:117",
1106
+ "where": "/home/dev/code/theprogrammablemind/kms/node_modules/theprogrammablemind/src/helpers.js:5",
1107
1107
  "id": "convertToUnits",
1108
1108
  "bridge": "{ ...next(operator), from: before[0], to: after[0] }",
1109
1109
  "isA": [
@@ -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 hierarchy = require('./hierarchy.js')
4
4
  const formulas = require('./formulas.js')
@@ -52,7 +52,7 @@ class API {
52
52
 
53
53
  const api = new API()
54
54
 
55
- let configStruct = {
55
+ let config = {
56
56
  name: 'dimension',
57
57
  operators: [
58
58
  "([dimension])",
@@ -170,23 +170,17 @@ let configStruct = {
170
170
  const template = {
171
171
  configs: [
172
172
  "dimension and unit are concepts",
173
- configStruct,
173
+ config,
174
174
  ],
175
175
  }
176
176
 
177
- const createConfig = async () => {
178
- const config = new Config({ name: 'dimension' }, module)
179
- config.stop_auto_rebuild()
180
- await config.add(hierarchy, formulas, testing)
181
- await config.setApi(api)
182
- await config.restart_auto_rebuild()
183
- return config
184
- }
185
-
186
177
  knowledgeModule({
178
+ config: { name: 'dimension' },
179
+ includes: [hierarchy, formulas, testing],
180
+ api: () => new API(),
181
+
187
182
  module,
188
183
  description: 'Used to define numeric temperature such as currency, temperature or weight',
189
- createConfig,
190
184
  template: { template, instance },
191
185
  test: {
192
186
  name: './dimension.test.json',
@@ -5219,6 +5219,20 @@
5219
5219
  1
5220
5220
  ]
5221
5221
  ],
5222
+ [
5223
+ [
5224
+ "is",
5225
+ 0
5226
+ ],
5227
+ [
5228
+ "list",
5229
+ 1
5230
+ ],
5231
+ [
5232
+ "unknown",
5233
+ 1
5234
+ ]
5235
+ ],
5222
5236
  [
5223
5237
  [
5224
5238
  "is",
@@ -21142,6 +21156,20 @@
21142
21156
  1
21143
21157
  ]
21144
21158
  ],
21159
+ [
21160
+ [
21161
+ "is",
21162
+ 0
21163
+ ],
21164
+ [
21165
+ "list",
21166
+ 1
21167
+ ],
21168
+ [
21169
+ "unknown",
21170
+ 1
21171
+ ]
21172
+ ],
21145
21173
  [
21146
21174
  [
21147
21175
  "is",
@@ -38769,6 +38797,20 @@
38769
38797
  1
38770
38798
  ]
38771
38799
  ],
38800
+ [
38801
+ [
38802
+ "a",
38803
+ 0
38804
+ ],
38805
+ [
38806
+ "is",
38807
+ 0
38808
+ ],
38809
+ [
38810
+ "unknown",
38811
+ 1
38812
+ ]
38813
+ ],
38772
38814
  [
38773
38815
  [
38774
38816
  "is",
@@ -41194,6 +41236,20 @@
41194
41236
  1
41195
41237
  ]
41196
41238
  ],
41239
+ [
41240
+ [
41241
+ "a",
41242
+ 0
41243
+ ],
41244
+ [
41245
+ "is",
41246
+ 0
41247
+ ],
41248
+ [
41249
+ "unknown",
41250
+ 1
41251
+ ]
41252
+ ],
41197
41253
  [
41198
41254
  [
41199
41255
  "is",
@@ -58263,6 +58319,34 @@
58263
58319
  1
58264
58320
  ]
58265
58321
  ],
58322
+ [
58323
+ [
58324
+ "a",
58325
+ 0
58326
+ ],
58327
+ [
58328
+ "is",
58329
+ 0
58330
+ ],
58331
+ [
58332
+ "unknown",
58333
+ 1
58334
+ ]
58335
+ ],
58336
+ [
58337
+ [
58338
+ "a",
58339
+ 0
58340
+ ],
58341
+ [
58342
+ "is",
58343
+ 0
58344
+ ],
58345
+ [
58346
+ "unknown",
58347
+ 1
58348
+ ]
58349
+ ],
58266
58350
  [
58267
58351
  [
58268
58352
  "apple",
@@ -59357,6 +59441,34 @@
59357
59441
  1
59358
59442
  ]
59359
59443
  ],
59444
+ [
59445
+ [
59446
+ "is",
59447
+ 0
59448
+ ],
59449
+ [
59450
+ "list",
59451
+ 1
59452
+ ],
59453
+ [
59454
+ "unknown",
59455
+ 1
59456
+ ]
59457
+ ],
59458
+ [
59459
+ [
59460
+ "is",
59461
+ 0
59462
+ ],
59463
+ [
59464
+ "list",
59465
+ 1
59466
+ ],
59467
+ [
59468
+ "unknown",
59469
+ 1
59470
+ ]
59471
+ ],
59360
59472
  [
59361
59473
  [
59362
59474
  "is",
package/common/edible.js CHANGED
@@ -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 } = require('./helpers')
3
3
  const hierarchy = require('./hierarchy')
4
4
  const countable = require('./countable')
@@ -74,16 +74,11 @@ const template ={
74
74
  ],
75
75
  }
76
76
 
77
- const createConfig = async () => {
78
- const config = new Config({ name: 'edible' }, module)
79
- await config.add(countable, hierarchy)
80
- return config
81
- }
82
-
83
77
  knowledgeModule( {
78
+ config: { name: 'edible' },
79
+ includes: [countable, hierarchy],
84
80
  module,
85
81
  description: 'Edible things',
86
- createConfig,
87
82
  test: {
88
83
  name: './edible.test.json',
89
84
  contents: edible_tests,