php5.6关键词过滤扩展php-ext-trie-filter添加

徘徊边缘 提交于 2020-04-24 14:06:20

php extension for spam word filter based on Double-Array Trie tree, it can detect if a spam word exists in a text message.

关键词过滤扩展,用于检查一段文本中是否出现敏感词,基于Double-Array Trie 树实现。

1、安装libiconv,这个是libdatrie的依赖项
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
make && make install && ldconfig

2、安装libdatrie (http://linux.thai.net/~thep/datrie/datrie.html)
wget ftp://linux.thai.net/pub/ThaiLinux/software/libthai/libdatrie-0.2.4.tar.gz
tar zxf libdatrie-0.2.4.tar.gz 
cd libdatrie-0.2.4 
make clean
./configure LDFLAGS=-L/usr/local/lib LIBS=-liconv --prefix=/usr/local/libdatrie
make && make install

3、添加trie-filter
yum install unzip -y
wget https://github.com/wulijun/php-ext-trie-filter/archive/master.zip

#php7.0.13使用 https://github.com/zzjin/php-ext-trie-filter/archive/php7.zip

unzip master.zip
cd php-ext-trie-filter-master
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-trie_filter=/usr/local/libdatrie
make && make install
echo "extension=trie_filter.so" >> /usr/local/php/etc/php.ini
重启php-fpm即可

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!