--- porterstemmer.module	2007-06-07 23:39:05.000000000 -0400
+++ porterstemmer.module	2005-12-17 18:08:01.000000000 -0500
@@ -28,283 +28,309 @@
 }
 
 /**
+* Implementation of hook_help().
+*/
+function porterstemmer_help($section = 'admin/help#search') {
+  switch ($section) {
+    case 'admin/modules#description':
+      return t('Implements the Porter-Stemmer algorithm to improve English searching.');
+  }
+}
+
+/**
 * Regex for matching a consonant
 */
 define('regex_consonant', '(?:[bcdfghjklmnpqrstvwxz]|(?<=[aeiou])y|^y)');
 
+
 /**
 * Regex for matching a vowel
 */
 define('regex_vowel', '(?:[aeiou]|(?<![aeiou])y)');
 
+
 /**
-* Stems a word
+* Stems a word. Simple huh?
 *
 * @param  string $word Word to stem
 * @return string       Stemmed word
 */
-function stem($word) {
-  if (strlen($word) <= 2) {
-      return $word;
-  }
+function stem($word)
+{
+    if (strlen($word) <= 2) {
+        return $word;
+    }
 
-  $word = step1ab($word);
-  $word = step1c($word);
-  $word = step2($word);
-  $word = step3($word);
-  $word = step4($word);
-  $word = step5($word);
+    $word = step1ab($word);
+    $word = step1c($word);
+    $word = step2($word);
+    $word = step3($word);
+    $word = step4($word);
+    $word = step5($word);
 
-  return $word;
+    return $word;
 }
 
 
 /**
 * Step 1
 */
-function step1ab($word) {
-  // Part a
-  if (substr($word, -1) == 's') {
-       replace($word, 'sses', 'ss')
-    OR replace($word, 'ies', 'i')
-    OR replace($word, 'ss', 'ss')
-    OR replace($word, 's', '');
-  }
-
-  // Part b
-  if (substr($word, -2, 1) != 'e' OR !replace($word, 'eed', 'ee', 0)) { // First rule
-    $v = regex_vowel;
+function step1ab($word)
+{
+    // Part a
+    if (substr($word, -1) == 's') {
+
+           replace($word, 'sses', 'ss')
+        OR replace($word, 'ies', 'i')
+        OR replace($word, 'ss', 'ss')
+        OR replace($word, 's', '');
+    }
 
-    // ing and ed
-    if (   preg_match("#$v+#", substr($word, 0, -3)) && replace($word, 'ing', '')
-        OR preg_match("#$v+#", substr($word, 0, -2)) && replace($word, 'ed', '')) { // Note use of && and OR, for precedence reasons
-
-        // If one of above two test successful
-        if (    !replace($word, 'at', 'ate')
-            AND !replace($word, 'bl', 'ble')
-            AND !replace($word, 'iz', 'ize')) {
-
-            // Double consonant ending
-            if (    doubleConsonant($word)
-                AND substr($word, -2) != 'll'
-                AND substr($word, -2) != 'ss'
-                AND substr($word, -2) != 'zz') {
-
-                $word = substr($word, 0, -1);
-
-              } else if (m($word) == 1 AND cvc($word)) {
-                  $word .= 'e';
-              }
-          }
-      }
-  }
+    // Part b
+    if (substr($word, -2, 1) != 'e' OR !replace($word, 'eed', 'ee', 0)) { // First rule
+        $v = regex_vowel;
+
+        // ing and ed
+        if (   preg_match("#$v+#", substr($word, 0, -3)) && replace($word, 'ing', '')
+            OR preg_match("#$v+#", substr($word, 0, -2)) && replace($word, 'ed', '')) { // Note use of && and OR, for precedence reasons
+
+            // If one of above two test successful
+            if (    !replace($word, 'at', 'ate')
+                AND !replace($word, 'bl', 'ble')
+                AND !replace($word, 'iz', 'ize')) {
+
+                // Double consonant ending
+                if (    doubleConsonant($word)
+                    AND substr($word, -2) != 'll'
+                    AND substr($word, -2) != 'ss'
+                    AND substr($word, -2) != 'zz') {
+
+                    $word = substr($word, 0, -1);
+
+                } else if (m($word) == 1 AND cvc($word)) {
+                    $word .= 'e';
+                }
+            }
+        }
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Step 1c
 *
 * @param string $word Word to stem
 */
-function step1c($word) {
-  $v = regex_vowel;
+function step1c($word)
+{
+    $v = regex_vowel;
 
-  if (substr($word, -1) == 'y' && preg_match("#$v+#", substr($word, 0, -1))) {
-    replace($word, 'y', 'i');
-  }
+    if (substr($word, -1) == 'y' && preg_match("#$v+#", substr($word, 0, -1))) {
+        replace($word, 'y', 'i');
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Step 2
 *
 * @param string $word Word to stem
 */
-function step2($word) {
-  switch (substr($word, -2, 1)) {
-      case 'a':
-             replace($word, 'ational', 'ate', 0)
-          OR replace($word, 'tional', 'tion', 0);
-          break;
-
-      case 'c':
-             replace($word, 'enci', 'ence', 0)
-          OR replace($word, 'anci', 'ance', 0);
-          break;
-
-      case 'e':
-          replace($word, 'izer', 'ize', 0);
-          break;
-
-      case 'g':
-          replace($word, 'logi', 'log', 0);
-          break;
-
-      case 'l':
-             replace($word, 'entli', 'ent', 0)
-          OR replace($word, 'ousli', 'ous', 0)
-          OR replace($word, 'alli', 'al', 0)
-          OR replace($word, 'bli', 'ble', 0)
-          OR replace($word, 'eli', 'e', 0);
-          break;
-
-      case 'o':
-             replace($word, 'ization', 'ize', 0)
-          OR replace($word, 'ation', 'ate', 0)
-          OR replace($word, 'ator', 'ate', 0);
-          break;
-
-      case 's':
-             replace($word, 'iveness', 'ive', 0)
-          OR replace($word, 'fulness', 'ful', 0)
-          OR replace($word, 'ousness', 'ous', 0)
-          OR replace($word, 'alism', 'al', 0);
-          break;
-
-      case 't':
-             replace($word, 'biliti', 'ble', 0)
-          OR replace($word, 'aliti', 'al', 0)
-          OR replace($word, 'iviti', 'ive', 0);
-          break;
-  }
+function step2($word)
+{
+    switch (substr($word, -2, 1)) {
+        case 'a':
+               replace($word, 'ational', 'ate', 0)
+            OR replace($word, 'tional', 'tion', 0);
+            break;
+
+        case 'c':
+               replace($word, 'enci', 'ence', 0)
+            OR replace($word, 'anci', 'ance', 0);
+            break;
+
+        case 'e':
+            replace($word, 'izer', 'ize', 0);
+            break;
+
+        case 'g':
+            replace($word, 'logi', 'log', 0);
+            break;
+
+        case 'l':
+               replace($word, 'entli', 'ent', 0)
+            OR replace($word, 'ousli', 'ous', 0)
+            OR replace($word, 'alli', 'al', 0)
+            OR replace($word, 'bli', 'ble', 0)
+            OR replace($word, 'eli', 'e', 0);
+            break;
+
+        case 'o':
+               replace($word, 'ization', 'ize', 0)
+            OR replace($word, 'ation', 'ate', 0)
+            OR replace($word, 'ator', 'ate', 0);
+            break;
+
+        case 's':
+               replace($word, 'iveness', 'ive', 0)
+            OR replace($word, 'fulness', 'ful', 0)
+            OR replace($word, 'ousness', 'ous', 0)
+            OR replace($word, 'alism', 'al', 0);
+            break;
+
+        case 't':
+               replace($word, 'biliti', 'ble', 0)
+            OR replace($word, 'aliti', 'al', 0)
+            OR replace($word, 'iviti', 'ive', 0);
+            break;
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Step 3
 *
 * @param string $word String to stem
 */
-function step3($word) {
-  switch (substr($word, -2, 1)) {
-      case 'a':
-          replace($word, 'ical', 'ic', 0);
-          break;
-
-      case 's':
-          replace($word, 'ness', '', 0);
-          break;
-
-      case 't':
-            replace($word, 'icate', 'ic', 0)
-          OR replace($word, 'iciti', 'ic', 0);
-          break;
-
-      case 'u':
-          replace($word, 'ful', '', 0);
-          break;
-
-      case 'v':
-          replace($word, 'ative', '', 0);
-          break;
-
-      case 'z':
-          replace($word, 'alize', 'al', 0);
-          break;
-  }
+function step3($word)
+{
+    switch (substr($word, -2, 1)) {
+        case 'a':
+            replace($word, 'ical', 'ic', 0);
+            break;
+
+        case 's':
+            replace($word, 'ness', '', 0);
+            break;
+
+        case 't':
+              replace($word, 'icate', 'ic', 0)
+            OR replace($word, 'iciti', 'ic', 0);
+            break;
+
+        case 'u':
+            replace($word, 'ful', '', 0);
+            break;
+
+        case 'v':
+            replace($word, 'ative', '', 0);
+            break;
+
+        case 'z':
+            replace($word, 'alize', 'al', 0);
+            break;
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Step 4
 *
 * @param string $word Word to stem
 */
-function step4($word) {
-  switch (substr($word, -2, 1)) {
-      case 'a':
-          replace($word, 'al', '', 1);
-          break;
-
-      case 'c':
-             replace($word, 'ance', '', 1)
-          OR replace($word, 'ence', '', 1);
-          break;
-
-      case 'e':
-          replace($word, 'er', '', 1);
-          break;
-
-      case 'i':
-          replace($word, 'ic', '', 1);
-          break;
-
-      case 'l':
-             replace($word, 'able', '', 1)
-          OR replace($word, 'ible', '', 1);
-          break;
-
-      case 'n':
-             replace($word, 'ant', '', 1)
-          OR replace($word, 'ement', '', 1)
-          OR replace($word, 'ment', '', 1)
-          OR replace($word, 'ent', '', 1);
-          break;
-
-      case 'o':
-          if (substr($word, -4) == 'tion' OR substr($word, -4) == 'sion') {
-             replace($word, 'ion', '', 1);
-          } else {
-              replace($word, 'ou', '', 1);
-          }
-          break;
-
-      case 's':
-          replace($word, 'ism', '', 1);
-          break;
-
-      case 't':
-             replace($word, 'ate', '', 1)
-          OR replace($word, 'iti', '', 1);
-          break;
-
-      case 'u':
-          replace($word, 'ous', '', 1);
-          break;
-
-      case 'v':
-          replace($word, 'ive', '', 1);
-          break;
-
-      case 'z':
-          replace($word, 'ize', '', 1);
-          break;
-  }
+function step4($word)
+{
+    switch (substr($word, -2, 1)) {
+        case 'a':
+            replace($word, 'al', '', 1);
+            break;
+
+        case 'c':
+               replace($word, 'ance', '', 1)
+            OR replace($word, 'ence', '', 1);
+            break;
+
+        case 'e':
+            replace($word, 'er', '', 1);
+            break;
+
+        case 'i':
+            replace($word, 'ic', '', 1);
+            break;
+
+        case 'l':
+               replace($word, 'able', '', 1)
+            OR replace($word, 'ible', '', 1);
+            break;
+
+        case 'n':
+               replace($word, 'ant', '', 1)
+            OR replace($word, 'ement', '', 1)
+            OR replace($word, 'ment', '', 1)
+            OR replace($word, 'ent', '', 1);
+            break;
+
+        case 'o':
+            if (substr($word, -4) == 'tion' OR substr($word, -4) == 'sion') {
+               replace($word, 'ion', '', 1);
+            } else {
+                replace($word, 'ou', '', 1);
+            }
+            break;
+
+        case 's':
+            replace($word, 'ism', '', 1);
+            break;
+
+        case 't':
+               replace($word, 'ate', '', 1)
+            OR replace($word, 'iti', '', 1);
+            break;
+
+        case 'u':
+            replace($word, 'ous', '', 1);
+            break;
+
+        case 'v':
+            replace($word, 'ive', '', 1);
+            break;
+
+        case 'z':
+            replace($word, 'ize', '', 1);
+            break;
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Step 5
 *
 * @param string $word Word to stem
 */
-function step5($word) {
-  // Part a
-  if (substr($word, -1) == 'e') {
-      if (m(substr($word, 0, -1)) > 1) {
-          replace($word, 'e', '');
-
-      } else if (m(substr($word, 0, -1)) == 1) {
-
-          if (!cvc(substr($word, 0, -1))) {
-              replace($word, 'e', '');
-          }
-      }
-  }
+function step5($word)
+{
+    // Part a
+    if (substr($word, -1) == 'e') {
+        if (m(substr($word, 0, -1)) > 1) {
+            replace($word, 'e', '');
+
+        } else if (m(substr($word, 0, -1)) == 1) {
+
+            if (!cvc(substr($word, 0, -1))) {
+                replace($word, 'e', '');
+            }
+        }
+    }
 
-  // Part b
-  if (m($word) > 1 AND doubleConsonant($word) AND substr($word, -1) == 'l') {
-      $word = substr($word, 0, -1);
-  }
+    // Part b
+    if (m($word) > 1 AND doubleConsonant($word) AND substr($word, -1) == 'l') {
+        $word = substr($word, 0, -1);
+    }
 
-  return $word;
+    return $word;
 }
 
+
 /**
 * Replaces the first string with the second, at the end of the string. If third
 * arg is given, then the preceding string must match that m count at least.
@@ -317,22 +343,26 @@
 *                       of the $str string. True does not necessarily mean
 *                       that it was replaced.
 */
-function replace(&$str, $check, $repl, $m = null) {
-  $len = 0 - strlen($check);
+function replace(&$str, $check, $repl, $m = null)
+{
+    $len = 0 - strlen($check);
+
+    if (substr($str, $len) == $check) {
+        $substr = substr($str, 0, $len);
+        if (is_null($m) OR m($substr) > $m) {
+            $str = $substr . $repl;
+        }
 
-  if (substr($str, $len) == $check) {
-    $substr = substr($str, 0, $len);
-    if (is_null($m) OR m($substr) > $m) {
-      $str = $substr . $repl;
+        return true;
     }
 
-    return true;
-  }
-
-  return false;
+    return false;
 }
 
+
 /**
+* What, you mean it's not obvious from the name?
+*
 * m() measures the number of consonant sequences in $str. if c is
 * a consonant sequence and v a vowel sequence, and <..> indicates arbitrary
 * presence,
@@ -345,18 +375,20 @@
 * @param  string $str The string to return the m count for
 * @return int         The m count
 */
-function m($str) {
-  $c = regex_consonant;
-  $v = regex_vowel;
+function m($str)
+{
+    $c = regex_consonant;
+    $v = regex_vowel;
 
-  $str = preg_replace("#^$c+#", '', $str);
-  $str = preg_replace("#$v+$#", '', $str);
+    $str = preg_replace("#^$c+#", '', $str);
+    $str = preg_replace("#$v+$#", '', $str);
 
-  preg_match_all("#($v+$c+)#", $str, $matches);
+    preg_match_all("#($v+$c+)#", $str, $matches);
 
-  return count($matches[1]);
+    return count($matches[1]);
 }
 
+
 /**
 * Returns true/false as to whether the given string contains two
 * of the same consonant next to each other at the end of the string.
@@ -364,25 +396,31 @@
 * @param  string $str String to check
 * @return bool        Result
 */
-function doubleConsonant($str) {
-  $c = regex_consonant;
+function doubleConsonant($str)
+{
+    $c = regex_consonant;
 
-  return preg_match("#$c{2}$#", $str, $matches) AND $matches[0]{0} == $matches[0]{1};
+    return preg_match("#$c{2}$#", $str, $matches) AND $matches[0]{0} == $matches[0]{1};
 }
 
+
 /**
 * Checks for ending CVC sequence where second C is not W, X or Y
 *
 * @param  string $str String to check
 * @return bool        Result
 */
-function cvc($str) {
-  $c = regex_consonant;
-  $v = regex_vowel;
-
-  return     preg_match("#($c$v$c)$#", $str, $matches)
-         AND strlen($matches[1]) == 3
-         AND $matches[1]{2} != 'w'
-         AND $matches[1]{2} != 'x'
-         AND $matches[1]{2} != 'y';
-}
\ No newline at end of file
+function cvc($str)
+{
+    $c = regex_consonant;
+    $v = regex_vowel;
+
+    return     preg_match("#($c$v$c)$#", $str, $matches)
+           AND strlen($matches[1]) == 3
+           AND $matches[1]{2} != 'w'
+           AND $matches[1]{2} != 'x'
+           AND $matches[1]{2} != 'y';
+}
+
+
+?>
\ No newline at end of file
