protected static function Porter2::step2 in Porter-Stemmer 8
Implements step 2 of the Porter2 algorithm.
Parameters
string $word: The word to stem.
Return value
string The modified word.
1 call to Porter2::step2()
- Porter2::stem in src/
Porter2.php - Computes the stem of the word.
File
- src/
Porter2.php, line 228
Class
- Porter2
- PHP Implementation of the Porter2 Stemming Algorithm.
Namespace
Drupal\porterstemmerCode
protected static function step2($word) {
$checks = [
"ization" => "ize",
"iveness" => "ive",
"fulness" => "ful",
"ational" => "ate",
"ousness" => "ous",
"biliti" => "ble",
"tional" => "tion",
"lessli" => "less",
"fulli" => "ful",
"entli" => "ent",
"ation" => "ate",
"aliti" => "al",
"iviti" => "ive",
"ousli" => "ous",
"alism" => "al",
"abli" => "able",
"anci" => "ance",
"alli" => "al",
"izer" => "ize",
"enci" => "ence",
"ator" => "ate",
"bli" => "ble",
"ogi" => "og",
];
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, 'li')) {
if (strlen($word) > 4 && self::validLi(self::charAt(-3, $word))) {
$word = self::removeEnding($word, 'li');
}
}
return $word;
}