crodas\TextRank\TextRank::getKeywords PHP Method

getKeywords() public method

public getKeywords ( $text, $limit = 20 )
    public function getKeywords($text, $limit = 20)
    {
        return array_slice($this->getAllKeywordsSorted($text), 0, $limit);
    }

Usage Example

コード例 #1
0
 /**
  * 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;
 }
All Usage Examples Of crodas\TextRank\TextRank::getKeywords