Changeset View
Changeset View
Standalone View
Standalone View
externals/porter-stemmer/src/Porter.php
Show First 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | class Porter | ||||
* @param string $str String to check | * @param string $str String to check | ||||
* | * | ||||
* @return bool Result | * @return bool Result | ||||
*/ | */ | ||||
private static function doubleConsonant($str) | private static function doubleConsonant($str) | ||||
{ | { | ||||
$c = self::$regex_consonant; | $c = self::$regex_consonant; | ||||
return preg_match("#$c{2}$#", $str, $matches) AND $matches[0]{0} == $matches[0]{1}; | return preg_match("#$c{2}$#", $str, $matches) AND $matches[0][0] == $matches[0][1]; | ||||
} | } | ||||
/** | /** | ||||
* Checks for ending CVC sequence where second C is not W, X or Y | * Checks for ending CVC sequence where second C is not W, X or Y | ||||
* | * | ||||
* @param string $str String to check | * @param string $str String to check | ||||
* | * | ||||
* @return bool Result | * @return bool Result | ||||
*/ | */ | ||||
private static function cvc($str) | private static function cvc($str) | ||||
{ | { | ||||
$c = self::$regex_consonant; | $c = self::$regex_consonant; | ||||
$v = self::$regex_vowel; | $v = self::$regex_vowel; | ||||
return preg_match("#($c$v$c)$#", $str, $matches) | return preg_match("#($c$v$c)$#", $str, $matches) | ||||
AND strlen($matches[1]) == 3 | AND strlen($matches[1]) == 3 | ||||
AND $matches[1]{2} != 'w' | AND $matches[1][2] != 'w' | ||||
AND $matches[1]{2} != 'x' | AND $matches[1][2] != 'x' | ||||
AND $matches[1]{2} != 'y'; | AND $matches[1][2] != 'y'; | ||||
} | } | ||||
} | } |