optimized trie and added optional configuration :3
This commit is contained in:
parent
5f485ac73a
commit
6efed770d0
@ -1,6 +1,9 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const rl = require('readline')
|
const rl = require('readline')
|
||||||
|
|
||||||
|
const trie = true;
|
||||||
|
const trieLevel = 4; //size between cuts for trie ex 4 : "/exam/ple"
|
||||||
|
|
||||||
const dictPath = "./dictionary/";
|
const dictPath = "./dictionary/";
|
||||||
const language = "en"
|
const language = "en"
|
||||||
|
|
||||||
@ -31,11 +34,18 @@ reader.on('line', (line) => {
|
|||||||
|
|
||||||
function getPath(word){
|
function getPath(word){
|
||||||
let path = "";
|
let path = "";
|
||||||
for (let i = 0; i < word.length; i+=2){
|
if (trie){
|
||||||
path += word[i] + (word[i+1] ?? "");
|
for (let i = 0; i < word.length; i+=trieLevel){
|
||||||
path += "/";
|
for (let n = 0; n < trieLevel; n++){
|
||||||
|
path += word[i+n] ?? "";
|
||||||
|
}
|
||||||
|
path += "/";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
path = word + '/';
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
|
return path.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeThesaurus(thispath, entry) {
|
function writeThesaurus(thispath, entry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user