public function getKeywords($text, $limit = 20) { return array_slice($this->getAllKeywordsSorted($text), 0, $limit); }
/** * Extract keywords from text * * @param string|null $text * @param bool|true $withoutStopWords * * @return array */ public function keywords($text = null, $withoutStopWords = true) { $config = new Config(); if ($withoutStopWords) { $config->addListener(new Stopword()); } $textRank = new TextRank($config); try { $keywords = $textRank->getKeywords($this->cleanup($text)); } catch (\RuntimeException $e) { $keywords = null; } return is_array($keywords) ? array_keys($keywords) : $keywords; }