https://github.com/crodas/textrank
extract relevant keywords from a given text
https://github.com/crodas/textrank
extract-relevant-keywords php textrank
Last synced: 12 months ago
JSON representation
extract relevant keywords from a given text
- Host: GitHub
- URL: https://github.com/crodas/textrank
- Owner: crodas
- License: bsd-3-clause
- Created: 2013-11-05T08:27:52.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-01-31T00:59:56.000Z (about 9 years ago)
- Last Synced: 2025-03-30T21:27:26.537Z (about 1 year ago)
- Topics: extract-relevant-keywords, php, textrank
- Language: PHP
- Size: 914 KB
- Stars: 104
- Watchers: 5
- Forks: 25
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TextRank [](https://travis-ci.org/crodas/TextRank)
========
extract relevant keywords from a given text
How to use it
-------------
In order to use the class, you must instance a `Config` object.
```php
getKeywords($some_long_text);
var_dump($keywords);
```
It is possible to get better results by adding few information about the language (`stopword` list, `stemmer` with `pecl install stem`).
```php
addListener(new Stopword);
$textrank = new TextRank($config);
$keywords = $textrank->getKeywords($some_long_text);
var_dump($keywords);
```
By doing this it will detect the language of the text and will remove common words (from the stopword list). If `ext-stem` is available the results will be even better.
Summarize large texts
---------------------
This class is also capable of summarizing long texts
```php
$config = new \crodas\TextRank\Config;
$config->addListener(new \crodas\TextRank\Stopword);
$analizer = new \crodas\TextRank\Summary($config);
$summary = $analizer->getSummary($text);
```
`$summary` is at most 5% of the sentences of the text.