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即可
来源:oschina
链接:https://my.oschina.net/u/1437015/blog/793030