You are here

protected static function Porter2::removeDoubles in Porter-Stemmer 8

Removes certain double consonants from the word's end.

Parameters

string $word: The word to stem.

Return value

string The modified word.

1 call to Porter2::removeDoubles()
Porter2::step1b in src/Porter2.php
Handles various suffixes, of which the longest is replaced.

File

src/Porter2.php, line 385

Class

Porter2
PHP Implementation of the Porter2 Stemming Algorithm.

Namespace

Drupal\porterstemmer

Code

protected static function removeDoubles($word) {
  $doubles = [
    'bb',
    'dd',
    'ff',
    'gg',
    'mm',
    'nn',
    'pp',
    'rr',
    'tt',
  ];
  foreach ($doubles as $double) {
    if (substr($word, -2) == $double) {
      $word = substr($word, 0, -1);
      break;
    }
  }
  return $word;
}