ekms 8.0.0 → 8.1.0-beta.1

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 (124) hide show
  1. package/common/animals.instance.json +3055 -1651
  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/asking.instance.json +2 -0
  6. package/common/asking.js +253 -0
  7. package/common/asking.test.json +2290 -0
  8. package/common/avatar.js +6 -10
  9. package/common/characters.js +23 -30
  10. package/common/colors.instance.json +25666 -0
  11. package/common/colors.js +67 -0
  12. package/common/colors.test.json +4425 -0
  13. package/common/comparable.instance.json +1750 -0
  14. package/common/comparable.js +36 -28
  15. package/common/comparable.test.json +1196 -2
  16. package/common/concept.js +121 -119
  17. package/common/concept.test.json +688 -0
  18. package/common/conjunction.instance.json +2 -0
  19. package/common/conjunction.js +104 -0
  20. package/common/conjunction.test.json +322 -0
  21. package/common/countable.js +20 -14
  22. package/common/countable.test.json +1050 -0
  23. package/common/crew.instance.json +16432 -9850
  24. package/common/crew.js +39 -42
  25. package/common/crew.test.json +714 -452
  26. package/common/currency.js +28 -46
  27. package/common/dialogues.js +187 -429
  28. package/common/dialogues.test.json +684 -450
  29. package/common/dimension.instance.json +517 -289
  30. package/common/dimension.js +22 -24
  31. package/common/dimension.test.json +727 -1944
  32. package/common/edible.instance.json +20506 -10664
  33. package/common/edible.js +4 -9
  34. package/common/emotions.instance.json +195 -123
  35. package/common/emotions.js +36 -39
  36. package/common/evaluate.instance.json +2 -0
  37. package/common/evaluate.js +53 -0
  38. package/common/evaluate.test.json +574 -0
  39. package/common/events.js +11 -15
  40. package/common/fastfood.instance.json +223185 -113172
  41. package/common/fastfood.js +77 -87
  42. package/common/fastfood.test.json +8205 -3733
  43. package/common/formulas.instance.json +444 -244
  44. package/common/formulas.js +20 -27
  45. package/common/formulas.test.json +1027 -955
  46. package/common/gdefaults.js +45 -32
  47. package/common/help.js +9 -14
  48. package/common/help.test.json +71 -18
  49. package/common/helpers/concept.js +37 -10
  50. package/common/helpers/dialogues.js +22 -4
  51. package/common/helpers/formulas.js +0 -14
  52. package/common/helpers/meta.js +0 -1
  53. package/common/helpers/properties.js +92 -84
  54. package/common/helpers.js +35 -24
  55. package/common/hierarchy.js +18 -25
  56. package/common/javascript.js +12 -19
  57. package/common/kirk.instance.json +583 -300
  58. package/common/kirk.js +6 -9
  59. package/common/length.instance.json +8995 -4964
  60. package/common/length.js +5 -9
  61. package/common/listener.js +48 -0
  62. package/common/listener.test.json +104 -0
  63. package/common/math.instance.json +409 -1202
  64. package/common/math.js +17 -21
  65. package/common/meta.js +24 -50
  66. package/common/nameable.instance.json +2 -0
  67. package/common/nameable.js +144 -0
  68. package/common/nameable.test.json +3191 -0
  69. package/common/negation.instance.json +2 -0
  70. package/common/negation.js +38 -0
  71. package/common/negation.test.json +308 -0
  72. package/common/numbers.js +28 -32
  73. package/common/ordering.instance.json +459 -274
  74. package/common/ordering.js +81 -87
  75. package/common/ordinals.instance.json +2 -0
  76. package/common/ordinals.js +61 -0
  77. package/common/ordinals.test.json +412 -0
  78. package/common/people.instance.json +2138 -1321
  79. package/common/people.js +9 -14
  80. package/common/people.test.json +1815 -1073
  81. package/common/percentages.instance.json +2 -0
  82. package/common/percentages.js +53 -0
  83. package/common/percentages.test.json +751 -0
  84. package/common/pipboy.instance.json +12261 -6898
  85. package/common/pipboy.js +53 -62
  86. package/common/pipboy.test.json +2835 -0
  87. package/common/pokemon.instance.json +4432 -2351
  88. package/common/pokemon.js +8 -21
  89. package/common/pos.js +16 -14
  90. package/common/pressure.instance.json +2311 -1303
  91. package/common/pressure.js +5 -9
  92. package/common/properties.instance.json +151 -87
  93. package/common/properties.js +164 -167
  94. package/common/properties.test.json +17605 -4030
  95. package/common/punctuation.js +24 -8
  96. package/common/punctuation.test.json +233 -5
  97. package/common/reports.instance.json +1037 -551
  98. package/common/reports.js +77 -103
  99. package/common/reports.test.json +15623 -10458
  100. package/common/scorekeeper.js +19 -31
  101. package/common/sdefaults.js +17 -8
  102. package/common/sizeable.js +13 -12
  103. package/common/spock.instance.json +582 -299
  104. package/common/spock.js +6 -9
  105. package/common/stgame.js +20 -20
  106. package/common/stm.js +182 -29
  107. package/common/stm.test.json +1734 -1
  108. package/common/tell.js +15 -19
  109. package/common/temperature.instance.json +2379 -1355
  110. package/common/temperature.js +5 -9
  111. package/common/tester.js +15 -4
  112. package/common/testing.js +8 -13
  113. package/common/time.js +21 -26
  114. package/common/tokenize.js +8 -8
  115. package/common/tokenize.test.json +86 -1
  116. package/common/ui.instance.json +151 -460
  117. package/common/ui.js +22 -34
  118. package/common/ui.test.json +641 -5357
  119. package/common/weight.instance.json +7957 -4350
  120. package/common/weight.js +5 -9
  121. package/common/weight.test.json +242 -238
  122. package/common/yesno.js +6 -6
  123. package/main.js +68 -45
  124. package/package.json +44 -6
