*
* Stems the words in $text, using the Porter Stemmer 2 algorithm.
*/
-function porterstemmer_search_preprocess(&$text) {
+function porterstemmer_search_preprocess($text) {
// Convert text to lower case, and replace special apostrophes with regular
- // apostrophes
+ // apostrophes.
$text = drupal_strtolower(str_replace('’', "'", $text));
// Split into words
$has_pecl_stem = _porterstemmer_pecl_loaded();
- // Process each word, skipping delimiters
+ // Process each word, skipping delimiters.
$isword = !preg_match('/' . PORTERSTEMMER_BOUNDARY . '/', $words[0] );
foreach ($words as $k => $word) {
if ($isword) {
$isword = !$isword;
}
- // Put it all back together
+ // Put it all back together (note that delimiters are in $words).
return implode('', $words);
}
/**
* Implementation of hook_sbp_excerpt_match().
+ *
+ * Allows Porter Stemmer to display better search excerpts with the
+ * Search by page module.
*/
function porterstemmer_sbp_excerpt_match( $key, $text, $offset, $boundary ) {
// Stem the keyword down to its root form.