theprogrammablemind_4wp 7.5.8-beta.77 → 7.5.8-beta.79
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +10 -7
- package/package.json +1 -1
- package/src/config.js +34 -76
package/client.js
CHANGED
@@ -591,7 +591,7 @@ const loadInstance = (config, instance) => {
|
|
591
591
|
config.addAssociations(instance.associations)
|
592
592
|
}
|
593
593
|
if (instance.learned_contextual_priorities && instance.learned_contextual_priorities.length > 0) {
|
594
|
-
config.
|
594
|
+
config.addPriorities(instance.learned_contextual_priorities)
|
595
595
|
}
|
596
596
|
}
|
597
597
|
}
|
@@ -1122,6 +1122,13 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
1122
1122
|
}
|
1123
1123
|
console.log("KM's loaded", config.configs.map((c) => c.name))
|
1124
1124
|
console.log('This is the global objects from running semantics:\n', config.objects)
|
1125
|
+
if (!_.isEmpty(responses.learned_contextual_priorities)) {
|
1126
|
+
console.log('\nThe learned contextual priorties are :\n')
|
1127
|
+
for (const lcp of responses.learned_contextual_priorities) {
|
1128
|
+
console.log(` ${JSON.stringify(lcp)},\n`)
|
1129
|
+
}
|
1130
|
+
console.log("\n")
|
1131
|
+
}
|
1125
1132
|
if (responses.logs) {
|
1126
1133
|
console.log('Logs')
|
1127
1134
|
responses.logs.forEach((log) => console.log(` ${log}`))
|
@@ -1433,6 +1440,7 @@ const knowledgeModule = async ({
|
|
1433
1440
|
parser.add_argument('-tmn', '--testModuleName', { help: 'When running tests instead of using the current modules tests use the specified modules tests' })
|
1434
1441
|
parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
|
1435
1442
|
parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
|
1443
|
+
// parser.add_argument('-ttr', '--testToRun', { help: 'Only the specified test will be run' })
|
1436
1444
|
parser.add_argument('-tva', '--testAllVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. All the tests will be run instead of stopping at first failure. Create tests by running with the --query or --loop with the --save flag' })
|
1437
1445
|
parser.add_argument('-tnp', '--testNoParenthesized', { action: 'store_true', help: 'Don\' check parenthesized differences for the tests' })
|
1438
1446
|
parser.add_argument('-n', '--count', { help: 'Number of times to run the tests. Default is one. Use this to check for flakey test. If possible the system will print out a message with the word "hint" suggesting how to fix the problem' })
|
@@ -1452,7 +1460,7 @@ const knowledgeModule = async ({
|
|
1452
1460
|
parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
|
1453
1461
|
parser.add_argument('-od', '--objectDiff', { action: 'store_true', help: 'When showing the objects use a colour diff' })
|
1454
1462
|
parser.add_argument('-daa', '--dontAddAssociations', { action: 'store_true', help: 'Do not add associations from the tests.' })
|
1455
|
-
parser.add_argument('-p', '--print', { help: 'Print the specified elements c === config, w === words, b === bridges, o === operators d === objects (d for data), h === hierarchy, g === generators, s === semantics, l === load t=tests ordering p === priorities a == associations j == JSON sent to server
|
1463
|
+
parser.add_argument('-p', '--print', { help: 'Print the specified elements c === config, w === words, b === bridges, o === operators d === objects (d for data), h === hierarchy, g === generators, s === semantics, l === load t=tests ordering p === priorities a == associations j == JSON sent to server. for example --print wb' })
|
1456
1464
|
parser.add_argument('-s', '--save', { action: 'store_true', help: 'When running with the --query flag this will save the current run to the test file. When running without the --query flag all tests will be run and resaved.' })
|
1457
1465
|
parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
|
1458
1466
|
parser.add_argument('-dl', '--debugLoops', { action: 'store_true', help: 'When running with the --debugLoops flag the logs calls to semantics and generators will be immediately written to the console '})
|
@@ -1629,11 +1637,6 @@ const knowledgeModule = async ({
|
|
1629
1637
|
console.log(JSON.stringify(priority))
|
1630
1638
|
}
|
1631
1639
|
}
|
1632
|
-
if (args.print.includes('x')) {
|
1633
|
-
for (let contextual_priority of config.config.contextual_priorities) {
|
1634
|
-
console.log(JSON.stringify(contextual_priority))
|
1635
|
-
}
|
1636
|
-
}
|
1637
1640
|
if (args.print.includes('h')) {
|
1638
1641
|
for (let edge of config.config.hierarchy) {
|
1639
1642
|
console.log(JSON.stringify(edge))
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -23,13 +23,6 @@ const indent = (string, indent) => {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
const config_toServer = (config) => {
|
26
|
-
/*
|
27
|
-
if (config.contextual_priorities) {
|
28
|
-
config.contextual_priorities = config.contextual_priorities.map((cp) => {
|
29
|
-
return [cp.context, cp.choose]
|
30
|
-
})
|
31
|
-
}
|
32
|
-
*/
|
33
26
|
}
|
34
27
|
|
35
28
|
const debugPriority = (priority) => {
|
@@ -48,14 +41,6 @@ const debugAssociation = (association) => {
|
|
48
41
|
}
|
49
42
|
}
|
50
43
|
|
51
|
-
const debugContextualPriority = (contextual_priority) => {
|
52
|
-
if (global.entodictonDebugContextualPriority) {
|
53
|
-
if (helpers.safeEquals(entodictonDebugContextualPriority, contextual_priority)) {
|
54
|
-
debugger; // debug hierarchy hit
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
44
|
const debugHierarchy = (pair) => {
|
60
45
|
if (global.entodictonDebugHierarchy) {
|
61
46
|
if (helpers.safeEquals(global.entodictonDebugHierarchy, pair)) {
|
@@ -87,7 +72,6 @@ const debugConfigProps = (config) => {
|
|
87
72
|
const checkProps = [
|
88
73
|
{ property: 'priorities', check: (v) => debugPriority(v) },
|
89
74
|
{ property: 'association', check: (v) => debugAssociation(v) },
|
90
|
-
{ property: 'contextual_priorities', check: (v) => debugContextualPriority(v) },
|
91
75
|
{ property: 'hierarchy', check: (v) => debugHierarchy(v) },
|
92
76
|
{ property: 'operators', check: (v) => debugOperator(v) },
|
93
77
|
{ property: 'bridges', check: (v) => debugBridge(v) },
|
@@ -109,7 +93,6 @@ const validConfigProps = (config) => {
|
|
109
93
|
'operators',
|
110
94
|
'words',
|
111
95
|
'priorities',
|
112
|
-
'contextual_priorities',
|
113
96
|
'associations',
|
114
97
|
'name',
|
115
98
|
'version',
|
@@ -188,20 +171,20 @@ const elist = (list, check, prefix) => {
|
|
188
171
|
}
|
189
172
|
}
|
190
173
|
}
|
191
|
-
const
|
192
|
-
elist(cps, (cp) =>
|
174
|
+
const priorities_valid = (cps) => {
|
175
|
+
elist(cps, (cp) => priority_valid(cp), (index, e) => `priorities has an invalid priority at position ${index}. ${e}`)
|
193
176
|
}
|
194
177
|
|
195
|
-
const
|
178
|
+
const priority_valid = (cp) => {
|
196
179
|
if (!cp.context) {
|
197
|
-
throw new Error(`The
|
180
|
+
throw new Error(`The priority ${JSON.stringify(cp)} is missing the "context" property. That is a list of the operator keys that are to be prioritized differently.`)
|
198
181
|
}
|
199
182
|
if (!_.isArray(cp.context)) {
|
200
|
-
throw new Error(`The
|
183
|
+
throw new Error(`The priority ${JSON.stringify(cp)} has an invalid "context" value. That is a list of the operator keys that are to be prioritized differently.`)
|
201
184
|
}
|
202
|
-
elist(cp.context, (element) => operatorKey_valid(element), (index, e) => `The
|
185
|
+
elist(cp.context, (element) => operatorKey_valid(element), (index, e) => `The priority ${JSON.stringify(cp)} has an invalid operator key at position ${index}. ${e}`)
|
203
186
|
if (!_.isArray(cp.choose)) {
|
204
|
-
throw new Error(`The
|
187
|
+
throw new Error(`The priority ${JSON.stringify(cp)} has an invalid "choose" value. The value should be a list of the operators in the context to consider for prioritization.`)
|
205
188
|
}
|
206
189
|
elist(cp.choose,
|
207
190
|
(element) => {
|
@@ -212,7 +195,7 @@ const contextual_priority_valid = (cp) => {
|
|
212
195
|
throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization. Valid values are between 0 and ${cp.context.length-1}.`)
|
213
196
|
}
|
214
197
|
},
|
215
|
-
(index, e) => `The choose property in the
|
198
|
+
(index, e) => `The choose property in the priority ${JSON.stringify(cp)} has an invalid index at position ${index}. ${e}`
|
216
199
|
)
|
217
200
|
}
|
218
201
|
|
@@ -245,7 +228,7 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
245
228
|
if (typeof after == 'string') {
|
246
229
|
after = [after, 0]
|
247
230
|
}
|
248
|
-
config.
|
231
|
+
config.addPriority({ context: [[bridge.id, bridge.level], after], choose: [0] })
|
249
232
|
}
|
250
233
|
}
|
251
234
|
if (bridge.after) {
|
@@ -253,7 +236,7 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
253
236
|
if (typeof before == 'string') {
|
254
237
|
before = [before, 0]
|
255
238
|
}
|
256
|
-
config.
|
239
|
+
config.addPriority({ context: [before, [bridge.id, bridge.level]], choose: [0] })
|
257
240
|
}
|
258
241
|
}
|
259
242
|
if (bridge.words) {
|
@@ -381,6 +364,11 @@ if (runtime.process.env.DEBUG_HIERARCHY) {
|
|
381
364
|
global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
|
382
365
|
}
|
383
366
|
|
367
|
+
|
368
|
+
// i keep randomly doing one of the other so I will just make both work the same way
|
369
|
+
if (runtime.process.env.DEBUG_PRIORITIES) {
|
370
|
+
global.entodictonDebugPriority = JSON.parse(runtime.process.env.DEBUG_PRIORITIES)
|
371
|
+
}
|
384
372
|
if (runtime.process.env.DEBUG_PRIORITY) {
|
385
373
|
global.entodictonDebugPriority = JSON.parse(runtime.process.env.DEBUG_PRIORITY)
|
386
374
|
}
|
@@ -739,10 +727,10 @@ class Config {
|
|
739
727
|
addAssociation: (...args) => this.addAssociation(...args),
|
740
728
|
addAssociations: (...args) => this.addAssociations(...args),
|
741
729
|
addBridge: (...args) => this.addBridge(...args, uuid),
|
742
|
-
addContextualPriority: (...args) => this.addContextualPriority(...args),
|
743
730
|
addGenerator: (...args) => this.addGenerator(...args, uuid, config.name),
|
744
731
|
addHierarchy: (...args) => this.addHierarchy(...args),
|
745
732
|
addOperator: (...args) => this.addOperator(...args, uuid),
|
733
|
+
addPriority: (...args) => this.addPriority(...args),
|
746
734
|
addPriorities: (...args) => this.addPriorities(...args),
|
747
735
|
addSemantic: (...args) => this.addSemantic(...args, uuid, config.name),
|
748
736
|
removeSemantic: (...args) => this.removeSemantic(...args, uuid, config.name),
|
@@ -815,7 +803,6 @@ class Config {
|
|
815
803
|
},
|
816
804
|
eqClasses: [],
|
817
805
|
priorities: [], // Done
|
818
|
-
contextual_priorities: [],
|
819
806
|
version: '3',
|
820
807
|
debug: false,
|
821
808
|
associations: { // Done
|
@@ -854,7 +841,6 @@ class Config {
|
|
854
841
|
'namespaces',
|
855
842
|
'eqClasses',
|
856
843
|
'priorities',
|
857
|
-
'contextual_priorities',
|
858
844
|
'associations',
|
859
845
|
'words',
|
860
846
|
'floaters',
|
@@ -1053,16 +1039,6 @@ class Config {
|
|
1053
1039
|
this.validifyTemplate(template)
|
1054
1040
|
instance.template = template
|
1055
1041
|
this.logs.push(`loading template for ${this.name}`)
|
1056
|
-
/*
|
1057
|
-
if (instance && (instance.associations || instance.learned_contextual_priorities) && !options.rebuild) {
|
1058
|
-
if (instance.associations) {
|
1059
|
-
this.addAssociations(instance.associations)
|
1060
|
-
}
|
1061
|
-
if (instance.learned_contextual_priorities && instance.learned_contextual_priorities.length > 0) {
|
1062
|
-
this.addContextualPriorities(instance.learned_contextual_priorities)
|
1063
|
-
}
|
1064
|
-
}
|
1065
|
-
*/
|
1066
1042
|
if (options.rebuild) {
|
1067
1043
|
// TODO fix beforeQuery
|
1068
1044
|
template = { fragments: [], queries: [], ...template }
|
@@ -1111,12 +1087,6 @@ class Config {
|
|
1111
1087
|
}
|
1112
1088
|
}
|
1113
1089
|
|
1114
|
-
addContextualPriorities (cps) {
|
1115
|
-
for (let cp of cps) {
|
1116
|
-
this.addContextualPriority(cp)
|
1117
|
-
}
|
1118
|
-
}
|
1119
|
-
|
1120
1090
|
debugConfig() {
|
1121
1091
|
}
|
1122
1092
|
|
@@ -1134,24 +1104,21 @@ class Config {
|
|
1134
1104
|
|
1135
1105
|
// TODO add more error checking to these like addHierarchy has
|
1136
1106
|
// TODO change name from priorities to priority
|
1137
|
-
|
1107
|
+
// [ context: <list of [id, level]>, choose: [<indexes of prioritized operator>], [ordered: [true|false]] ]
|
1108
|
+
addPriority (priority) {
|
1138
1109
|
if (!this.config.priorities) {
|
1139
1110
|
this.config.priorities = []
|
1140
1111
|
}
|
1141
|
-
debugPriority(
|
1142
|
-
|
1143
|
-
this.
|
1112
|
+
debugPriority(priority)
|
1113
|
+
priority_valid(priority)
|
1114
|
+
this.config.priorities.push(priority)
|
1115
|
+
this._delta.json.priorities.push({ action: 'add', priority })
|
1144
1116
|
}
|
1145
1117
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
this.config.contextual_priorities = []
|
1118
|
+
addPriorities (priorities) {
|
1119
|
+
for (let priority of priorities) {
|
1120
|
+
this.addPriority(priority)
|
1150
1121
|
}
|
1151
|
-
debugContextualPriority(contextual_priority)
|
1152
|
-
contextual_priority_valid(contextual_priority)
|
1153
|
-
this.config.contextual_priorities.push(contextual_priority)
|
1154
|
-
this._delta.json.contextual_priorities.push({ action: 'add', contextual_priority: contextual_priority })
|
1155
1122
|
}
|
1156
1123
|
|
1157
1124
|
addHierarchy (child, parent) {
|
@@ -1549,7 +1516,6 @@ class Config {
|
|
1549
1516
|
config.hierarchy = config.hierarchy || []
|
1550
1517
|
config.associations = config.associations || { negative: [], positive: [] }
|
1551
1518
|
config.priorities = config.priorities || []
|
1552
|
-
config.contextual_priorities = config.contextual_priorities || []
|
1553
1519
|
}
|
1554
1520
|
|
1555
1521
|
this.maxDepth = 20 // for generators and semantics
|
@@ -1603,8 +1569,8 @@ class Config {
|
|
1603
1569
|
}
|
1604
1570
|
}
|
1605
1571
|
|
1606
|
-
if (config && config.
|
1607
|
-
|
1572
|
+
if (config && config.priorities) {
|
1573
|
+
priorities_valid(config.priorities)
|
1608
1574
|
}
|
1609
1575
|
|
1610
1576
|
normalizeConfig(config)
|
@@ -1692,7 +1658,6 @@ class Config {
|
|
1692
1658
|
bridges: [],
|
1693
1659
|
associations: [],
|
1694
1660
|
priorities: [],
|
1695
|
-
contextual_priorities: [],
|
1696
1661
|
hierarchy: [],
|
1697
1662
|
}
|
1698
1663
|
}
|
@@ -2322,7 +2287,6 @@ class Config {
|
|
2322
2287
|
bridges: this.config.bridges,
|
2323
2288
|
hierarchy: this.config.hierarchy,
|
2324
2289
|
priorities: this.config.priorities,
|
2325
|
-
contextual_priorities: this.config.contextual_priorities,
|
2326
2290
|
associations: this.config.associations,
|
2327
2291
|
words: this.config.words
|
2328
2292
|
}
|
@@ -2331,7 +2295,6 @@ class Config {
|
|
2331
2295
|
this.config.bridges = []
|
2332
2296
|
this.config.hierarchy = []
|
2333
2297
|
this.config.priorities = []
|
2334
|
-
this.config.contextual_priorities = []
|
2335
2298
|
this.config.associations = { positive: [], negative: [] }
|
2336
2299
|
this.config.words = {}
|
2337
2300
|
|
@@ -2540,25 +2503,20 @@ class Config {
|
|
2540
2503
|
|
2541
2504
|
if (config.priorities) {
|
2542
2505
|
let priorities = config.priorities
|
2543
|
-
priorities = priorities.map((
|
2544
|
-
return { ...p, context: p.context.map( (id) => [toNS(id[0]), id[1]] )}
|
2545
|
-
})
|
2546
|
-
config.priorities = priorities
|
2547
|
-
}
|
2548
|
-
|
2549
|
-
if (config.contextual_priorities) {
|
2550
|
-
let contextual_priorities = config.contextual_priorities
|
2551
|
-
contextual_priorities = contextual_priorities.map((cp) => {
|
2506
|
+
priorities = priorities.map((cp) => {
|
2552
2507
|
const { context, choose, ordered } = cp
|
2553
|
-
|
2508
|
+
const priority = {
|
2554
2509
|
context: context.map((id) => {
|
2555
2510
|
return [toNS(id[0]), id[1]]
|
2556
2511
|
}),
|
2557
2512
|
choose,
|
2558
|
-
ordered
|
2559
2513
|
}
|
2514
|
+
if (ordered) {
|
2515
|
+
priority.ordered = ordered
|
2516
|
+
}
|
2517
|
+
return priority
|
2560
2518
|
})
|
2561
|
-
config.
|
2519
|
+
config.priorities = priorities
|
2562
2520
|
}
|
2563
2521
|
|
2564
2522
|
for (const bag of bags) {
|