gpt4 book ai didi

list - "bad words"过滤器

转载 作者:行者123 更新时间:2023-12-02 03:32:06 26 4
gpt4 key购买 nike

关闭。这个问题是off-topic .它目前不接受答案。












想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。

8年前关闭。




Improve this question




不是很技术,但是... 我必须在我们正在开发的新站点中实现一个坏词过滤器。所以我需要一个“好”的坏词列表来为我的数据库提供......任何提示/方向?用谷歌环顾四周found this一,这是一个开始,但仅此而已。

是的,我知道这种过滤器很容易逃脱...但客户将是客户将! :-)

该网站必须过滤掉英语和意大利语单词,但对于意大利语,我可以请我的同事帮助我使用社区构建的“parolacce”列表:-) - 一封电子邮件就可以了。

谢谢你的帮助。

最佳答案

我没有看到任何指定的语言,但您可以将它用于 PHP,它会为每个插入的工作生成一个 RegEx,这样即使是故意的拼写错误(即 @ss, i3itch )也会被捕获。

<?php

/**
* @author unkwntech@unkwndesign.com
**/

if($_GET['act'] == 'do')
{
$pattern['a'] = '/[a]/'; $replace['a'] = '[a A @]';
$pattern['b'] = '/[b]/'; $replace['b'] = '[b B I3 l3 i3]';
$pattern['c'] = '/[c]/'; $replace['c'] = '(?:[c C (]|[k K])';
$pattern['d'] = '/[d]/'; $replace['d'] = '[d D]';
$pattern['e'] = '/[e]/'; $replace['e'] = '[e E 3]';
$pattern['f'] = '/[f]/'; $replace['f'] = '(?:[f F]|[ph pH Ph PH])';
$pattern['g'] = '/[g]/'; $replace['g'] = '[g G 6]';
$pattern['h'] = '/[h]/'; $replace['h'] = '[h H]';
$pattern['i'] = '/[i]/'; $replace['i'] = '[i I l ! 1]';
$pattern['j'] = '/[j]/'; $replace['j'] = '[j J]';
$pattern['k'] = '/[k]/'; $replace['k'] = '(?:[c C (]|[k K])';
$pattern['l'] = '/[l]/'; $replace['l'] = '[l L 1 ! i]';
$pattern['m'] = '/[m]/'; $replace['m'] = '[m M]';
$pattern['n'] = '/[n]/'; $replace['n'] = '[n N]';
$pattern['o'] = '/[o]/'; $replace['o'] = '[o O 0]';
$pattern['p'] = '/[p]/'; $replace['p'] = '[p P]';
$pattern['q'] = '/[q]/'; $replace['q'] = '[q Q 9]';
$pattern['r'] = '/[r]/'; $replace['r'] = '[r R]';
$pattern['s'] = '/[s]/'; $replace['s'] = '[s S $ 5]';
$pattern['t'] = '/[t]/'; $replace['t'] = '[t T 7]';
$pattern['u'] = '/[u]/'; $replace['u'] = '[u U v V]';
$pattern['v'] = '/[v]/'; $replace['v'] = '[v V u U]';
$pattern['w'] = '/[w]/'; $replace['w'] = '[w W vv VV]';
$pattern['x'] = '/[x]/'; $replace['x'] = '[x X]';
$pattern['y'] = '/[y]/'; $replace['y'] = '[y Y]';
$pattern['z'] = '/[z]/'; $replace['z'] = '[z Z 2]';
$word = str_split(strtolower($_POST['word']));
$i=0;
while($i < count($word))
{
if(!is_numeric($word[$i]))
{
if($word[$i] != ' ' || count($word[$i]) < '1')
{
$word[$i] = preg_replace($pattern[$word[$i]], $replace[$word[$i]], $word[$i]);
}
}
$i++;
}
//$word = "/" . implode('', $word) . "/";
echo implode('', $word);
}

if($_GET['act'] == 'list')
{
$link = mysql_connect('localhost', 'username', 'password', '1');
mysql_select_db('peoples');
$sql = "SELECT word FROM filters";
$result = mysql_query($sql, $link);
$i=0;
while($i < mysql_num_rows($result))
{
echo mysql_result($result, $i, 'word') . "<br />";
$i++;
}
echo '<hr>';
}
?>
<html>
<head>
<title>RegEx Generator</title>
</head>
<body>
<form action='badword.php?act=do' method='post'>
Word: <input type='text' name='word' /><br />
<input type='submit' value='Generate' />
</form>
<a href="badword.php?act=list">List Words</a>
</body>
</html>

关于list - "bad words"过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com