You are here

function porterstemmer_step1a in Porter-Stemmer 7

Same name and namespace in other branches
  1. 6.2 porterstemmer.module \porterstemmer_step1a()

Step 1a of algorithm: plurals, etc.

Parameters

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

Return value

bool 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 includes/standard-stemmer.inc
Stems a word, using the Porter Stemmer 2 algorithm.

File

includes/standard-stemmer.inc, line 304
This is an implementation of the Porter 2 Stemming algorithm.

Code

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

  // The 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);
}