@@ -0,0 +1,104 @@
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const gdefaults = require('./gdefaults.js')
3
+ const conjunction_tests = require('./conjunction.test.json')
4
+ const { defaultContextCheck } = require('./helpers')
5
+
6
+ let config = {
7
+ name: 'conjunction',
8
+ operators: [
9
+ "(x [list|and] y)",
10
+ ],
11
+ bridges: [
12
+ // context.instance == variables.instance (unification)
13
+ {
14
+ id: "list",
15
+ level: 0,
16
+ selector: {
17
+ match: "same",
18
+ left: [ { pattern: '($type && context.instance == variables.instance)' } ],
19
+ right: [ { pattern: '($type && context.instance == variables.instance)' } ],
20
+ // left: [ { pattern: '($type)' } ],
21
+ // right: [ { pattern: '($type)' } ],
22
+ passthrough: true
23
+ },
24
+ bridge: "{ ...next(operator), listable: true, isList: true, value: append(before, after) }"
25
+ },
26
+ {
27
+ id: "list",
28
+ level: 1,
29
+ selector: {
30
+ match: "same",
31
+ left: [ { pattern: '($type && context.instance == variables.instance)' } ],
32
+ passthrough: true
33
+ },
34
+ bridge: "{ ...operator, value: append(before, operator.value) }"
35
+ },
36
+ ],
37
+ generators: [
38
+ {
39
+ where: where(),
40
+ notes: 'handle lists with yes no',
41
+ // ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
42
+ // ({context, hierarchy}) => context.marker == 'list' && context.value,
43
+ match: ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value && context.value.length > 0 && context.value[0].marker == 'yesno',
44
+ apply: async ({context, g, gs}) => {
45
+ return `${await g(context.value[0])} ${await gs(context.value.slice(1), ', ', ' and ')}`
46
+ }
47
+ },
48
+
49
+ {
50
+ where: where(),
51
+ notes: 'handle lists',
52
+ // ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
53
+ // ({context, hierarchy}) => context.marker == 'list' && context.value,
54
+ match: ({context, hierarchy}) => context.marker == 'list' && context.value,
55
+ apply: async ({context, gs}) => {
56
+ if (context.newLinesOnly) {
57
+ return await gs(context.value, '\n')
58
+ } else {
59
+ return await gs(context.value, ', ', ' and ')
60
+ }
61
+ }
62
+ },
63
+ ],
64
+ };
65
+
66
+ const initializer = ({objects, config, isModule}) => {
67
+ config.addArgs(({config, api, isA}) => ({
68
+ isAListable: (context, type) => {
69
+ if (context.marker == 'list' || context.listable) {
70
+ return context.value.every( (element) => isA(element.marker, type) )
71
+ } else {
72
+ return isA(context.marker, type)
73
+ }
74
+ },
75
+ toContext: (v) => {
76
+ if (Array.isArray(v)) {
77
+ return { marker: 'list', level: 1, value: v }
78
+ }
79
+ if (v.marker == 'list') {
80
+ return v
81
+ }
82
+ return v
83
+ },
84
+ }))
85
+ }
86
+
87
+ knowledgeModule( {
88
+ config,
89
+ includes: [gdefaults],
90
+ initializer,
91
+
92
+ module,
93
+ description: 'framework for conjunction',
94
+ newWay: true,
95
+ test: {
96
+ name: './conjunction.test.json',
97
+ contents: conjunction_tests,
98
+ checks: {
99
+ objects: ['idSuffix'],
100
+ context: defaultContextCheck(),
101
+ },
102
+
103
+ },
104
+ })
@@ -0,0 +1,322 @@
1
+ [
2
+ {
3
+ "associations": [
4
+ [
5
+ [
6
+ "list",
7
+ 0
8
+ ],
9
+ [
10
+ "unknown",
11
+ 0
12
+ ]
13
+ ],
14
+ [
15
+ [
16
+ "list",
17
+ 0
18
+ ],
19
+ [
20
+ "unknown",
21
+ 0
22
+ ],
23
+ [
24
+ "unknown",
25
+ 1
26
+ ]
27
+ ],
28
+ [
29
+ [
30
+ "list",
31
+ 0
32
+ ],
33
+ [
34
+ "unknown",
35
+ 1
36
+ ]
37
+ ],
38
+ [
39
+ [
40
+ "list",
41
+ 1
42
+ ],
43
+ [
44
+ "unknown",
45
+ 1
46
+ ]
47
+ ]
48
+ ],
49
+ "config": {
50
+ },
51
+ "contexts": [
52
+ {
53
+ "default": true,
54
+ "isList": true,
55
+ "level": 1,
56
+ "listable": true,
57
+ "marker": "list",
58
+ "range": {
59
+ "end": 8,
60
+ "start": 0
61
+ },
62
+ "text": "1 2 and 3",
63
+ "topLevel": true,
64
+ "types": [
65
+ "list",
66
+ "unknown"
67
+ ],
68
+ "value": [
69
+ {
70
+ "dead": true,
71
+ "level": 1,
72
+ "marker": "unknown",
73
+ "range": {
74
+ "end": 0,
75
+ "start": 0
76
+ },
77
+ "text": "1",
78
+ "types": [
79
+ "unknown"
80
+ ],
81
+ "unknown": true,
82
+ "value": "1",
83
+ "word": "1"
84
+ },
85
+ {
86
+ "dead": true,
87
+ "level": 1,
88
+ "marker": "unknown",
89
+ "range": {
90
+ "end": 2,
91
+ "start": 2
92
+ },
93
+ "text": "2",
94
+ "types": [
95
+ "unknown"
96
+ ],
97
+ "unknown": true,
98
+ "value": "2",
99
+ "word": "2"
100
+ },
101
+ {
102
+ "dead": true,
103
+ "level": 1,
104
+ "marker": "unknown",
105
+ "range": {
106
+ "end": 8,
107
+ "start": 8
108
+ },
109
+ "text": "3",
110
+ "types": [
111
+ "unknown"
112
+ ],
113
+ "unknown": true,
114
+ "value": "3",
115
+ "word": "3"
116
+ }
117
+ ],
118
+ "word": "and"
119
+ }
120
+ ],
121
+ "developerTest": false,
122
+ "generatedParenthesized": [
123
+ ""
124
+ ],
125
+ "metadata": {
126
+ "opChoices": [
127
+ {
128
+ "counter": 1,
129
+ "op": [
130
+ "unknown",
131
+ 0
132
+ ],
133
+ "ops": [
134
+ [
135
+ "list",
136
+ 0
137
+ ],
138
+ [
139
+ "unknown",
140
+ 0
141
+ ],
142
+ [
143
+ "unknown",
144
+ 0
145
+ ],
146
+ [
147
+ "unknown",
148
+ 0
149
+ ]
150
+ ]
151
+ },
152
+ {
153
+ "counter": 2,
154
+ "op": [
155
+ "unknown",
156
+ 0
157
+ ],
158
+ "ops": [
159
+ [
160
+ "list",
161
+ 0
162
+ ],
163
+ [
164
+ "unknown",
165
+ 0
166
+ ],
167
+ [
168
+ "unknown",
169
+ 0
170
+ ]
171
+ ]
172
+ },
173
+ {
174
+ "counter": 3,
175
+ "op": [
176
+ "unknown",
177
+ 0
178
+ ],
179
+ "ops": [
180
+ [
181
+ "list",
182
+ 0
183
+ ],
184
+ [
185
+ "unknown",
186
+ 0
187
+ ]
188
+ ]
189
+ },
190
+ {
191
+ "counter": 4,
192
+ "op": [
193
+ "list",
194
+ 0
195
+ ],
196
+ "ops": [
197
+ [
198
+ "list",
199
+ 0
200
+ ]
201
+ ]
202
+ },
203
+ {
204
+ "counter": 5,
205
+ "op": [
206
+ "list",
207
+ 1
208
+ ],
209
+ "ops": [
210
+ [
211
+ "list",
212
+ 1
213
+ ]
214
+ ]
215
+ }
216
+ ]
217
+ },
218
+ "objects": {
219
+ "nameToUUID": {
220
+ "conjunction": "conjunction1",
221
+ "gdefaults": "gdefaults2",
222
+ "tokenize": "tokenize2"
223
+ },
224
+ "namespaced": {
225
+ "conjunction1": {
226
+ },
227
+ "gdefaults2": {
228
+ },
229
+ "tokenize2": {
230
+ }
231
+ },
232
+ "processed": [
233
+ {
234
+ "context": {
235
+ "default": true,
236
+ "isList": true,
237
+ "level": 1,
238
+ "listable": true,
239
+ "marker": "list",
240
+ "range": {
241
+ "end": 8,
242
+ "start": 0
243
+ },
244
+ "text": "1 2 and 3",
245
+ "topLevel": true,
246
+ "types": [
247
+ "list",
248
+ "unknown"
249
+ ],
250
+ "value": [
251
+ {
252
+ "dead": true,
253
+ "level": 1,
254
+ "marker": "unknown",
255
+ "range": {
256
+ "end": 0,
257
+ "start": 0
258
+ },
259
+ "text": "1",
260
+ "types": [
261
+ "unknown"
262
+ ],
263
+ "unknown": true,
264
+ "value": "1",
265
+ "word": "1"
266
+ },
267
+ {
268
+ "dead": true,
269
+ "level": 1,
270
+ "marker": "unknown",
271
+ "range": {
272
+ "end": 2,
273
+ "start": 2
274
+ },
275
+ "text": "2",
276
+ "types": [
277
+ "unknown"
278
+ ],
279
+ "unknown": true,
280
+ "value": "2",
281
+ "word": "2"
282
+ },
283
+ {
284
+ "dead": true,
285
+ "level": 1,
286
+ "marker": "unknown",
287
+ "range": {
288
+ "end": 8,
289
+ "start": 8
290
+ },
291
+ "text": "3",
292
+ "types": [
293
+ "unknown"
294
+ ],
295
+ "unknown": true,
296
+ "value": "3",
297
+ "word": "3"
298
+ }
299
+ ],
300
+ "word": "and"
301
+ },
302
+ "generatedParenthesized": "",
303
+ "paraphrases": "1, 2 and 3",
304
+ "paraphrasesParenthesized": "((1), (2) and (3))",
305
+ "responses": [
306
+ ""
307
+ ]
308
+ }
309
+ ]
310
+ },
311
+ "paraphrases": [
312
+ "1, 2 and 3"
313
+ ],
314
+ "paraphrasesParenthesized": [
315
+ "((1), (2) and (3))"
316
+ ],
317
+ "query": "1 2 and 3",
318
+ "responses": [
319
+ ""
320
+ ]
321
+ }
322
+ ]
@@ -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,12 +11,14 @@ 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]))",
18
18
  "(([number|]) [countOfPieces|] ([piece]))",
