- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
function sinonimizer($my_text)
{
$arr_ = file(dirname(__FILE__).'/new_words.txt');
$arr = array();
foreach ($arr_ as $str)
{
$str = trim($str);
$t1 = explode('|', $str);
$master = trim($t1[0]); //пихаем слово которое заменять
if (!isset($t1[1]))
continue;
$t2 = explode('|', $t1[1]); //Тут слово которым заменять
if (sizeof($t2) == 0)
continue;
//Дальше волшебные мунипуляции
foreach ($t2 as $t)
$arr[crc32(strtolower($master))][crc32(strtolower(trim($t)))] = array('word' =>
trim($t), 'rep' => 0);
}
$my_text=str_replace(array("\n","\t","\r")," ",$my_text);
$text_arr = explode(' ', $my_text);
$str_ = '';
foreach ($text_arr as $item)
{
$fl = false;
$t = str_replace('.', '', str_replace(',', '', str_replace('!', '',
str_replace('?', '', str_replace('"', '', str_replace('\'', '',
str_replace('<', '', str_replace('>', '', str_replace(':', '',
str_replace(';', '', $item))))))))));
if (isset($arr[crc32(strtolower($t))]))
{
foreach ($arr[crc32(strtolower($t))] as $k => $v)
if ($v['rep'] == 0)
{
$str_ .= str_ireplace($t, "$v[word]", $item) . ' ';
$$v['rep'] = 1;
$fl = true;
break;
}
}
if (!$fl) $str_ .= $item . ' ';
}
return $str_;
}
function sinonimizer_new($my_text)
{
$arr_ = file(dirname(__FILE__).'/new_words.txt');
$arr = array();
foreach ($arr_ as $str)
{
$str = trim($str);
$t1 = explode('|', $str);
$master = trim($t1[0]); //пихаем слово которое заменять
if (!isset($t1[1]))
continue;
$t2 = explode('|', $t1[1]); //Тут слово которым заменять
if (sizeof($t2) == 0)
continue;
//Дальше волшебные мунипуляции
foreach ($t2 as $t)
$arr[(strtolower($master))][(strtolower(trim($t)))] = array('word' =>
trim($t), 'rep' => 0);
}
$my_text=str_replace(array("\n","\t","\r")," ",$my_text);
$text_arr = explode(' ', $my_text);
$str_ = '';
foreach ($text_arr as $item)
{
$fl = false;
$t = str_replace('.', '', str_replace(',', '', str_replace('!', '',
str_replace('?', '', str_replace('"', '', str_replace('\'', '',
str_replace('<', '', str_replace('>', '', str_replace(':', '',
str_replace(';', '', $item))))))))));
if (isset($arr[(strtolower($t))]))
{
foreach ($arr[(strtolower($t))] as $k => $v)
if ($v['rep'] == 0)
{
$str_ .= str_ireplace($t, "$v[word]", $item) . ' ';
$$v['rep'] = 1;
$fl = true;
break;
}
}
if (!$fl) $str_ .= $item . ' ';
}
return $str_;