protected static function Porter2::step1a in Porter-Stemmer 8
Handles various suffixes, of which the longest is replaced.
Parameters
string $word: The word to stem.
Return value
string The modified word.
1 call to Porter2::step1a()
- Porter2::stem in src/
Porter2.php - Computes the stem of the word.
File
- src/
Porter2.php, line 113
Class
- Porter2
- PHP Implementation of the Porter2 Stemming Algorithm.
Namespace
Drupal\porterstemmerCode
protected static function step1a($word) {
$found = FALSE;
if (self::hasEnding($word, 'sses')) {
$word = self::removeEnding($word, 'sses') . 'ss';
$found = TRUE;
}
$checks = [
'ied',
'ies',
];
foreach ($checks as $check) {
if (!$found && self::hasEnding($word, $check)) {
// @todo: check order here.
$length = strlen($word);
$word = self::removeEnding($word, $check);
if ($length > 4) {
$word .= 'i';
}
else {
$word .= 'ie';
}
$found = TRUE;
}
}
if (self::hasEnding($word, 'us') || self::hasEnding($word, 'ss')) {
$found = TRUE;
}
// Delete if preceding word part has a vowel not immediately before the s.
if (!$found && self::hasEnding($word, 's') && self::containsVowel(substr($word, 0, -2))) {
$word = self::removeEnding($word, 's');
}
return $word;
}