You are here

function porterstemmer_step1a in Porter-Stemmer 6.2

Same name and namespace in other branches
  1. 7 includes/standard-stemmer.inc \porterstemmer_step1a()

Step 1a of algorithm: plurals, etc.

Parameters

$word: Word to stem, modified in place if successful.

Return value

TRUE if it is time to stop stemming, FALSE to continue.

2 calls to porterstemmer_step1a()
PorterStemmerInternalsUnitTest::testIesIed in ./porterstemmer.test
Test internal steps on the words "ies" and "ied".
porterstemmer_stem in ./porterstemmer.module
Stems a word, using the Porter Stemmer 2 algorithm.

File

./porterstemmer.module, line 432
This is an implementation of the Porter 2 Stemming algorithm from http://snowball.tartarus.org/algorithms/english/stemmer.html by Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Code

function porterstemmer_step1a(&$word) {
  $tmp = $word;
  $didit = FALSE;
  $done = porterstemmer_suffix($tmp, 'sses', 'ss', $didit);

  // ies/ied endings -- have different replacements depending on
  // if there is more than one letter preceeding. So make sure to
  // test/replace for both conditions.
  if (!$done && porterstemmer_suffix($tmp, 'ies', 'ie', $didit, '/^.?ies$/')) {
    if (!$didit) {
      porterstemmer_suffix($tmp, 'ies', 'i', $didit);
    }
    $done = TRUE;
  }
  if (!$done && porterstemmer_suffix($tmp, 'ied', 'ie', $didit, '/^.?ied$/')) {
    if (!$didit) {
      porterstemmer_suffix($tmp, 'ied', 'i', $didit);
    }
    $done = TRUE;
  }
  if (!$done) {
    porterstemmer_suffix($tmp, 'ss', 'ss', $didit) or porterstemmer_suffix($tmp, 'us', 'us', $didit) or porterstemmer_suffix($tmp, 's', '', $didit, '/' . PORTERSTEMMER_VOWEL . '.+s$/');
  }
  return porterstemmer_step_ending($word, $tmp);
}