You are here

protected function SearchApiPorter2::step1a in Search API 7

Handles various suffixes, of which the longest is replaced.

Implements step 1a of the Porter2 algorithm.

1 call to SearchApiPorter2::step1a()
SearchApiPorter2::stem in includes/processor_stemmer.inc
Computes the stem of the word.

File

includes/processor_stemmer.inc, line 233
Contains SearchApiPorterStemmer and SearchApiPorter2.

Class

SearchApiPorter2
Implements the Porter2 stemming algorithm.

Code

protected function step1a() {
  $found = FALSE;
  if ($this
    ->hasEnding('sses')) {
    $this
      ->removeEnding('sses');
    $this
      ->addEnding('ss');
    $found = TRUE;
  }
  $checks = array(
    'ied',
    'ies',
  );
  foreach ($checks as $check) {
    if (!$found && $this
      ->hasEnding($check)) {
      $length = $this
        ->length();
      $this
        ->removeEnding($check);
      if ($length > 4) {
        $this
          ->addEnding('i');
      }
      else {
        $this
          ->addEnding('ie');
      }
      $found = TRUE;
    }
  }
  if ($this
    ->hasEnding('us') || $this
    ->hasEnding('ss')) {
    $found = TRUE;
  }

  // Delete if preceding word part has a vowel not immediately before the s.
  if (!$found && $this
    ->hasEnding('s') && $this
    ->containsVowel(substr($this->word, 0, -2))) {
    $this
      ->removeEnding('s');
  }
}