329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
}
// BINARY CONVERSION
createBinary (nMethod) {
console.log("Write DAWG as an indexable binary dictionary [method: "+nMethod+"]");
if (nMethod == 1) {
this.nBytesArc = Math.floor( (this.nArcVal.toString(2).length + 2) / 8 ) + 1; // We add 2 bits. See DawgNode.convToBytes1()
this._calcNumBytesNodeAddress()
this._calcNodesAddress1()
} else {
console.log("Error: unknown compression method");
}
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");
return this._createJSON(nMethod);
|
>
|
|
|
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
}
// BINARY CONVERSION
createBinary (nMethod) {
console.log("Write DAWG as an indexable binary dictionary [method: "+nMethod+"]");
if (nMethod == 1) {
this.nBytesArc = Math.floor( (this.nArcVal.toString(2).length + 2) / 8 ) + 1; // We add 2 bits. See DawgNode.convToBytes1()
this.nBytesOffset = 0;
this._calcNumBytesNodeAddress();
this._calcNodesAddress1();
} else {
console.log("Error: unknown compression method");
}
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");
return this._createJSON(nMethod);
|
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
"nEntries": this.nEntry,
"nNode": this.nNode,
"nArc": this.nArc,
"nAff": this.nAff,
"cStemming": this.cStemming,
"nTag": this.nTag,
"dChar": helpers.mapToObject(this.dChar),
"nBytesOffset": 1
};
return oJSON;
},
_getDate () {
let oDate = new Date();
let sMonth = (oDate.getMonth() + 1).toString().padStart(2, "0"); // Month+1: Because JS always sucks somehow.
|
|
|
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
"nEntries": this.nEntry,
"nNode": this.nNode,
"nArc": this.nArc,
"nAff": this.nAff,
"cStemming": this.cStemming,
"nTag": this.nTag,
"dChar": helpers.mapToObject(this.dChar),
"nBytesOffset": this.nBytesOffset
};
return oJSON;
},
_getDate () {
let oDate = new Date();
let sMonth = (oDate.getMonth() + 1).toString().padStart(2, "0"); // Month+1: Because JS always sucks somehow.
|