Update Stemmer.php

Так будет корректнее.
This commit is contained in:
Vitaliy Klimin 2018-01-11 19:27:19 +05:00 committed by GitHub
parent 24910f8add
commit b3d54cec21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -93,7 +93,7 @@ class Stemmer
public static function removeEndings(&$word, $regex, $region) public static function removeEndings(&$word, $regex, $region)
{ {
$prefix = mb_substr($word, 0, $region, 'UTF-8'); $prefix = mb_substr($word, 0, $region, 'UTF-8');
$ending = substr($word, strlen($prefix)); $ending = mb_substr($word, mb_strlen($prefix, 'UTF-8'), null, 'UTF-8');
if (is_array($regex)) { if (is_array($regex)) {
if (preg_match('/.+[а|я]' . $regex[0] . '/ui', $ending)) { if (preg_match('/.+[а|я]' . $regex[0] . '/ui', $ending)) {
$word = $prefix . preg_replace('/' . $regex[0] . '/ui', '', $ending); $word = $prefix . preg_replace('/' . $regex[0] . '/ui', '', $ending);