density-score
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

density-score

simple package to calculate keyword density score from given text using stopwords.

Installation

npm install density-score

Usage

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';

Example

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 }]

API

densityScore(text, ignoreStopWords)

text

Type: string

The text to calculate the density score for.

ignoreStopWords

Type: boolean

Default: true

If set to true, the function will ignore stop words from the text.

Contribution

Feel free to contribute to this project. You can open an issue or submit a pull request.

Author

Mahmoud Ibrahiam

/density-score/

    Package Sidebar

    Install

    npm i density-score

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.03 kB

    Total Files

    7

    Last publish

    Collaborators

    • remahmoud