Crowdin localization integration prepare and stopwords removal

This commit is contained in:
Yuriy Pikhtarev 2017-02-10 04:15:58 +03:00
commit 4b9965b062
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
51 changed files with 3145 additions and 1894 deletions

View file

@ -2198,7 +2198,7 @@ function clean_title($str, $replace_underscore = false)
return $str;
}
function clean_text_match($text, $ltrim_star = true, $remove_stopwords = false, $die_if_empty = false)
function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
{
global $bb_cfg, $lang;
@ -2208,10 +2208,6 @@ function clean_text_match($text, $ltrim_star = true, $remove_stopwords = false,
$text = ' ' . str_compact(ltrim($text, $ltrim_chars)) . ' ';
if ($remove_stopwords) {
$text = remove_stopwords($text);
}
if ($bb_cfg['search_engine_type'] == 'sphinx') {
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно)
@ -2334,18 +2330,6 @@ function decode_text_match($txt)
return str_replace('&#039;', "'", $txt);
}
function remove_stopwords($text)
{
static $stopwords = null;
if (is_null($stopwords)) {
$stopwords = explode(' ', str_compact(@file_get_contents(LANG_DIR . 'search_stopwords.txt')));
array_deep($stopwords, 'pad_with_space');
}
return ($stopwords) ? str_replace($stopwords, ' ', $text) : $text;
}
function pad_with_space($str)
{
return ($str) ? " $str " : $str;