Calculates the keyword density of a text as described in Wikipedia. Counts the frequency usage of each word in a text.
Keyword density is the percentage of times a keyword or phrase appears on a text compared to the total number of words on the text. The word frequency counter PHP package can be used to count the frequency usage of each word in a text.
Requires PHP 8.0+
You can install the package via composer:
composer require amara/keyword-density
$kw = new Kaiju\KeywordDensity\KeywordDensity();
$kw->setText($text);
print_r($kw->getPopularWords());
composer test
Please see CHANGELOG for more information on what has changed recently.
Thank you for considering to contribute to this project. All the contribution guidelines are mentioned here.
Please review our security policy on how to report security vulnerabilities.
This project is an open-sourced software licensed under the MIT license.