n-gram
![Size](https://img.shields.io/bundlephobia/minzip/n-gram.svg)
Get n-grams.
Install
This package is ESM only: Node 12+ is needed to use it and it must be import
ed
instead of require
d.
npm:
npm install n-gram
Use
import {bigram, trigram, nGram} from 'n-gram'
bigram('n-gram')
nGram(2)('n-gram')
trigram('n-gram')
nGram(6)('n-gram')
nGram(7)('n-gram')
bigram(['alpha', 'bravo', 'charlie'])
API
This package exports the following identifiers: ngram
, bigram
, and trigram
.
There is no default export.
nGram(n)
Create a function that converts a given value to n-grams.
Want padding?
Use something like the following: nGram(2)(' ' + value + ' ')
bigram(value)
Shortcut for nGram(2)
.
trigram(value)
Shortcut for nGram(3)
.
License
MIT © Titus Wormer