theprogrammablemind 7.5.4-beta.1 → 7.5.4-beta.3

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 (2) hide show
  1. package/package.json +4 -4
  2. package/src/config.js +115 -5
package/package.json CHANGED
@@ -10,12 +10,12 @@
10
10
  "eslint": "^7.31.0"
11
11
  },
12
12
  "scripts": {
13
- "to:debug": "node inspect node_modules/.bin/jest --runInBand -t ONE23",
13
+ "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
14
14
  "test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
15
- "tod": "node inspect node_modules/.bin/jest --runInBand -t ONE23",
15
+ "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO23",
16
16
  "lint:fix": "eslint \"**/*.js\" --fix",
17
17
  "lint": "eslint \"**/*.js\"",
18
- "to": "node node_modules/.bin/jest --runInBand -t ONE23",
18
+ "to": "node node_modules/.bin/jest --runInBand -t NEO23",
19
19
  "test": "jest --config ./jest.config.json",
20
20
  "test:watch": "npm run test -- --watch"
21
21
  },
@@ -61,6 +61,6 @@
61
61
  "json-stable-stringify": "^1.0.1",
62
62
  "node-fetch": "^2.6.1"
63
63
  },
64
- "version": "7.5.4-beta.1",
64
+ "version": "7.5.4-beta.3",
65
65
  "license": "ISC"
66
66
  }
package/src/config.js CHANGED
@@ -22,6 +22,88 @@ const indent = (string, indent) => {
22
22
  return string.replace(/^/gm, ' '.repeat(indent));
23
23
  }
24
24
 
25
+ const handleBridgeProps = (config, bridge) => {
26
+ if (!bridge.bridge) {
27
+ bridge.bridge = "{ ...next(operator) }"
28
+ }
29
+ if (!bridge.level) {
30
+ bridge.level = 0
31
+ }
32
+ if (bridge.children) {
33
+ for (let child of bridge.children) {
34
+ config.addHierarchy(child, bridge.id)
35
+ }
36
+ }
37
+ if (bridge.parents) {
38
+ for (let parent of bridge.parents) {
39
+ config.addHierarchy(bridge.id, parent)
40
+ }
41
+ }
42
+ if (bridge.isA) {
43
+ for (let parent of bridge.isA) {
44
+ config.addHierarchy(bridge.id, parent)
45
+ }
46
+ }
47
+ if (bridge.before) {
48
+ for (let after of bridge.before) {
49
+ if (typeof after == 'string') {
50
+ after = [after, 0]
51
+ }
52
+ config.addPriorities([after, [bridge.id, bridge.level]])
53
+ }
54
+ }
55
+ if (bridge.words) {
56
+ for (let def of bridge.words) {
57
+ if (typeof def == 'string') {
58
+ config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
59
+ } else {
60
+ const word = def.word
61
+ def = { initial: JSON.stringify(def), id: bridge.id, word: undefined }
62
+ config.addWordInternal(word, def)
63
+ }
64
+ }
65
+ }
66
+ if (bridge.generator) {
67
+ config.config.generators.unshift(bridge.generator)
68
+ }
69
+ if (bridge.generators) {
70
+ const generators = [...bridge.generators]
71
+ generators.reverse()
72
+ for (let generator of generators) {
73
+ config.config.generators.unshift(generator)
74
+ }
75
+ }
76
+ if (bridge.generatorp) {
77
+ config.config.generators.unshift({
78
+ where: bridge.generatorp.where || client.where(3),
79
+ match: ({context}) => bridge.id == context.marker && context.paraphrase,
80
+ apply: (args) => bridge.generatorp(args),
81
+ })
82
+ }
83
+ if (bridge.generatorr) {
84
+ config.config.generators.unshift({
85
+ // TODO merge response and isResponse
86
+ where: bridge.generatorr.where || client.where(3),
87
+ match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
88
+ apply: (args) => bridge.generatorr(args),
89
+ })
90
+ }
91
+ if (bridge.evaluator) {
92
+ config.config.semantics.unshift({
93
+ where: bridge.evaluator.where || client.where(3),
94
+ match: ({context}) => bridge.id == context.marker && context.evaluate,
95
+ apply: (args) => bridge.evaluator(args),
96
+ })
97
+ }
98
+ if (bridge.semantic) {
99
+ config.config.semantics.unshift({
100
+ where: bridge.semantic.where || client.where(3),
101
+ match: ({context}) => bridge.id == context.marker,
102
+ apply: (args) => bridge.semantic(args),
103
+ })
104
+ }
105
+ }
106
+
25
107
  if (runtime.process.env.DEBUG_HIERARCHY) {
26
108
  global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
27
109
  }
