public function getSummary($text)
{
$sentences = $this->config->trigger('get_sentences', $text);
$candidates = [];
$x = microtime(true);
foreach ($sentences as $id => $t) {
try {
$words = $this->config->trigger('get_words', $t);
$words = $this->config->trigger('filter_keywords', $words);
$words = $this->config->trigger('normalize_keywords', $words);
$words = array_filter($words, function ($word) {
return !ctype_punct($word);
});
$candidates[$id] = $words;
} catch (\Exception $e) {
}
}
$pr = new SummaryPageRank();
$sorted = $pr->sort($candidates);
$keys = array_slice($sorted, 0, ceil(count($sorted) * 0.05), true);
$txt = "";
foreach (array_keys($keys) as $key) {
$txt .= $sentences[$key] . "\n";
}
return $txt;
}