0.0.6 • Published 3 years ago

compromise-ngrams v0.0.6

Weekly downloads
34
License
MIT
Repository
github
Last release
3 years ago
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