You are here

function porterstemmer_step5 in Porter-Stemmer 6.2

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

Step 5 of algorithm: e, l endings in region R1/R2.

Parameters

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

$r1: Position of start of R1 region in word.

$r2: Position of start of R2 region in word.

Return value

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

2 calls to porterstemmer_step5()
PorterStemmerInternalsUnitTest::testBaked in ./porterstemmer.test
Test internal steps on the word "baked".
porterstemmer_stem in ./porterstemmer.module
Stems a word, using the Porter Stemmer 2 algorithm.

File

./porterstemmer.module, line 665
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_step5(&$word, $r1, $r2) {
  $tmp = $word;
  $didit = FALSE;
  $done = FALSE;

  // Delete l at end of word if in R2 and preceded by another l
  $done = porterstemmer_suffix($tmp, 'll', 'l', $didit, NULL, $r2 + 1);

  // Delete e at end of word if in R2, or in R1 and not preceded by
  // a short syllable
  $len = drupal_strlen($tmp);
  if (!$done && preg_match('/e$/', $tmp) && ($len > $r2 || $len > $r1 && !preg_match('/^' . PORTERSTEMMER_VOWEL . PORTERSTEMMER_NOT_VOWEL . 'e$/', $tmp) && !preg_match('/' . PORTERSTEMMER_NOT_VOWEL . PORTERSTEMMER_VOWEL . PORTERSTEMMER_NOT_VOWEL_WXY . 'e$/', $tmp))) {
    $tmp = drupal_substr($tmp, 0, -1);
  }
  return porterstemmer_step_ending($word, $tmp);
}