@@ -86,6 +168,17 @@ const normalizeConfig = (config) => {
86
168
  config[bag][i].km = config.name
87
169
  }
88
170
  }
171
+
172
+ }
173
+ if (config['bridges']) {
174
+ for (let bridge of config['bridges']) {
175
+ if (!bridge.level) {
176
+ bridge.level = 0
177
+ }
178
+ if (!bridge.bridge) {
179
+ bridge.bridge = "{ ...next(operator) }"
180
+ }
181
+ }
89
182
  }
90
183
  }
91
184
  }
@@ -689,6 +782,7 @@ class Config {
689
782
  if (global.transitoryMode) {
690
783
  def.transitoryMode = true
691
784
  }
785
+ handleBridgeProps(this, def)
692
786
  bridges.push(def)
693
787
  this.checkBridges();
694
788
  this._delta.json.bridges.push({ action: 'add', bridge: def })
@@ -1018,7 +1112,8 @@ class Config {
1018
1112
  'debug',
1019
1113
 
1020
1114
  // TODO Fix these from the test app
1021
- 'implicit',
1115
+ 'implicits',
1116
+ 'convolution',
1022
1117
  'expected_generated',
1023
1118
  'expected_results',
1024
1119
  'skipSemantics',
@@ -1115,9 +1210,21 @@ class Config {
1115
1210
  config = _.cloneDeep(config)
1116
1211
  this.config = config
1117
1212
  for (let bridge of this.config.bridges) {
1118
- const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'implicit', 'inverted', 'isA', 'children', 'parents',
1213
+ const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
1119
1214
  'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy' ]
1120
1215
  helpers.validProps(valid, bridge, 'bridge')
1216
+ /* moved
1217
+ if (!bridge.bridge) {
1218
+ bridge.bridge = "{ ...next(operator) }"
1219
+ }
1220
+ */
1221
+ handleBridgeProps(this, bridge)
1222
+
1223
+ /* moved
1224
+ if (!bridge.level) {
1225
+ bridge.level = 0
1226
+ }
1227
+ */
1121
1228
  /*
1122
1229
  if (bridge.generator) {
1123
1230
  this.config.generators.push({
@@ -1126,6 +1233,7 @@ class Config {
1126
1233
  })
1127
1234
  }
1128
1235
  */
1236
+ /* moved
1129
1237
  if (bridge.children) {
1130
1238
  for (let child of bridge.children) {
1131
1239
  this.addHierarchy(child, bridge.id)
@@ -1141,6 +1249,8 @@ class Config {
1141
1249
  this.addHierarchy(bridge.id, parent)
1142
1250
  }
1143
1251
  }
1252
+ */
1253
+ /* moved
1144
1254
  if (bridge.before) {
1145
1255
  for (let after of bridge.before) {
1146
1256
  if (typeof after == 'string') {
@@ -1163,6 +1273,8 @@ class Config {
1163
1273
  if (bridge.generator) {
1164
1274
  this.config.generators.unshift(bridge.generator)
1165
1275
  }
1276
+ */
1277
+ /* moved
1166
1278
  if (bridge.generators) {
1167
1279
  const generators = [...bridge.generators]
1168
1280
  generators.reverse()
@@ -1199,6 +1311,7 @@ class Config {
1199
1311
  apply: (args) => bridge.semantic(args),
1200
1312
  })
1201
1313
  }
1314
+ */
1202
1315
  }
1203
1316
  if (config.operators) {
1204
1317
  config.operators = config.operators.map((operator) => {
@@ -2560,9 +2673,6 @@ class Config {
2560
2673
  // console.log('key', key, 'XXX')
2561
2674
  // console.log('more', JSON.stringify(more, null, 2))
2562
2675
  // this.config[key] = this.config[key].concat(more[key])
2563
- if (key == '2enerators') {
2564
- debugger
2565
- }
2566
2676
  // this.config[key] = this.config[key].concat(more[key])
2567
2677
  this.config[key] = more[key].concat(this.config[key])
2568
2678
  } else {