public static function matchKeyword(&$wordarray, &$content, $start, $content_len) { if ($start >= $content_len) { return 0; } if (!array_key_exists($content[$start], $wordarray)) { return 0; } $X =& $wordarray[$content[$start]]; if ($X == 1) { return 1; } else { $n = KeywordFilter::matchKeyword($X, $content, $start + 1, $content_len); if ($n == 0) { return 0; } else { return $n + 1; } } }
private static function getPhraseScores($phrases, $wordScores) { $phrase_scores = array(); foreach ($phrases as $phrase) { if (!array_key_exists($phrase, $phrase_scores)) { $phrase_scores[$phrase] = 0; } $wordList = KeywordFilter::splitPhraseIntoWords($phrase); $total_score = 0; foreach ($wordList as $word) { if (isset($wordScores[$word])) { $total_score += $wordScores[$word]; } } $phrase_scores[$phrase] = $total_score; } arsort($phrase_scores); return $phrase_scores; }