PHP code example of php-science / textrank
1. Go to this page and download the library: Download php-science/textrank library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-science / textrank example snippets
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);