You are here

function porterstemmer_search_preprocess in Porter-Stemmer 6

Same name and namespace in other branches
  1. 8 porterstemmer.module \porterstemmer_search_preprocess()
  2. 5 porterstemmer.module \porterstemmer_search_preprocess()
  3. 6.2 porterstemmer.module \porterstemmer_search_preprocess()
  4. 7 porterstemmer.module \porterstemmer_search_preprocess()

Implementation of hook_search_preprocess

File

./porterstemmer.module, line 13

Code

function porterstemmer_search_preprocess(&$text) {

  // Split words from noise and remove apostrophes
  $words = preg_split('/([^a-zA-Z]+)/', str_replace("'", '', $text), -1, PREG_SPLIT_DELIM_CAPTURE);

  // Process each word
  $odd = true;
  foreach ($words as $k => $word) {
    if ($odd) {
      $words[$k] = Stem($word);
    }
    $odd = !$odd;
  }

  // Put it all back together
  return implode('', $words);
}