You are here

protected function SearchApiPorter2::step4 in Search API 7

Implements step 4 of the Porter2 algorithm.

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

File

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

Class

SearchApiPorter2
Implements the Porter2 stemming algorithm.

Code

protected function step4() {
  $checks = array(
    'ement',
    'ment',
    'ance',
    'ence',
    'able',
    'ible',
    'ant',
    'ent',
    'ion',
    'ism',
    'ate',
    'iti',
    'ous',
    'ive',
    'ize',
    'al',
    'er',
    'ic',
  );
  foreach ($checks as $check) {

    // Among the suffixes, if found and in R2, delete.
    if ($this
      ->hasEnding($check)) {
      if ($this
        ->inR2($check)) {
        if ($check !== 'ion' || in_array($this
          ->charAt(-4), array(
          's',
          't',
        ))) {
          $this
            ->removeEnding($check);
        }
      }
      return;
    }
  }
}