ekms 8.0.0-beta.42 → 8.0.0-beta.43

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/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 = async () => {
29
- const config = new Config({ name: 'animals' }, module)
30
- await 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
  })
@@ -1,10 +1,10 @@
1
- const { Config, knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
2
2
  const gdefaults = require('./gdefaults.js')
3
3
  const pos = require('./pos.js')
4
4
  const { defaultContextCheck } = require('./helpers')
5
5
  const tests = require('./articles.test.json')
6
6
 
7
- let configStruct = {
7
+ let config = {
8
8
  name: 'articles',
9
9
  operators: [
10
10
  "([thisitthat|])",
@@ -84,18 +84,13 @@ let configStruct = {
84
84
 
85
85
  };
86
86
 
87
- const createConfig = async () => {
88
- const config = new Config(configStruct, module)
89
- config.stop_auto_rebuild()
90
- await config.add(pos, gdefaults)
91
- await config.restart_auto_rebuild()
92
- return config
93
- }
94
-
95
87
  knowledgeModule( {
88
+ config,
89
+ includes: [pos, gdefaults],
90
+
96
91
  module,
97
92
  description: 'articles',
98
- createConfig, newWay: true,
93
+ newWay: true,
99
94
  test: {
100
95
  name: './articles.test.json',
101
96
  contents: tests,
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 = async () => {
72
- const config = new Config(configStruct, module)
73
- await 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,34 +176,27 @@ const initializeApi = (config, api) => {
173
176
  }
174
177
 
175
178
 
176
- const createConfig = async () => {
177
- const timeKM = await createTimeKM()
178
- const currencyKM = await 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
- await config.add(gdefaults)
185
-
186
- await config.setMultiApi(initializeApi)
187
- config.initializer( async ({isModule, km}) => {
188
- if (!isModule) {
189
- const config = km('characters')
190
- await config.setApi(api2)
191
- await config.setApi(api)
192
- }
193
- })
194
- await config.restart_auto_rebuild()
195
- 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
+ }
196
189
  }
197
-
198
190
  // mode this to non-module init only
199
191
  knowledgeModule({
192
+ config,
193
+ includes: [gdefaults],
194
+ initializer,
195
+ multiApiInitializer: initializeApi,
196
+
200
197
  module,
201
198
  description: 'this module is for creating a team of characters that can respond to commands',
202
199
  demo: "https://youtu.be/eA25GZ0ZAHo",
203
- createConfig,
204
200
  test: {
205
201
  name: './characters.test.json',
206
202
  contents: characters_tests,
@@ -3210,6 +3210,20 @@
3210
3210
  1
3211
3211
  ]
3212
3212
  ],
3213
+ [
3214
+ [
3215
+ "is",
3216
+ 0
3217
+ ],
3218
+ [
3219
+ "list",
3220
+ 1
3221
+ ],
3222
+ [
3223
+ "unknown",
3224
+ 1
3225
+ ]
3226
+ ],
3213
3227
  [
3214
3228
  [
3215
3229
  "is",
@@ -25552,6 +25566,20 @@
25552
25566
  1
25553
25567
  ]
25554
25568
  ],
25569
+ [
25570
+ [
25571
+ "is",
25572
+ 0
25573
+ ],
25574
+ [
25575
+ "list",
25576
+ 1
25577
+ ],
25578
+ [
25579
+ "unknown",
25580
+ 1
25581
+ ]
25582
+ ],
25555
25583
  [
25556
25584
  [
25557
25585
  "is",
package/common/colors.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 colors_tests = require('./colors.test.json')
4
4
  const colors_instance = require('./colors.instance.json')
@@ -46,15 +46,11 @@ const template = {
46
46
  ],
47
47
  }
48
48
 
49
- const createConfig = async () => {
50
- const config = new Config({ name: 'colors' }, module)
51
- await config.add(hierarchy)
52
- return config
53
- }
54
-
55
49
  knowledgeModule( {
50
+ config: { name: 'colors' },
51
+ includes: [hierarchy],
52
+
56
53
  module,
57
- createConfig,
58
54
  description: 'talking about colors',
59
55
  test: {
60
56
  name: './colors.test.json',
@@ -1,10 +1,10 @@
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")
4
4
  const numbers = require("./numbers")
5
5
  const comparable_tests = require('./comparable.test.json')
6
6
 
7
- let configStruct = {
7
+ let config = {
8
8
  name: 'comparable',
9
9
  operators: [
10
10
  "([condition|])",
@@ -47,16 +47,12 @@ let configStruct = {
47
47
  ],
48
48
  };
49
49
 
50
- const createConfig = async () => {
51
- const config = new Config(configStruct, module)
52
- await config.add(dialogues, numbers)
53
- return config
54
- }
55
-
56
50
  knowledgeModule({
51
+ config,
52
+ includes: [dialogues, numbers],
53
+
57
54
  module,
58
55
  description: 'Comparable things',
59
- createConfig,
60
56
  test: {
61
57
  name: './comparable.test.json',
62
58
  contents: comparable_tests,
package/common/concept.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, flatten, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, flatten, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const { API }= require('./helpers/concept')
4
4
  const dialogues = require('./dialogues.js')
@@ -14,141 +14,137 @@ const concept_instance = require('./concept.instance.json')
14
14
  plain and regular fries mean the same thing
15
15
  */
16
16
 
17
- const createConfig = async () => {
18
- const config = new Config({
19
- name: 'concept',
20
- operators: [
21
- "((context.punctuation != true)* [modifies|] (concept))",
22
- "([concept])",
23
- "([literally] (modifies/0))",
24
- ],
25
- bridges: [
26
- {
27
- id: "modifies",
28
- isA: ['verby'],
29
- words: [{ word: 'modifies', number: 'one', flatten: false }, { word: 'modify', number: 'many', flatten: true }],
30
- // bridge: "{ ...next(operator), modifiers: before, concept: after[0], flatten: true }"
31
- bridge: "{ ...next(operator), modifiers: before, concept: after[0] }"
32
- },
33
- { id: "literally", bridge: "{ ...after[0], flatten: false, literally: true }" },
34
- { id: "concept", bridge: "{ ...next(operator) }" },
35
- ],
36
- priorities: [
37
- { "context": [['literally', 0], ['modifies', 0], ], "choose": [0] },
38
- ],
39
- hierarchy: [
40
- ['concept', 'theAble'],
41
- ['concept', 'queryable'],
42
- ],
43
- generators: [
44
- {
45
- notes: '"fire type, water type and earth type" to "fire water and earth type"',
46
- /*
47
- {
48
- "water": {
49
- "marker": "water",
50
- "value": "water",
51
- "word": "water"
52
- },
53
- "marker": "water_type",
54
- "modifiers": [
55
- "water"
56
- ],
57
- "types": [
58
- "water_type"
59
- ],
60
- "value": "water_type",
61
- "word": "type",
62
- "paraphrase": true
17
+ config = {
18
+ name: 'concept',
19
+ operators: [
20
+ "((context.punctuation != true)* [modifies|] (concept))",
21
+ "([concept])",
22
+ "([literally] (modifies/0))",
23
+ ],
24
+ bridges: [
25
+ {
26
+ id: "modifies",
27
+ isA: ['verby'],
28
+ words: [{ word: 'modifies', number: 'one', flatten: false }, { word: 'modify', number: 'many', flatten: true }],
29
+ // bridge: "{ ...next(operator), modifiers: before, concept: after[0], flatten: true }"
30
+ bridge: "{ ...next(operator), modifiers: before, concept: after[0] }"
31
+ },
32
+ { id: "literally", bridge: "{ ...after[0], flatten: false, literally: true }" },
33
+ { id: "concept", bridge: "{ ...next(operator) }" },
34
+ ],
35
+ priorities: [
36
+ { "context": [['literally', 0], ['modifies', 0], ], "choose": [0] },
37
+ ],
38
+ hierarchy: [
39
+ ['concept', 'theAble'],
40
+ ['concept', 'queryable'],
41
+ ],
42
+ generators: [
43
+ {
44
+ notes: '"fire type, water type and earth type" to "fire water and earth type"',
45
+ /*
46
+ {
47
+ "water": {
48
+ "marker": "water",
49
+ "value": "water",
50
+ "word": "water"
63
51
  },
64
- */
65
- where: where(),
66
- match: ({context}) => {
67
- if (!context.paraphrase) {
68
- return
69
- }
70
- if (context.marker !== 'list') {
71
- return
72
- }
73
- if ((context.value || []).length < 2) {
74
- return
75
- }
76
- if (!context.value[0].word) {
77
- return
78
- }
79
- const word = context.value[0].word
80
-
81
- for (let value of context.value) {
82
- if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
83
- return
84
- }
85
- }
86
- return true
52
+ "marker": "water_type",
53
+ "modifiers": [
54
+ "water"
55
+ ],
56
+ "types": [
57
+ "water_type"
58
+ ],
59
+ "value": "water_type",
60
+ "word": "type",
61
+ "paraphrase": true
87
62
  },
88
- apply: async ({g, context}) => {
89
- const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
90
- context.word = context.value[0].word
91
- context.value = null
92
- context.modifiers = ['modifier']
93
- context.modifier = {
94
- marker: 'list',
95
- paraphrase: true,
96
- value: modifiers
97
- }
98
- context.paraphrase = true
99
- return await g(context)
63
+ */
64
+ where: where(),
65
+ match: ({context}) => {
66
+ if (!context.paraphrase) {
67
+ return
100
68
  }
101
- },
102
- {
103
- where: where(),
104
- match: ({context}) => context.marker == 'modifies' && context.paraphrase,
105
- apply: async ({context, gp, gw}) => {
106
- const modifiers = []
107
- for (modifier of context.modifiers) {
108
- modifiers.push(await gp(modifier))
109
- }
110
- if (context.literally) {
111
- return `${modifiers.join(" ")} literally ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
112
- } else {
113
- return `${modifiers.join(" ")} ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
114
- }
69
+ if (context.marker !== 'list') {
70
+ return
115
71
  }
116
- // const chosen = chooseNumber(context, word.singular, word.plural)
117
- },
118
- ],
119
- semantics: [
120
- {
121
- notes: 'define a modifier',
122
- where: where(),
123
- match: ({context}) => context.marker == 'modifies',
124
- apply: ({config, query, km, context}) => {
125
- let modifiers
126
- if (context.literally) {
127
- literalModifiers = context.modifiers[0]
128
- // modifiers = literalModifiers.value.map(modifier => modifier.value)
129
- modifiers = literalModifiers.value
130
- modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
131
- } else {
132
- modifiers = context.modifiers
133
- // modifiers = context.modifiers.map(modifier => modifier.value)
72
+ if ((context.value || []).length < 2) {
73
+ return
74
+ }
75
+ if (!context.value[0].word) {
76
+ return
77
+ }
78
+ const word = context.value[0].word
79
+
80
+ for (let value of context.value) {
81
+ if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
82
+ return
134
83
  }
135
- // km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
136
- km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
137
84
  }
85
+ return true
138
86
  },
139
- ],
140
- }, module)
141
- config.stop_auto_rebuild()
142
- await config.setApi(new API())
143
- await config.add(dialogues)
144
- await config.restart_auto_rebuild()
145
- return config
87
+ apply: async ({g, context}) => {
88
+ const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
89
+ context.word = context.value[0].word
90
+ context.value = null
91
+ context.modifiers = ['modifier']
92
+ context.modifier = {
93
+ marker: 'list',
94
+ paraphrase: true,
95
+ value: modifiers
96
+ }
97
+ context.paraphrase = true
98
+ return await g(context)
99
+ }
100
+ },
101
+ {
102
+ where: where(),
103
+ match: ({context}) => context.marker == 'modifies' && context.paraphrase,
104
+ apply: async ({context, gp, gw}) => {
105
+ const modifiers = []
106
+ for (modifier of context.modifiers) {
107
+ modifiers.push(await gp(modifier))
108
+ }
109
+ if (context.literally) {
110
+ return `${modifiers.join(" ")} literally ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
111
+ } else {
112
+ return `${modifiers.join(" ")} ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
113
+ }
114
+ }
115
+ // const chosen = chooseNumber(context, word.singular, word.plural)
116
+ },
117
+ ],
118
+ semantics: [
119
+ {
120
+ notes: 'define a modifier',
121
+ where: where(),
122
+ match: ({context}) => context.marker == 'modifies',
123
+ apply: ({config, query, km, context}) => {
124
+ let modifiers
125
+ if (context.literally) {
126
+ literalModifiers = context.modifiers[0]
127
+ // modifiers = literalModifiers.value.map(modifier => modifier.value)
128
+ modifiers = literalModifiers.value
129
+ modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
130
+ } else {
131
+ modifiers = context.modifiers
132
+ // modifiers = context.modifiers.map(modifier => modifier.value)
133
+ }
134
+ // km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
135
+ km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
136
+ }
137
+ },
138
+ ],
146
139
  }
147
140
 
148
141
  knowledgeModule({
142
+ config,
143
+ includes: [dialogues],
144
+ api: () => new API(),
145
+
149
146
  module,
150
147
  description: 'The idea of a concept whatever that might end up being',
151
- createConfig,
152
148
  test: {
153
149
  name: './concept.test.json',
154
150
  contents: concept_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 dialogues = require("./hierarchy")
4
4
  const numbers = require("./numbers")
@@ -11,7 +11,7 @@ const countable_tests = require('./countable.test.json')
11
11
  2 6 and 3 10 piece nuggets
12
12
  */
13
13
 
14
- let configStruct = {
14
+ let config = {
15
15
  name: 'countable',
16
16
  operators: [
17
17
  "(([quantifier|]) [counting] ([countable]))",
@@ -75,16 +75,12 @@ let configStruct = {
75
75
  ]
76
76
  };
77
77
 
78
- const createConfig = async () => {
79
- const config = new Config(configStruct, module)
80
- await config.add(dialogues, numbers)
81
- return config
82
- }
83
-
84
78
  knowledgeModule({
79
+ config,
80
+ includes: [dialogues, numbers],
81
+
85
82
  module,
86
83
  description: 'Countable things',
87
- createConfig,
88
84
  test: {
89
85
  name: './countable.test.json',
90
86
  contents: countable_tests,