- $aWordFrequencyScores = array();
- foreach ($aDatabaseWords as $aToken) {
- // Filter country tokens that do not match restricted countries.
- if ($this->aCountryCodes
- && $aToken['country_code']
- && !in_array($aToken['country_code'], $this->aCountryCodes)
- ) {
- continue;
- }
-
- // Special terms need to appear in their normalized form.
- if ($aToken['word'] && $aToken['class']) {
- $sNormWord = $this->normTerm($aToken['word']);
- if (strpos($sNormQuery, $sNormWord) === false) {
- continue;
- }
- }
-
- if (isset($aValidTokens[$aToken['word_token']])) {
- $aValidTokens[$aToken['word_token']][] = $aToken;
- } else {
- $aValidTokens[$aToken['word_token']] = array($aToken);
- }
- $aWordFrequencyScores[$aToken['word_id']] = $aToken['search_name_count'] + 1;
- }