compromise-ngrams
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published
a plugin for compromise

npm install compromise-ngrams
const nlp = require('compromise')
nlp.extend(require('compromise-ngrams'))

let doc = nlp(`bake 'em away, toys`)
doc.bigrams().data()
//[{normal:'bake em', size:2, count:1}, {normal:'em away', size:2, count:1}, {normal:'em toys', size:2, count:1}]

//same for:
doc.unigrams()
doc.trigrams()
doc.ngrams({ size: 3 })

Demo

API:

  • .ngrams({}) - list all repeating sub-phrases, by word-count
  • .unigrams(n) - n-grams with one word
  • .bigrams(n) - n-grams with two words
  • .trigrams(n) - n-grams with three words
  • .startgrams({}) - n-grams including the first term of a phrase
  • .endgrams({}) - n-grams including the last term of a phrase
  • .edgegrams({}) - n-grams including the first or last term of a phrase

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i compromise-ngrams

Weekly Downloads

6

Version

0.0.6

License

MIT

Unpacked Size

36.7 kB

Total Files

7

Last publish

Collaborators

  • spencermountain