PHPackages                             keyword-extractor/keyword-extractor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. keyword-extractor/keyword-extractor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

keyword-extractor/keyword-extractor
===================================

A package to extract keywords from text

v1.1.0(1y ago)118.7k↓50%5[1 issues](https://github.com/iranianpep/keyword-extractor/issues)MITPHPPHP ^7.4|^8.0

Since Oct 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/iranianpep/keyword-extractor)[ Packagist](https://packagist.org/packages/keyword-extractor/keyword-extractor)[ Docs](https://github.com/iranianpep/keyword-extractor)[ RSS](/packages/keyword-extractor-keyword-extractor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Keyword Extractor
=================

[](#keyword-extractor)

A package to extract keywords from text

[![Latest Stable Version](https://camo.githubusercontent.com/e42fab13172a1a7f143bdc00223f3a89fb6d7a7b643bc35ab3b673e493047044/68747470733a2f2f706f7365722e707567782e6f72672f6b6579776f72642d657874726163746f722f6b6579776f72642d657874726163746f722f762f737461626c65)](https://packagist.org/packages/keyword-extractor/keyword-extractor)[![Build Status](https://camo.githubusercontent.com/9a07761db0216a7939270969214c1c976f7764c1c11d861af0004e10063c5749/68747470733a2f2f7472617669732d63692e6f72672f6972616e69616e7065702f6b6579776f72642d657874726163746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iranianpep/keyword-extractor)[![Build Status](https://camo.githubusercontent.com/287717ee90c437b7b39271cbc0c33f6050cba47a0d3ff1958ba414836bec04ff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/keyword-extractor/build-status/master)[![Code Climate](https://camo.githubusercontent.com/47265850378bcd2a487828162f2f6bd03ee09dd4accd7fafcfcf57d143ec2df1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f6770612e737667)](https://codeclimate.com/github/iranianpep/keyword-extractor)[![Test Coverage](https://camo.githubusercontent.com/7215ade67aa0183fb462dc4393c685158b3800d0510e2c9246c0c4aa23c3dda9/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/iranianpep/keyword-extractor/coverage)[![Code Coverage](https://camo.githubusercontent.com/63d11e9089d6441179fa2379a446d014c8be6b7783f056639cebdcc92beaae83/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/keyword-extractor/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fc7e0ca88263e9460c0fe7f4328a7a0d985330664d3940a9d889d601c9c275e7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iranianpep/keyword-extractor/?branch=master)[![Issue Count](https://camo.githubusercontent.com/06c6376a1a6d791f8a7864310737613a584196bb4a0c937d8cd7f306fe933824/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f6b6579776f72642d657874726163746f722f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/iranianpep/keyword-extractor)[![License](https://camo.githubusercontent.com/6a64c4596202cf6f56b2dfd65a6fabf1f4a1481a8174627c219c2b6db1555b49/68747470733a2f2f706f7365722e707567782e6f72672f6b6579776f72642d657874726163746f722f6b6579776f72642d657874726163746f722f6c6963656e7365)](https://packagist.org/packages/keyword-extractor/keyword-extractor)[![StyleCI](https://camo.githubusercontent.com/95644821bc6b14f0cd96f671741ce3f76b11bdd7892b3dc336c088ab2e6e88aa/68747470733a2f2f7374796c6563692e696f2f7265706f732f3135323336393430382f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/152369408)[![Codacy Badge](https://camo.githubusercontent.com/059869e782bdc8575340d02294af28fa06c48986f1d820395a17d99addad167b/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6636373938636533633030653464653038336438396632383962366339323835)](https://www.codacy.com/app/iranianpep/keyword-extractor?utm_source=github.com&utm_medium=referral&utm_content=iranianpep/keyword-extractor&utm_campaign=Badge_Grade)[![Packagist](https://camo.githubusercontent.com/075e4db88d3066bfcb0e0c924bb1df6ee2644bced6cf2fd9414c413239eb5a11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6579776f72642d657874726163746f722f6b6579776f72642d657874726163746f722e737667)](https://packagist.org/packages/keyword-extractor/keyword-extractor)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/iranianpep/keyword-extractor/master/LICENSE)

Server Requirements
-------------------

[](#server-requirements)

- PHP &gt;= 7.3

Usage
-----

[](#usage)

- To install ths package:

```
composer require keyword-extractor/keyword-extractor

```

- Extract the keywords:

```
$keywordExtractor = new KeywordExtractor();
$text = 'This is a simple sentence.';
$result = $keywordExtractor->run($text);

```

The result with the default modifiers and no sorting values will be:

```
Array
(
    [simpl] => Array
        (
            [frequency] => 1
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => simple
                            [indexes] => Array
                                (
                                    [0] => 3
                                )

                        )

                )

        )

    [sentenc] => Array
        (
            [frequency] => 1
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => sentence.
                            [indexes] => Array
                                (
                                    [0] => 4
                                )

                        )

                )

        )

)

```

Currently, the default modifiers are as follow (they will be applied to the tokens in order):

```
[
    new EmailFilter(),
    new PunctuationFilter(),
    new WhitelistFilter($this->getWhitelist()),
    new BlacklistFilter($this->getBlacklist()),
    new StopWordFilter(),
    new NumberFilter(),
    new StemFilter(),
    // run the blacklist even after stemming too
    new BlacklistFilter($this->getBlacklist()),
]

```

Obviously, you can set your own modifiers:

```
$keywordExtractor->setModifiers([new PunctuationFilter()]);

```

Also, whitelist can be used as follow:

```
$keywordExtractor = new KeywordExtractor();
$text = 'This is a simple sentence and simple sentence.';
$keywordExtractor->setWhitelist(['simple']);
$result = $keywordExtractor->run($text);

```

Which results in:

```
Array
(
    [simple] => Array
        (
            [frequency] => 2
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => simple
                            [indexes] => Array
                                (
                                    [0] => 3
                                )

                        )

                    [1] => Array
                        (
                            [ngram] => simple
                            [indexes] => Array
                                (
                                    [0] => 6
                                )

                        )

                )

        )

    [sentenc] => Array
        (
            [frequency] => 2
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => sentence
                            [indexes] => Array
                                (
                                    [0] => 4
                                )

                        )

                    [1] => Array
                        (
                            [ngram] => sentence.
                            [indexes] => Array
                                (
                                    [0] => 7
                                )

                        )

                )

        )

)

```

Blacklist can also be used in the same way as whitelist:

```
$keywordExtractor = new KeywordExtractor();
$text = 'This is a simple sentence.';
$keywordExtractor->setBlacklist(['simple']);
$result = $keywordExtractor->run($text);

```

The result is:

```
Array
(
    [sentenc] => Array
        (
            [frequency] => 1
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => sentence.
                            [indexes] => Array
                                (
                                    [0] => 4
                                )

                        )

                )

        )

)

```

To sort by frequency in descending order:

```
$keywordExtractor->run($text, Sorter::SORT_BY_FREQUENCY, Sorter::SORT_DIR_DESC);

```

To sort by min occurrences distance:

```
$text = 'sentence and sentence';
$result = $this->keywordExtractor->run($text, Sorter::SORT_BY_MIN_OCCURRENCE_DISTANCE);

Array
(
    [sentenc] => Array
        (
            [frequency] => 2
            [occurrences] => Array
                (
                    [0] => Array
                        (
                            [ngram] => sentence
                            [indexes] => Array
                                (
                                    [0] => 0
                                )

                        )

                    [1] => Array
                        (
                            [ngram] => sentence
                            [indexes] => Array
                                (
                                    [0] => 2
                                )

                        )

                )

            [minOccurrencesDistance] => 1
        )

)

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 76.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~205 days

Recently: every ~547 days

Total

12

Last Release

507d ago

Major Versions

v0.96 → 1.02018-11-05

PHP version history (2 changes)0.9PHP &gt;=7.1

v1.1.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4e337f9891a92e469bd236f9774b8c6a894b05a31fc4f3d2da1f4010977b44e?d=identicon)[ehsan.abb](/maintainers/ehsan.abb)

---

Top Contributors

[![iranianpep](https://avatars.githubusercontent.com/u/3667439?v=4)](https://github.com/iranianpep "iranianpep (99 commits)")[![kudashevs](https://avatars.githubusercontent.com/u/15892462?v=4)](https://github.com/kudashevs "kudashevs (26 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

keywordkeyword-extractor

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/keyword-extractor-keyword-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/keyword-extractor-keyword-extractor/health.svg)](https://phpackages.com/packages/keyword-extractor-keyword-extractor)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
