An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

TextRank [![Build Status](https://travis-ci.org/crodas/TextRank.png?branch=master)](https://travis-ci.org/crodas/TextRank) Flattr this
========

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.