protected static function Porter2::step5 in Porter-Stemmer 8
Implements step 5 of the Porter2 algorithm.
Parameters
string $word: The word to stem.
Return value
string The modified word.
1 call to Porter2::step5()
- Porter2::stem in src/
Porter2.php - Computes the stem of the word.
File
- src/
Porter2.php, line 359
Class
- Porter2
- PHP Implementation of the Porter2 Stemming Algorithm.
Namespace
Drupal\porterstemmerCode
protected static function step5($word) {
if (self::hasEnding($word, 'e')) {
// Delete if in R2, or in R1 and not preceded by a short syllable.
if (self::inR2($word, 'e') || self::inR1($word, 'e') && !self::isShortSyllable($word, strlen($word) - 3)) {
$word = self::removeEnding($word, 'e');
}
return $word;
}
if (self::hasEnding($word, 'l')) {
// Delete if in R2 and preceded by l.
if (self::inR2($word, 'l') && self::charAt(-2, $word) == 'l') {
$word = self::removeEnding($word, 'l');
}
}
return $word;
}