private function getPopularWords()
{
$limit = 5;
$minimumFrequency = 1;
$stopWords = $this->config()->getStopWords()->getCurrentStopWords();
$text = $this->article()->getTitle();
$text .= ' ' . $this->article()->getMetaDescription();
if ($this->article()->getTopNode()) {
$text .= ' ' . $this->article()->getCleanedArticleText();
}
// Decode and split words by white-space
$text = html_entity_decode($text, ENT_COMPAT | ENT_HTML5, 'UTF-8');
$words = preg_split('@[\\s]+@iu', $text, -1, PREG_SPLIT_NO_EMPTY);
// Determine stop words currently in $words
$ignoreWords = array_intersect($words, $stopWords);
// Remove ignored words from $words
$words = array_diff($words, $ignoreWords);
// Count and sort $words
$words = array_count_values($words);
arsort($words);
// Limit and filter $words
$words = array_slice($words, 0, $limit);
$words = array_filter($words, function ($value) use($minimumFrequency) {
return !($value < $minimumFrequency);
});
return $words;
}