compromise-ngrams
v0.0.6
Published
plugin for nlp-compromise
Downloads
240
Readme
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