Craft\SeomaticService::extractKeywords PHP Method

extractKeywords() public method

* -------------------------------------------------------------------------------- Extract the most important words from the passed in text via TextRank --------------------------------------------------------------------------------
public extractKeywords ( $text = null, $limit = 15, $withoutStopWords = true )
    public function extractKeywords($text = null, $limit = 15, $withoutStopWords = true)
    {
        if (!$text) {
            return;
        }
        $text = strtolower($text);
        $config = new Config();
        if ($withoutStopWords) {
            $config->addListener(new Stopword());
        }
        $textRank = new TextRank($config);
        try {
            $keywords = $textRank->getKeywords($this->_cleanupText($text));
        } catch (\RuntimeException $e) {
            $keywords = null;
        }
        if ($keywords == "") {
            $keywords = str_replace(' ', ',', $text);
        }
        return is_array($keywords) ? implode(", ", array_slice(array_keys($keywords), 0, $limit)) : $keywords;
    }