You are here

public function SearchApiPorter2::__construct in Search API 7

Constructs a SearchApiPorter2 object.

Parameters

string $word: The word to stem.

string[] $custom_exceptions: (optional) A custom list of exceptions.

File

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

Class

SearchApiPorter2
Implements the Porter2 stemming algorithm.

Code

public function __construct($word, $custom_exceptions = array()) {
  $this->word = $word;
  $this->exceptions = $custom_exceptions + array(
    'skis' => 'ski',
    'skies' => 'sky',
    'dying' => 'die',
    'lying' => 'lie',
    'tying' => 'tie',
    'idly' => 'idl',
    'gently' => 'gentl',
    'ugly' => 'ugli',
    'early' => 'earli',
    'only' => 'onli',
    'singly' => 'singl',
    'sky' => 'sky',
    'news' => 'news',
    'howe' => 'howe',
    'atlas' => 'atlas',
    'cosmos' => 'cosmos',
    'bias' => 'bias',
    'andes' => 'andes',
  );

  // Set initial y, or y after a vowel, to Y.
  $inc = 0;
  while ($inc <= $this
    ->length()) {
    if (substr($this->word, $inc, 1) === 'y' && ($inc == 0 || $this
      ->isVowel($inc - 1))) {
      $this->word = substr_replace($this->word, 'Y', $inc, 1);
    }
    $inc++;
  }

  // Establish the regions R1 and R2. See function R().
  $this->r1 = $this
    ->R(1);
  $this->r2 = $this
    ->R(2);
}