simple package to calculate keyword density score from given text using stopwords.
npm install density-score
using density-score
is very simple, just pass the text to the function and it will return an array of objects, each object contains the keyword, frequency and density score.
import using require
:
const densityScore = require('density-score');
import using import
:
import densityScore from 'density-score';
const densityScore = require('density-score');
const text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.';
const score = densityScore(text);
console.log(score);
// [{ keyword: 'dolor', frequency: 2, density: 0.1 }]
Type: string
The text to calculate the density score for.
Type: boolean
Default: true
If set to true
, the function will ignore stop words from the text.
Feel free to contribute to this project. You can open an issue or submit a pull request.