protected function SearchApiPorter2::isShortSyllable in Search API 7
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 SearchApiPorter2::isShortSyllable()
- SearchApiPorter2::isShort in includes/
processor_stemmer.inc - Determines whether the word is short.
- SearchApiPorter2::step5 in includes/
processor_stemmer.inc - Implements step 5 of the Porter2 algorithm.
File
- includes/
processor_stemmer.inc, line 539 - Contains SearchApiPorterStemmer and SearchApiPorter2.
Class
- SearchApiPorter2
- Implements the Porter2 stemming algorithm.
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 = array(
'w',
'x',
'Y',
);
return !$this
->isVowel($position - 1) && $this
->isVowel($position) && !$this
->isVowel($position + 1, NULL, $additional);
}