Craft\SeomaticService::extractSummary PHP Method

extractSummary() public method

* -------------------------------------------------------------------------------- Extract a summary from the text, or if it's not long enough, just return the text --------------------------------------------------------------------------------
public extractSummary ( $text = null, $limit = null, $withoutStopWords = true )
    public function extractSummary($text = null, $limit = null, $withoutStopWords = true)
    {
        if (!$text) {
            return;
        }
        $config = new Config();
        if ($withoutStopWords) {
            $config->addListener(new Stopword());
        }
        $analyzer = new Summary($config);
        try {
            $summary = $analyzer->getSummary($this->_cleanupText($text));
            if ($summary && is_integer($limit)) {
                $summary = mb_strimwidth($summary, 0, $limit, "...");
            }
        } catch (\RuntimeException $e) {
            $summary = $text;
        }
        if ($summary == "") {
            $keywords = $text;
        }
        return $summary;
    }