You are here

protected function SearchApiAbstractProcessor::normalizeTokens in Search API 7

Internal helper function for normalizing tokens.

1 call to SearchApiAbstractProcessor::normalizeTokens()
SearchApiAbstractProcessor::processField in includes/processor.inc
Method for preprocessing field data.

File

includes/processor.inc, line 294
Contains SearchApiProcessorInterface and SearchApiAbstractProcessor.

Class

SearchApiAbstractProcessor
Abstract processor implementation that provides an easy framework for only processing specific fields.

Code

protected function normalizeTokens($tokens, $score = 1) {
  $ret = array();
  foreach ($tokens as $token) {
    if (empty($token['value']) && !is_numeric($token['value'])) {

      // Filter out empty tokens.
      continue;
    }
    if (!isset($token['score'])) {
      $token['score'] = $score;
    }
    else {
      $token['score'] *= $score;
    }
    if (is_array($token['value'])) {
      foreach ($this
        ->normalizeTokens($token['value'], $token['score']) as $t) {
        $ret[] = $t;
      }
    }
    else {
      $ret[] = $token;
    }
  }
  return $ret;
}