PHPackages                             nanhh/textrank - 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. nanhh/textrank

ActiveLibrary

nanhh/textrank
==============

TextRank (automatic text summarization) for PHP7 and HHVM.

014PHP

Since Dec 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nhatanh1/TextRank)[ Packagist](https://packagist.org/packages/nanhh/textrank)[ RSS](/packages/nanhh-textrank/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

TextRank
=========

[](#textrank)

 [ ![](https://github.com/php-science/textrank/workflows/tests/badge.svg) ](https://github.com/PHP-Science/TextRank/actions) [ ![](https://camo.githubusercontent.com/8ee2e01f268a94c06657db4c441719e745953e2425ca6f1bacd5752cbc6e2072/68747470733a2f2f706f7365722e707567782e6f72672f7068702d736369656e63652f7465787472616e6b2f762f737461626c652e737667) ](https://packagist.org/packages/php-science/textrank) [ ![](https://camo.githubusercontent.com/9e4023283a58781ab3b32a94676fea59e69c19cf690c9b4ee69ca8ef97ae8967/68747470733a2f2f706f7365722e707567782e6f72672f7068702d736369656e63652f7465787472616e6b2f646f776e6c6f616473) ](https://packagist.org/packages/php-science/textrank) [ ![](https://camo.githubusercontent.com/d0bb7d3f26feaf2cd69cc4a0b565d3310c8d3420272b9ae8f28b308fd731e445/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d4646463330302e737667) ](https://github.com/PHP-Science/TextRank/blob/master/LICENSE)

This source code is an implementation of the TextRank algorithm (Automatic summarization) on PHP7 strict mode. It can summarize a text, article for example to a short paragraph. Before it would start the summarizing it removes the junk words what are defined in the Stopwords namespace. It is possible to extend it with another languages.

TextRank or Automatic summarization
-----------------------------------

[](#textrank-or-automatic-summarization)

> Automatic summarization is the process of reducing a text document with a computer program in order to create a summary that retains the most important points of the original document. Technologies that can make a coherent summary take into account variables such as length, writing style and syntax. Automatic data summarization is part of machine learning and data mining. The main idea of summarization is to find a representative subset of the data, which contains the information of the entire set. Summarization technologies are used in a large number of sectors in industry today. - Wikipedia

The algorithm of this implementation is:

- Find sentences,
- Remove stopwords,
- Create integer values by find and count the matching words,
- Change the integer values by the related words' integer values,
- Normalize values to create scores,
- Order by scores

Install
-------

[](#install)

```
composer require php-science/textrank

```

Test
----

[](#test)

```
cd project-folder
composer test

```

or

```
cd project-folder
phpunit --colors='always' $(pwd)/tests

```

Examples
--------

[](#examples)

```
use PhpScience\TextRank\Tool\StopWords\English;

// String contains a long text, see the /res/sample1.txt file.
$text = "Lorem ipsum...";

$api = new TextRankFacade();
// English implementation for stopwords/junk words:
$stopWords = new English();
$api->setStopWords($stopWords);

// Array of the most important keywords:
$result = $api->getOnlyKeyWords($text);

// Array of the sentences from the most important part of the text:
$result = $api->getHighlights($text);

// Array of the most important sentences from the text:
$result = $api->summarizeTextBasic($text);
```

More examples:

- [tests/TextRankFacadeTest.php](https://github.com/DoveID/PHP-Science-TextRank/blob/master/tests/TextRankFacadeTest.php)
-

Authors, Contributors
---------------------

[](#authors-contributors)

NameGitHub userDavid Belicza@DavidBeliczaRiccardo Marton@riccardomartonSyndesi@Syndesivincentsch@vincentschAndrew Welch@khalwatAndrey Astashov@mvcaaaLeo Toneff@bragleWilly Arisky@willyariskyRobert-Jan Keizer@KeizerDev

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfb2055bde954717d4be351e13379452c1f233864594a26e1ba0259d99729934?d=identicon)[nhatanh1](/maintainers/nhatanh1)

---

Top Contributors

[![nhatanh1](https://avatars.githubusercontent.com/u/74230645?v=4)](https://github.com/nhatanh1 "nhatanh1 (6 commits)")

### Embed Badge

![Health badge](/badges/nanhh-textrank/health.svg)

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

PHPackages © 2026

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