skipgram
v1.0.2
Published
For all your n-gram and skip-gram needs 🔠
Downloads
6
Readme
skipgram
For all your n-gram and skip-gram needs 🔠
npm install -g skipgram
const skipgram = require('skipgram');
const text = '0 1 2 3 4 5 6 7 8 9';
skipgram(1)(text);
// [
// [ '0' ],
// [ '1' ],
// [ '2' ],
// [ '3' ],
// [ '4' ],
// [ '5' ],
// [ '6' ],
// [ '7' ],
// [ '8' ],
// [ '9' ]
// ]
skipgram(2)(text);
// [
// [ '0', '1' ],
// [ '1', '2' ],
// [ '2', '3' ],
// [ '3', '4' ],
// [ '4', '5' ],
// [ '5', '6' ],
// [ '6', '7' ],
// [ '7', '8' ],
// [ '8', '9' ]
// ]
skipgram(4)(text);
// [
// [ '0', '1', '2', '3' ],
// [ '1', '2', '3', '4' ],
// [ '2', '3', '4', '5' ],
// [ '3', '4', '5', '6' ],
// [ '4', '5', '6', '7' ],
// [ '5', '6', '7', '8' ],
// [ '6', '7', '8', '9' ]
// ]
skipgram(3, 1)(text);
// [
// [ '0', '2', '4' ],
// [ '1', '3', '5' ],
// [ '2', '4', '6' ],
// [ '3', '5', '7' ],
// [ '4', '6', '8' ],
// [ '5', '7', '9' ]
// ]