theprogrammablemind 7.5.0-beta.0 → 7.5.0-beta.2
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.
- package/package.json +1 -1
- package/src/config.js +31 -6
- package/src/digraph.js +24 -7
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -593,18 +593,24 @@ class Config {
|
|
593
593
|
}
|
594
594
|
}
|
595
595
|
|
596
|
-
addHierarchyProperties (
|
597
|
-
|
596
|
+
addHierarchyProperties (edge) {
|
597
|
+
const { child, parent } = edge
|
598
|
+
if (typeof child !== 'string') {
|
598
599
|
throw `addHierarchy expected child property to be a string. got ${JSON.stringify(child)}`
|
599
600
|
}
|
600
|
-
if (typeof
|
601
|
-
throw `addHierarchy expected parent
|
601
|
+
if (typeof parent !== 'string') {
|
602
|
+
throw `addHierarchy expected parent property to be a string. got ${JSON.stringify(parent)}`
|
602
603
|
}
|
603
604
|
if (!this.config.hierarchy) {
|
604
605
|
this.config.hierarchy = []
|
605
606
|
}
|
606
|
-
|
607
|
-
|
607
|
+
if (global.entodictonDebugHierarchy) {
|
608
|
+
if (deepEqual(global.entodictonDebugHierarchy, [child, parent])) {
|
609
|
+
debugger; // debug hierarchy hit
|
610
|
+
}
|
611
|
+
}
|
612
|
+
this.config.hierarchy.push(edge)
|
613
|
+
// TODO greg11 this.hierarchy.addEdge(edge)
|
608
614
|
this._delta.json.hierarchy.push([child, parent])
|
609
615
|
}
|
610
616
|
|
@@ -615,6 +621,7 @@ class Config {
|
|
615
621
|
if (typeof parent !== 'string') {
|
616
622
|
throw `addHierarchy expected parent to be a string. got ${JSON.stringify(parent)}`
|
617
623
|
}
|
624
|
+
|
618
625
|
if (!this.config.hierarchy) {
|
619
626
|
this.config.hierarchy = []
|
620
627
|
}
|
@@ -623,6 +630,7 @@ class Config {
|
|
623
630
|
debugger; // debug hierarchy hit
|
624
631
|
}
|
625
632
|
}
|
633
|
+
|
626
634
|
if (this.config.hierarchy.find( (element) => {
|
627
635
|
const hc = hierarchyCanonical(element)
|
628
636
|
if (child == hc.child && parent == hc.parent) {
|
@@ -633,6 +641,7 @@ class Config {
|
|
633
641
|
}
|
634
642
|
|
635
643
|
this.config.hierarchy.push([child, parent])
|
644
|
+
// this.hierarchy.addEdge([child, parent])
|
636
645
|
this._delta.json.hierarchy.push([child, parent])
|
637
646
|
}
|
638
647
|
|
@@ -1006,6 +1015,15 @@ class Config {
|
|
1006
1015
|
'flatten',
|
1007
1016
|
]
|
1008
1017
|
helpers.validProps(valid, config, 'config')
|
1018
|
+
|
1019
|
+
config.operators = config.operators || []
|
1020
|
+
config.bridges = config.bridges || []
|
1021
|
+
config.words = config.words || {}
|
1022
|
+
config.generators = config.generators || []
|
1023
|
+
config.semantics = config.semantics || []
|
1024
|
+
config.hierarchy = config.hierarchy || []
|
1025
|
+
config.associations = config.associations || { negative: [], positive: [] }
|
1026
|
+
config.priorities = config.priorities || []
|
1009
1027
|
}
|
1010
1028
|
|
1011
1029
|
this.allowDelta = false
|
@@ -1648,6 +1666,13 @@ class Config {
|
|
1648
1666
|
return false
|
1649
1667
|
}
|
1650
1668
|
|
1669
|
+
/* TODO greg11
|
1670
|
+
if (!this.hierarchy) {
|
1671
|
+
debugBreak()
|
1672
|
+
return false
|
1673
|
+
}
|
1674
|
+
*/
|
1675
|
+
|
1651
1676
|
for (const key in this.config.words) {
|
1652
1677
|
const values = this.config.words[key]
|
1653
1678
|
if (values.some((word) => (Object.keys(word).includes('uuid') && !word.uuid))) {
|
package/src/digraph.js
CHANGED
@@ -9,21 +9,38 @@ const toA = (edge) => {
|
|
9
9
|
class Digraph {
|
10
10
|
// edges maybe either [child, parent] or { child, parent }
|
11
11
|
constructor (edges = []) {
|
12
|
-
this.
|
12
|
+
// dont make a copy of edges. this is shared and that breaks stuff. TODO fix this
|
13
|
+
this._edges = edges
|
13
14
|
}
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
addEdges(edges) {
|
17
|
+
for (let edge of edges) {
|
18
|
+
this.addEdge(edge)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
addEdge(edge) {
|
23
|
+
edge = toA(edge)
|
24
|
+
this._edges.push(edge)
|
25
|
+
}
|
26
|
+
|
27
|
+
get edges() {
|
28
|
+
return this._edges
|
29
|
+
}
|
30
|
+
|
31
|
+
/*
|
32
|
+
set edges(edges) {
|
33
|
+
this._edges = edges.map( toA )
|
18
34
|
}
|
19
35
|
*/
|
36
|
+
|
20
37
|
acdcs (s, from, to) {
|
21
38
|
const todo = [s]
|
22
39
|
const seen = new Set([s])
|
23
40
|
const acdcs = new Set([])
|
24
41
|
while (todo.length > 0) {
|
25
42
|
const n = todo.pop()
|
26
|
-
this.
|
43
|
+
this._edges.forEach((e) => {
|
27
44
|
e = toA(e)
|
28
45
|
if (e[from] === n) {
|
29
46
|
acdcs.add(e[to])
|
@@ -84,12 +101,12 @@ class Digraph {
|
|
84
101
|
}
|
85
102
|
|
86
103
|
add (child, parent) {
|
87
|
-
this.
|
104
|
+
this._edges.push([child, parent])
|
88
105
|
}
|
89
106
|
|
90
107
|
addList (l) {
|
91
108
|
for (let i = 1; i < l.length; ++i) {
|
92
|
-
this.
|
109
|
+
this._edges.push([l[i - 1], l[i]])
|
93
110
|
}
|
94
111
|
}
|
95
112
|
|