You are here

protected function Porter2::isShortSyllable in Search API 8

Determines whether the word ends in a "vowel-consonant" suffix.

Unless the word is only two characters long, it also checks that the third-last character is neither "w", "x" nor "Y".

Parameters

int|null $position: (optional) If given, do not check the end of the word, but the character at the given position, and the next one.

Return value

bool TRUE if the word has the described suffix, FALSE otherwise.

2 calls to Porter2::isShortSyllable()
Porter2::isShort in src/Plugin/search_api/processor/Resources/Porter2.php
Determines whether the word is short.
Porter2::step5 in src/Plugin/search_api/processor/Resources/Porter2.php
Implements step 5 of the Porter2 algorithm.

File

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

Class

Porter2
Implements the Porter2 stemming algorithm.

Namespace

Drupal\search_api\Plugin\search_api\processor\Resources

Code

protected function isShortSyllable($position = NULL) {
  if ($position === NULL) {
    $position = $this
      ->length() - 2;
  }

  // A vowel at the beginning of the word followed by a non-vowel.
  if ($position === 0) {
    return $this
      ->isVowel(0) && !$this
      ->isVowel(1);
  }

  // Vowel followed by non-vowel other than w, x, Y and preceded by
  // non-vowel.
  $additional = [
    'w',
    'x',
    'Y',
  ];
  return !$this
    ->isVowel($position - 1) && $this
    ->isVowel($position) && !$this
    ->isVowel($position + 1, NULL, $additional);
}