JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q58669F
  • License CC-BY-NC-SA-3.0

The easiest wat to get n-grams from strings

Package Exports

  • simplengrams

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simplengrams) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SimleNGrams

The easiest way of getting an array of n-grams from a string!

Useage

const sng = require('simplengrams');
const txt = 'A string of text...';
const bigrams = sng(text, 2);
const trigrams = sng(text, 3);
console.log(bigrams, trigrams);

Example

Input

const sng = require('simplengrams');
const text = 'In the beginning God created the heavens and the earth.';
const bigrams = sng(text, 2);
console.log(bigrams);

Bigram Output

[
  [ 'In', 'the' ],
  [ 'the', 'beginning' ],
  [ 'beginning', 'God' ],
  [ 'God', 'created' ],
  [ 'created', 'the' ],
  [ 'the', 'heavens' ],
  [ 'heavens', 'and' ],
  [ 'and', 'the' ],
  [ 'the', 'earth' ],
  [ 'earth', '.' ]
]

Licence

(C) 2017 P. Hughes.

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.