19
19
  "((countOfPieces/*) [countingPieces] ([hasCountOfPieces]))",
20
+ "([more] (countable/*))",
21
+ "([less] (countable/*))",
20
22
  "([all])",
21
23
  // everything
22
24
  ],
@@ -24,7 +26,7 @@ let configStruct = {
24
26
  {
25
27
  id: "counting",
26
28
  convolution: true,
27
- before: ['verby'],
29
+ before: ['verb'],
28
30
  bridge: "{ ...after, modifiers: append(['quantity'], after[0].modifiers), quantity: before[0], number: default(before[0].number, before[0].value), instance: true }"
29
31
  },
30
32
  {
@@ -44,6 +46,14 @@ let configStruct = {
44
46
  {
45
47
  id: "piece",
46
48
  },
49
+ {
50
+ id: "more",
51
+ bridge: "{ ...next(after[0]), more: operator, modifiers: append(['more'], after[0].modifiers) }",
52
+ },
53
+ {
54
+ id: "less",
55
+ bridge: "{ ...next(after[0]), less: operator, modifiers: append(['less'], after[0].modifiers) }",
56
+ },
47
57
  {
48
58
  id: "quantifier",
49
59
  children: ['number', 'all'],
@@ -63,34 +73,30 @@ let configStruct = {
63
73
  {
64
74
  where: where(),
65
75
  match: ({context}) => false && context.quantity,
66
- apply: ({context, g}) => {
76
+ apply: async ({context, g}) => {
67
77
  let number = context.quantity.number || 'one'
68
78
  if (context.quantity.value > 1) {
69
79
  number = 'many'
70
80
  }
71
- const countable = g({ ...context, quantity: undefined, number})
72
- return `${g(context.quantity)} ${countable}`
81
+ const countable = await g({ ...context, quantity: undefined, number})
82
+ return `${await g(context.quantity)} ${countable}`
73
83
  }
74
84
  },
75
85
  ]
76
86
  };
77
87
 
78
- const createConfig = () => {
79
- const config = new Config(configStruct, module)
80
- config.add(dialogues(), numbers())
81
- return config
82
- }
83
-
84
88
  knowledgeModule({
89
+ config,
90
+ includes: [dialogues, numbers],
91
+
85
92
  module,
86
93
  description: 'Countable things',
87
- createConfig,
88
94
  test: {
89
95
  name: './countable.test.json',
90
96
  contents: countable_tests,
91
97
  checks: {
92
98
  context: [
93
- ...defaultContextCheck,
99
+ ...defaultContextCheck(),
94
100
  {
95
101
  property: 'quantity',
96
102
  filter: ['marker', 'value'],