New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pat-tree

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pat-tree - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

42

index.js

@@ -125,3 +125,3 @@ var Tree = require("./lib/BTree");

//console.log("check connection: " + this._checkConnections());
//this._printTreeContent();
//this.printTreeContent();
}

@@ -141,12 +141,12 @@ },

//console.log(sistring);
this._insert(tree, tree.root.id, sistring, index);
this._insert(tree, tree.root, sistring, index);
this._updateParents();
},
_insert: function(tree, nodeId, sistring, index) {
var node = tree.getNode(nodeId);
_insert: function(tree, node, sistring, index) {
//var node = tree.getNode(nodeId);
var indexes = [];
indexes.push(index);
if(tree.isRoot(nodeId) && tree.root.data == null) {
tree.setNodeData(nodeId, {
if(tree.isRoot(node) && tree.root.data == null) {
tree.setNodeData(node, {
type: this.EXTERNAL,

@@ -175,5 +175,5 @@ sistring: sistring,

};
tree.appendLeftChild(nodeId, leftChild);
tree.appendLeftChild(node, leftChild);
} else {
this._insert(tree, node.left.id, sistring, index);
this._insert(tree, node.left, sistring, index);
}

@@ -188,5 +188,5 @@ } else if(branchBit == 1) {

}
tree.appendRightChild(nodeId, rightChild);
tree.appendRightChild(node, rightChild);
} else {
this._insert(tree, node.right.id, sistring, index);
this._insert(tree, node.right, sistring, index);
}

@@ -251,8 +251,8 @@ } else {

var type = tree.getNodeType(node.id);
var type = tree.getNodeType(node);
if(type == "left") {
tree.detachLeftChild(parent.id);
tree.detachLeftChild(parent);
} else if(type == "right") {
tree.detachRightChild(parent.id);
tree.detachRightChild(parent);
}

@@ -263,7 +263,7 @@

if(nodeBranchBit == 0 && sistringBranchBit == 1) {
subtree.appendLeftChild(subtreeRoot.id, node);
subtree.appendRightChild(subtreeRoot.id, externalNode);
subtree.appendLeftChild(subtreeRoot, node);
subtree.appendRightChild(subtreeRoot, externalNode);
} else if(nodeBranchBit == 1 && sistringBranchBit == 0){
subtree.appendLeftChild(subtreeRoot.id, externalNode);
subtree.appendRightChild(subtreeRoot.id, node);
subtree.appendLeftChild(subtreeRoot, externalNode);
subtree.appendRightChild(subtreeRoot, node);
} else {

@@ -278,5 +278,5 @@ throw "wrong branch bit";

} else if(type == "left") {
tree.appendLeftChild(parent.id, subtree);
tree.appendLeftChild(parent, subtree);
} else if(type == "right") {
tree.appendRightChild(parent.id, subtree);
tree.appendRightChild(parent, subtree);
}

@@ -466,3 +466,3 @@

console.log("id: " + node.id);
var type = tree.getNodeType(node.id);
var type = tree.getNodeType(node);
console.log(type);

@@ -505,3 +505,3 @@ if(type != "root") {

tree.preOrderTraverse(function(node) {
if(!tree.isRoot(node.id)) {
if(!tree.isRoot(node)) {
var nodeId = node.id;

@@ -508,0 +508,0 @@ var parent = node.parent;

@@ -20,9 +20,9 @@ var uuid = require("../node_modules/node-uuid").v4;

isRoot: function(id) {
return this.root.id == id;
isRoot: function(node) {
return this.root.id == node.id;
},
isLeftChild: function(childId) {
isLeftChild: function(node) {
//console.log(this.root.id);
var node = this.getNode(childId);
//var node = this.getNode(childId);
if(!node.parent) {

@@ -33,3 +33,3 @@ console.trace();

var parent = node.parent;
if(parent.left != null && parent.left.id == childId) {
if(parent.left != null && parent.left.id == node.id) {
return true;

@@ -42,4 +42,4 @@ } else {

isRightChild: function(childId) {
var node = this.getNode(childId)
isRightChild: function(node) {
//var node = this.getNode(childId)
if(!node.parent) {

@@ -50,3 +50,3 @@ console.trace();

var parent = node.parent;
if(parent.right != null && parent.right.id == childId) {
if(parent.right != null && parent.right.id == node.id) {
return true;

@@ -59,10 +59,10 @@ } else {

getNodeType: function(id) {
var node = this.getNode(id);
getNodeType: function(node) {
//var node = this.getNode(id);
var type;
if(this.isRoot(id)) {
if(this.isRoot(node)) {
type = "root";
} else if(this.isLeftChild(id)) {
} else if(this.isLeftChild(node)) {
type = "left";
} else if(this.isRightChild(id)) {
} else if(this.isRightChild(node)) {
type = "right";

@@ -90,4 +90,4 @@ } else {

getParent: function(id) {
var node = this.getNode(id);
getParent: function(node) {
//var node = this.getNode(id);
if(!node.parent) {

@@ -102,4 +102,4 @@ console.trace();

//checked
getLeftChild: function(id) {
var node = this.getNode(id);
getLeftChild: function(node) {
//var node = this.getNode(id);
if(!node.left) {

@@ -114,4 +114,4 @@ console.trace();

//checked
getRightChild: function(id) {
var node = this.getNode(id);
getRightChild: function(node) {
//var node = this.getNode(id);
if(!node.right) {

@@ -147,4 +147,4 @@ console.trace();

//checked
setNodeData: function(id, data) {
var node = this.getNode(id);
setNodeData: function(node, data) {
//var node = this.getNode(id);
node.data = data;

@@ -154,4 +154,4 @@ },

//checked
appendLeftChild: function(id, subtree) {
var node = this.getNode(id);
appendLeftChild: function(node, subtree) {
//var node = this.getNode(id);
if(node.left) {

@@ -172,10 +172,2 @@ console.trace();

target.parent = node;
/*
if(subtree instanceof BTree) {
console.log(subtree.root.parent.id);
console.log(target.parent.id);
console.log(this.getNode(target.id).id);
}
*/
return true;

@@ -186,4 +178,4 @@ }

//checked
appendRightChild: function(id, subtree) {
var node = this.getNode(id);
appendRightChild: function(node, subtree) {
//var node = this.getNode(id);
if(node.right) {

@@ -208,4 +200,4 @@ console.trace();

detachLeftChild: function(id) {
var node = this.getNode(id);
detachLeftChild: function(node) {
//var node = this.getNode(id);
if(!node.left) {

@@ -221,4 +213,4 @@ return;

detachRightChild: function(id) {
var node = this.getNode(id);
detachRightChild: function(node) {
//var node = this.getNode(id);
if(!node.right) {

@@ -234,4 +226,4 @@ return;

removeSubtree: function(id) {
var node = this.getNode(id);
removeSubtree: function(node) {
//var node = this.getNode(id);
if(node) {

@@ -246,5 +238,5 @@ this._remove(node);

//checked
reparentToLeft: function(id, newParentId) {
var node = this.getNode(id);
var newParent = this.getNode(newParentId);
reparentToLeft: function(node, newParent) {
//var node = this.getNode(id);
//var newParent = this.getNode(newParentId);
if(newParent.left) {

@@ -257,5 +249,5 @@ console.trace();

node.parent = newParent;
if(oldParent.left.id == id) {
if(oldParent.left.id == node.id) {
oldParent.left = null;
} else if (oldParent.right.id == id) {
} else if (oldParent.right.id == node.id) {
oldParent.right = null;

@@ -268,5 +260,5 @@ }

//checked
reparentToRight: function(id, newParentId) {
var node = this.getNode(id);
var newParent = this.getNode(newParentId);
reparentToRight: function(node, newParent) {
//var node = this.getNode(id);
//var newParent = this.getNode(newParentId);
if(newParent.right) {

@@ -279,5 +271,5 @@ console.trace();

node.parent = newParent;
if(oldParent.left.id == id) {
if(oldParent.left.id == node.id) {
oldParent.left = null;
} else if(oldParent.right.id == id) {
} else if(oldParent.right.id == node.id) {
oldParent.right = null;

@@ -284,0 +276,0 @@ }

{
"name": "pat-tree",
"version": "0.1.5",
"version": "0.1.6",
"description": "PAT tree construction for Chinese documents",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -117,6 +117,8 @@ pat-tree

* 0.1.6 Improve performance
* 0.1.5 Add functionality of SLP extraction
* 0.1.4 Add external node number and term frequency to internal nodes
* 0.1.3 Able to restore Chinese characters
* 0.1.2 Construction complete
* 0.1.1 First release
* 0.1.2 Construction complete
* 0.1.3 Able to restore Chinese characters
* 0.1.4 Add external node number and term frequency to internal nodes
* 0.1.5 Add functionality of SLP extraction
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc