Comparing version
29
index.js
@@ -192,3 +192,3 @@ var Tree = require("./lib/BTree"); | ||
} | ||
} else { // the prefix of the sistring and all sistrings of the internal node do not match | ||
} else { // the prefix of the sistring and all sistringRepres of the internal node do not match | ||
this._rebuildInternalSubtree(tree, node, sistring, index); | ||
@@ -235,3 +235,2 @@ } | ||
var subtreeRoot = subtree.getRoot(); | ||
@@ -244,3 +243,3 @@ subtreeRoot.data = { | ||
totalFrequency: 0, | ||
sistrings: [] | ||
sistringRepres: externalNode | ||
}; | ||
@@ -291,3 +290,3 @@ | ||
var owner = this; | ||
var sistrings = []; | ||
//var sistringRepres = []; | ||
var left = node.left; | ||
@@ -301,7 +300,7 @@ var right = node.right; | ||
totalFrequency += left.data.totalFrequency; | ||
sistrings = sistrings.concat(left.data.sistrings); | ||
//sistringRepres = sistringRepres.concat(left.data.sistringRepres); | ||
} else if(left.data.type == owner.EXTERNAL) { | ||
externalNodeNum += 1; | ||
totalFrequency += left.data.indexes.length; | ||
sistrings.push(left); | ||
//sistringRepres.push(left); | ||
} else { | ||
@@ -314,7 +313,7 @@ console.trace(); | ||
totalFrequency += right.data.totalFrequency; | ||
sistrings = sistrings.concat(right.data.sistrings); | ||
//sistringRepres = sistringRepres.concat(right.data.sistringRepres); | ||
} else if(right.data.type == owner.EXTERNAL) { | ||
externalNodeNum += 1; | ||
totalFrequency += right.data.indexes.length; | ||
sistrings.push(right); | ||
//sistringRepres.push(right); | ||
} else { | ||
@@ -328,3 +327,3 @@ console.trace(); | ||
} | ||
node.data.sistrings = sistrings; | ||
//node.data.sistringRepres = sistringRepres; | ||
node.data.externalNodeNum = externalNodeNum; | ||
@@ -416,3 +415,3 @@ node.data.totalFrequency = totalFrequency; | ||
var prefix = internalNode.data.prefix; | ||
var externalNode = internalNode.data.sistrings[0]; | ||
var externalNode = internalNode.data.sistringRepres; | ||
var index = externalNode.data.indexes[0]; | ||
@@ -481,8 +480,6 @@ var indexes = index.split("."); | ||
{ | ||
console.log("sistrings: "); | ||
for(var i = 0; i < node.data.sistrings.length; i++) { | ||
var externalNode = node.data.sistrings[i]; | ||
console.log(" sistring: " + owner._restoreSistring(externalNode)); | ||
console.log(" indexes: " + externalNode.data.indexes); | ||
} | ||
console.log("sistringRepres: "); | ||
var externalNode = node.data.sistringRepres; | ||
console.log(" sistring: " + owner._restoreSistring(externalNode)); | ||
console.log(" indexes: " + externalNode.data.indexes); | ||
} | ||
@@ -489,0 +486,0 @@ |
{ | ||
"name": "pat-tree", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "PAT tree construction for Chinese documents", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -84,3 +84,3 @@ pat-tree | ||
totalFrequency: 89, // number of the total frequency of the external nodes in the collection, data type: integer | ||
sistrings: ArrayOfExternalNodes // array of external nodes, data type: array | ||
sistringRepres: node // one of the external node in the subree of this internal node, data type: Node | ||
} | ||
@@ -104,5 +104,5 @@ | ||
[ [ '嗨你好', | ||
'這是測試文件1' ], | ||
'這是測試文件' ], | ||
[ '你好', | ||
'這是測試文件2' ] ] | ||
'這是另外一個測試文件' ] ] | ||
@@ -117,2 +117,3 @@ An index is in following structure: | ||
* 0.1.8 Alter algorithm, improve simplicity | ||
* 0.1.7 Improve performance | ||
@@ -119,0 +120,0 @@ * 0.1.6 Improve performance |
27489
0.4%124
0.81%795
-0.25%