JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q58741F
  • 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. Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters."
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', '.' ],
  [ '.', 'Now' ],
  [ 'Now', 'the' ],
  [ 'the', 'earth' ],
  [ 'earth', 'was' ],
  [ 'was', 'formless' ],
  [ 'formless', 'and' ],
  [ 'and', 'empty' ],
  [ 'empty', ',' ],
  [ ',', 'darkness' ],
  [ 'darkness', 'was' ],
  [ 'was', 'over' ],
  [ 'over', 'the' ],
  [ 'the', 'surface' ],
  [ 'surface', 'of' ],
  [ 'of', 'the' ],
  [ 'the', 'deep' ],
  [ 'deep', ',' ],
  [ ',', 'and' ],
  [ 'and', 'the' ],
  [ 'the', 'Spirit' ],
  [ 'Spirit', 'of' ],
  [ 'of', 'God' ],
  [ 'God', 'was' ],
  [ 'was', 'hovering' ],
  [ 'hovering', 'over' ],
  [ 'over', 'the' ],
  [ 'the', 'waters' ],
  [ 'waters', '.' ]
]

Licence

P. Hughes (C) 2017.

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.