protected static function Porter2::step3 in Porter-Stemmer 8
Implements step 3 of the Porter2 algorithm.
Parameters
string $word: The word to stem.
Return value
string The modified word.
1 call to Porter2::step3()
- Porter2::stem in src/
Porter2.php - Computes the stem of the word.
File
- src/
Porter2.php, line 279
Class
- Porter2
- PHP Implementation of the Porter2 Stemming Algorithm.
Namespace
Drupal\porterstemmerCode
protected static function step3($word) {
$checks = [
'ational' => 'ate',
'tional' => 'tion',
'alize' => 'al',
'icate' => 'ic',
'iciti' => 'ic',
'ical' => 'ic',
'ness' => '',
'ful' => '',
];
foreach ($checks as $find => $replace) {
if (self::hasEnding($word, $find)) {
if (self::inR1($word, $find)) {
$word = self::removeEnding($word, $find) . $replace;
}
return $word;
}
}
if (self::hasEnding($word, 'ative')) {
if (self::inR2($word, 'ative')) {
$word = self::removeEnding($word, 'ative');
}
}
return $word;
}