346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
// BINARY CONVERSION
_calculateBinary (nCompressionMethod=1) {
console.log("Write DAWG as an indexable binary dictionary");
this.nBytesArc = Math.floor( (this.nArcVal.toString(2).length + 2) / 8 ) + 1; // We add 2 bits. See DawgNode.convToBytes()
this.nBytesOffset = 0;
this._calcNumBytesNodeAddress();
this._calcNodesAddress();
let this.sByDic = this.oRoot.convToBytes(this.nBytesArc, this.nBytesNodeAddress);
for (let oNode of this.dMinimizedNodes.values()) {
this.sByDic += oNode.convToBytes(this.nBytesArc, this.nBytesNodeAddress);
}
console.log("Arc values (chars, affixes and tags): " + this.nArcVal);
console.log("Arc size: "+this.nBytesArc+" bytes, Address size: "+this.nBytesNodeAddress+" bytes");
console.log("-> " + this.nBytesArc+this.nBytesNodeAddress + " * " + this.nArc + " = " + (this.nBytesArc+this.nBytesNodeAddress)*this.nArc + " bytes");
}
|
|
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
// BINARY CONVERSION
_calculateBinary (nCompressionMethod=1) {
console.log("Write DAWG as an indexable binary dictionary");
this.nBytesArc = Math.floor( (this.nArcVal.toString(2).length + 2) / 8 ) + 1; // We add 2 bits. See DawgNode.convToBytes()
this.nBytesOffset = 0;
this._calcNumBytesNodeAddress();
this._calcNodesAddress();
this.sByDic = this.oRoot.convToBytes(this.nBytesArc, this.nBytesNodeAddress);
for (let oNode of this.dMinimizedNodes.values()) {
this.sByDic += oNode.convToBytes(this.nBytesArc, this.nBytesNodeAddress);
}
console.log("Arc values (chars, affixes and tags): " + this.nArcVal);
console.log("Arc size: "+this.nBytesArc+" bytes, Address size: "+this.nBytesNodeAddress+" bytes");
console.log("-> " + this.nBytesArc+this.nBytesNodeAddress + " * " + this.nArc + " = " + (this.nBytesArc+this.nBytesNodeAddress)*this.nArc + " bytes");
}
|