You are here

protected function Porter2::removeDoubles in Search API 8

Removes certain double consonants from the word's end.

Return value

bool TRUE if a match was found and removed, FALSE otherwise.

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

File

src/Plugin/search_api/processor/Resources/Porter2.php, line 381

Class

Porter2
Implements the Porter2 stemming algorithm.

Namespace

Drupal\search_api\Plugin\search_api\processor\Resources

Code

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