mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Crowdin localization integration prepare and stopwords removal
This commit is contained in:
parent
e87f1beff0
commit
4b9965b062
51 changed files with 3145 additions and 1894 deletions
|
@ -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(''', "'", $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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue