function rustemmer_search_preprocess in Russian stemming 6
Same name and namespace in other branches
- 7 rustemmer.module \rustemmer_search_preprocess()
Implements hook_search_preprocess().
File
- ./
rustemmer.module, line 30 - Russian stemming algorith provided by Dr Martin Porter
Code
function rustemmer_search_preprocess($text) {
$words = $text;
$words = str_replace('ё', 'е', $words);
$words = str_replace('Ё', 'Е', $words);
// Split words from noise and remove apostrophes.
$words = preg_split('/([^' . RUSTEMMER_CHARS . ']+)/u', str_replace("'", '', $words), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$stemmer = new RussianStemmer();
// Process each word.
$odd = TRUE;
foreach ($words as $k => $word) {
if ($odd) {
$words[$k] = $stemmer
->stem_word($word);
}
$odd = !$odd;
}
// Put it all back together.
return implode('', $words);
}