|
|
@ -19112,6 +19112,7 @@
|
|
|
|
var word = null;
|
|
|
|
var word = null;
|
|
|
|
var count = 0;
|
|
|
|
var count = 0;
|
|
|
|
var len = seq.words.length;
|
|
|
|
var len = seq.words.length;
|
|
|
|
|
|
|
|
var root = seq.newWord ? seq.newWord.word : undefined
|
|
|
|
|
|
|
|
|
|
|
|
var _loop = function _loop(s) {
|
|
|
|
var _loop = function _loop(s) {
|
|
|
|
var fdist = {};
|
|
|
|
var fdist = {};
|
|
|
@ -19133,6 +19134,8 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(seq)
|
|
|
|
|
|
|
|
|
|
|
|
var maxw = null;
|
|
|
|
var maxw = null;
|
|
|
|
var maxc = 0;
|
|
|
|
var maxc = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -19143,20 +19146,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
words.forEach(function(w) {
|
|
|
|
words.forEach(function(w) {
|
|
|
|
var value = fdist[w];
|
|
|
|
var value = fdist[w];
|
|
|
|
//if (value < maxSupport && (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase > maxc) {
|
|
|
|
var distRatio = 0.1
|
|
|
|
//if (value < maxSupport && value > maxc && (stopwords.indexOf(itemset[w]) < 0 || isNotRoot)) {
|
|
|
|
if (root) {
|
|
|
|
if (value < maxSupport && value > maxc && stopwords.indexOf(itemset[w]) < 0) {
|
|
|
|
var dist = Math.abs(words.indexOf(w) - words.indexOf(root))
|
|
|
|
maxw = +w;
|
|
|
|
}
|
|
|
|
//maxc = (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase
|
|
|
|
switch (mode) {
|
|
|
|
maxc = value
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
if (!root) {
|
|
|
|
|
|
|
|
if (value < maxSupport && value > maxc && stopwords.indexOf(itemset[w]) < 0) {
|
|
|
|
|
|
|
|
maxw = +w
|
|
|
|
|
|
|
|
maxc = value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (value < maxSupport && (value * Math.pow(distRatio, dist - 1)) > maxc && stopwords.indexOf(itemset[w]) < 0 && dist == 1) {
|
|
|
|
|
|
|
|
maxw = +w
|
|
|
|
|
|
|
|
maxc = value
|
|
|
|
|
|
|
|
console.log(maxc)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
if (value < maxSupport && (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase > maxc) {
|
|
|
|
|
|
|
|
//if (value < maxSupport && value > maxc && (stopwords.indexOf(itemset[w]) < 0 || isNotRoot)) {
|
|
|
|
|
|
|
|
//if (value < maxSupport && value > maxc && stopwords.indexOf(itemset[w]) < 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxw = +w;
|
|
|
|
|
|
|
|
maxc = (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase
|
|
|
|
|
|
|
|
//maxc = value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
//if (value < maxSupport && (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase > maxc) {
|
|
|
|
|
|
|
|
if (value < maxSupport && value > maxc && (stopwords.indexOf(itemset[w]) < 0 || isNotRoot)) {
|
|
|
|
|
|
|
|
//if (value < maxSupport && value > maxc && stopwords.indexOf(itemset[w]) < 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxw = +w;
|
|
|
|
|
|
|
|
//maxc = (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase
|
|
|
|
|
|
|
|
maxc = value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
//if (value < maxSupport && value > maxc && (stopwords.indexOf(itemset[w]) < 0 || isNotRoot)) {
|
|
|
|
|
|
|
|
if (value < maxSupport && value > maxc && stopwords.indexOf(itemset[w]) < 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxw = +w;
|
|
|
|
|
|
|
|
//maxc = (value / Math.max(idfTable[itemset[w]], idfBase)) * idfBase
|
|
|
|
|
|
|
|
maxc = value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log(itemset)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (maxc > count) {
|
|
|
|
if (maxc > count) {
|
|
|
|
pos = s;
|
|
|
|
pos = s;
|
|
|
|
word = maxw;
|
|
|
|
word = maxw;
|
|
|
|
count = maxc;
|
|
|
|
count = maxc;
|
|
|
|
|
|
|
|
console.log({ 'word#': maxw, 'word': itemset[maxw], 'root': seq.newWord ? seq.newWord.entity : null, 'count': root ? count : "root" })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -19188,7 +19236,6 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log({ 's0': s0, 's1': s1 })
|
|
|
|
|
|
|
|
return { word: word, pos: pos, count: count, s0: s0, s1: s1 };
|
|
|
|
return { word: word, pos: pos, count: count, s0: s0, s1: s1 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -19206,12 +19253,10 @@
|
|
|
|
seqs.push(rootSeq);
|
|
|
|
seqs.push(rootSeq);
|
|
|
|
var leafSeqs = [];
|
|
|
|
var leafSeqs = [];
|
|
|
|
|
|
|
|
|
|
|
|
console.log(JSON.parse(JSON.stringify(seqs)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!seqs.empty() && expandCnt > 0) {
|
|
|
|
while (!seqs.empty() && expandCnt > 0) {
|
|
|
|
/* find the candidate sequence with largest support DB */
|
|
|
|
/* find the candidate sequence with largest support DB */
|
|
|
|
var s = seqs.pop();
|
|
|
|
var s = seqs.pop();
|
|
|
|
console.log({ 's': s, 'seqs': seqs })
|
|
|
|
|
|
|
|
var graph = s.graph;
|
|
|
|
var graph = s.graph;
|
|
|
|
var s0 = s.r;
|
|
|
|
var s0 = s.r;
|
|
|
|
var s1 = s.l;
|
|
|
|
var s1 = s.l;
|
|
|
@ -19219,7 +19264,6 @@
|
|
|
|
if (!s0 && !s1) {
|
|
|
|
if (!s0 && !s1) {
|
|
|
|
/* find the next frequent sequence */
|
|
|
|
/* find the next frequent sequence */
|
|
|
|
var result = growSeq(s, terms, minSupport, maxSupport, itemset);
|
|
|
|
var result = growSeq(s, terms, minSupport, maxSupport, itemset);
|
|
|
|
console.log(result)
|
|
|
|
|
|
|
|
s0 = result.s0;
|
|
|
|
s0 = result.s0;
|
|
|
|
s1 = result.s1;
|
|
|
|
s1 = result.s1;
|
|
|
|
var word = result.word,
|
|
|
|
var word = result.word,
|
|
|
@ -19237,6 +19281,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var newWord = {
|
|
|
|
var newWord = {
|
|
|
|
id: graph.totalNodeCnt++,
|
|
|
|
id: graph.totalNodeCnt++,
|
|
|
|
|
|
|
|
word: word,
|
|
|
|
entity: itemset[word],
|
|
|
|
entity: itemset[word],
|
|
|
|
freq: count,
|
|
|
|
freq: count,
|
|
|
|
topEntries: s1.DBs.slice(0, 5),
|
|
|
|
topEntries: s1.DBs.slice(0, 5),
|
|
|
@ -19306,7 +19351,6 @@
|
|
|
|
var str = words.map(function(w) {
|
|
|
|
var str = words.map(function(w) {
|
|
|
|
return w.entity;
|
|
|
|
return w.entity;
|
|
|
|
}).join(' ');
|
|
|
|
}).join(' ');
|
|
|
|
console.log(str);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var SentenTreeModel = function() {
|
|
|
|
var SentenTreeModel = function() {
|
|
|
@ -19336,7 +19380,6 @@
|
|
|
|
var size = tokenizedData.computeSize();
|
|
|
|
var size = tokenizedData.computeSize();
|
|
|
|
|
|
|
|
|
|
|
|
this.supportRange = [Math.max(size * minSupportRatio, minSupportCount), size * maxSupportRatio];
|
|
|
|
this.supportRange = [Math.max(size * minSupportRatio, minSupportCount), size * maxSupportRatio];
|
|
|
|
console.log(this.supportRange)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _supportRange = _slicedToArray(this.supportRange, 2),
|
|
|
|
var _supportRange = _slicedToArray(this.supportRange, 2),
|
|
|
|
minSupport = _supportRange[0],
|
|
|
|
minSupport = _supportRange[0],
|
|
|
@ -19386,11 +19429,9 @@
|
|
|
|
key: 'getRenderedGraphs',
|
|
|
|
key: 'getRenderedGraphs',
|
|
|
|
value: function getRenderedGraphs(limit) {
|
|
|
|
value: function getRenderedGraphs(limit) {
|
|
|
|
var graphs = arguments.length === 1 ? this.graphs.slice(0, limit) : this.graphs;
|
|
|
|
var graphs = arguments.length === 1 ? this.graphs.slice(0, limit) : this.graphs;
|
|
|
|
console.log("slice")
|
|
|
|
|
|
|
|
var renderedGraphs = graphs.map(function(g) {
|
|
|
|
var renderedGraphs = graphs.map(function(g) {
|
|
|
|
return g.toRenderedGraph();
|
|
|
|
return g.toRenderedGraph();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log("toRenderedGraph")
|
|
|
|
|
|
|
|
var globalFreqRange = [(0, _lodash.min)(renderedGraphs.map(function(g) {
|
|
|
|
var globalFreqRange = [(0, _lodash.min)(renderedGraphs.map(function(g) {
|
|
|
|
return g.freqRange[0];
|
|
|
|
return g.freqRange[0];
|
|
|
|
})), (0, _lodash.max)(renderedGraphs.map(function(g) {
|
|
|
|
})), (0, _lodash.max)(renderedGraphs.map(function(g) {
|
|
|
@ -37869,15 +37910,12 @@
|
|
|
|
let counter = 1;
|
|
|
|
let counter = 1;
|
|
|
|
|
|
|
|
|
|
|
|
while (heap.size() > 0) {
|
|
|
|
while (heap.size() > 0) {
|
|
|
|
console.log(`in while ${counter++}`)
|
|
|
|
|
|
|
|
var parent = heap.pop();
|
|
|
|
var parent = heap.pop();
|
|
|
|
console.log(heap)
|
|
|
|
|
|
|
|
if (parent.merged) {
|
|
|
|
if (parent.merged) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var groups = [];
|
|
|
|
var groups = [];
|
|
|
|
console.log(parent.data.id)
|
|
|
|
|
|
|
|
if (parent.leftLinks.length > 1) {
|
|
|
|
if (parent.leftLinks.length > 1) {
|
|
|
|
var lNodes = parent.leftLinks.map(function(l) {
|
|
|
|
var lNodes = parent.leftLinks.map(function(l) {
|
|
|
|
return l.source;
|
|
|
|
return l.source;
|
|
|
@ -37891,7 +37929,6 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
groups = groups.concat(this.groupMergeableNodes(rNodes));
|
|
|
|
groups = groups.concat(this.groupMergeableNodes(rNodes));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(groups)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groups.length > 0) {
|
|
|
|
if (groups.length > 0) {
|
|
|
|
var newNodes = groups.map(function(group) {
|
|
|
|
var newNodes = groups.map(function(group) {
|
|
|
@ -38119,7 +38156,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
var RenderedGraph = function() {
|
|
|
|
var RenderedGraph = function() {
|
|
|
|
function RenderedGraph(rawGraph) {
|
|
|
|
function RenderedGraph(rawGraph) {
|
|
|
|
console.log(arguments)
|
|
|
|
|
|
|
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
|
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
|
|
_ref$bundle = _ref.bundle,
|
|
|
|
_ref$bundle = _ref.bundle,
|
|
|
|
bundle = _ref$bundle === undefined ? true : _ref$bundle,
|
|
|
|
bundle = _ref$bundle === undefined ? true : _ref$bundle,
|
|
|
@ -38152,10 +38188,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
this.assignNodeIds(nodes);
|
|
|
|
this.assignNodeIds(nodes);
|
|
|
|
|
|
|
|
|
|
|
|
console.log(bundle)
|
|
|
|
|
|
|
|
if (bundle) {
|
|
|
|
if (bundle) {
|
|
|
|
var bundled = new _GraphBundler2.default(nodes, links).bundle();
|
|
|
|
var bundled = new _GraphBundler2.default(nodes, links).bundle();
|
|
|
|
console.log(bundled)
|
|
|
|
|
|
|
|
this.nodes = bundled.nodes;
|
|
|
|
this.nodes = bundled.nodes;
|
|
|
|
this.links = bundled.links;
|
|
|
|
this.links = bundled.links;
|
|
|
|
this.assignNodeIds(this.nodes);
|
|
|
|
this.assignNodeIds(this.nodes);
|
|
|
@ -43071,11 +43105,10 @@
|
|
|
|
var l3 = l * l * l;
|
|
|
|
var l3 = l * l * l;
|
|
|
|
var hs = 2 * -weight / (D2 * l3);
|
|
|
|
var hs = 2 * -weight / (D2 * l3);
|
|
|
|
if (!isFinite(gs))
|
|
|
|
if (!isFinite(gs))
|
|
|
|
console.log(gs);
|
|
|
|
for (i = 0; i < this.k; ++i) {
|
|
|
|
for (i = 0; i < this.k; ++i) {
|
|
|
|
this.g[i][u] += d[i] * gs;
|
|
|
|
this.g[i][u] += d[i] * gs;
|
|
|
|
Huu[i] -= this.H[i][u][v] = hs * (l3 + D * (d2[i] - sd2) + l * sd2);
|
|
|
|
Huu[i] -= this.H[i][u][v] = hs * (l3 + D * (d2[i] - sd2) + l * sd2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < this.k; ++i)
|
|
|
|
for (i = 0; i < this.k; ++i)
|
|
|
|
maxH = Math.max(maxH, this.H[i][u][u] = Huu[i]);
|
|
|
|
maxH = Math.max(maxH, this.H[i][u][u] = Huu[i]);
|
|
|
|