          selitm(currdbidxs[i]);
        }
    }
    countsel();
}


function ngramParser(text, n) {
    const words = text.split(/\s+/).filter(word => word.length > 0);
    const ngrams = {};
    for (let i = 0; i <= words.length - n; i++) {
        const ngram = words.slice(i, i + n).join(' ');
        if (ngrams[ngram]) {
            ngrams[ngram]++;
        } else {
            ngrams[ngram] = 1;
        }
    }
    const sortedNgrams = Object.entries(ngrams).sort((a, b) => b[1] - a[1]