aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Stemmer.php
diff options
context:
space:
mode:
authorAlexander Kiryukhin <alexander@kiryukhin.su>2017-11-22 15:48:01 +0300
committerGitHub <noreply@github.com>2017-11-22 15:48:01 +0300
commit24910f8add42cb281506751ecb916f7a27e1448f (patch)
tree4e1009d0bb6347c2b6ba4b79ad1ff9c680ba18df /src/NXP/Stemmer.php
parentb715fe440277acfe871c0ae02b2771e8a3a5851e (diff)
parentf5bdd18316f47c0bc62023df2585e037dcbb4252 (diff)
Merge pull request #9 from vklimin/patch-2
Update Stemmer.php
Diffstat (limited to 'src/NXP/Stemmer.php')
-rw-r--r--src/NXP/Stemmer.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/NXP/Stemmer.php b/src/NXP/Stemmer.php
index f38a1b1..0188434 100644
--- a/src/NXP/Stemmer.php
+++ b/src/NXP/Stemmer.php
@@ -92,17 +92,17 @@ class Stemmer
*/
public static function removeEndings(&$word, $regex, $region)
{
- $prefix = mb_substr($word, 0, $region, 'utf8');
+ $prefix = mb_substr($word, 0, $region, 'UTF-8');
$ending = substr($word, strlen($prefix));
if (is_array($regex)) {
- if (preg_match('/.+[а|я]' . $regex[0] . '/u', $ending)) {
- $word = $prefix . preg_replace('/' . $regex[0] . '/u', '', $ending);
+ if (preg_match('/.+[а|я]' . $regex[0] . '/ui', $ending)) {
+ $word = $prefix . preg_replace('/' . $regex[0] . '/ui', '', $ending);
return true;
}
$regex = $regex[1];
}
- if (preg_match('/.+' . $regex . '/u', $ending)) {
- $word = $prefix . preg_replace('/' . $regex . '/u', '', $ending);
+ if (preg_match('/.+' . $regex . '/ui', $ending)) {
+ $word = $prefix . preg_replace('/' . $regex . '/ui', '', $ending);
return true;
}
@@ -118,10 +118,10 @@ class Stemmer
{
$rv = 0;
$state = 0;
- $wordLength = mb_strlen($word, 'utf8');
+ $wordLength = mb_strlen($word, 'UTF-8');
for ($i = 1; $i < $wordLength; $i++) {
- $prevChar = mb_substr($word, $i - 1, 1, 'utf8');
- $char = mb_substr($word, $i, 1, 'utf8');
+ $prevChar = mb_substr($word, $i - 1, 1, 'UTF-8');
+ $char = mb_substr($word, $i, 1, 'UTF-8');
switch ($state) {
case 0:
if (self::isVowel($char)) {
@@ -152,6 +152,6 @@ class Stemmer
*/
private static function isVowel($char)
{
- return strpos(self::VOWEL, $char) !== false;
+ return mb_stripos(self::VOWEL, $char, 0, 'UTF-8') !== false;
}
}