File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1
1
# php-DFA-filterWord
2
2
php实现基于确定有穷自动机算法的铭感词过滤
3
+
4
+ ### 使用流程
5
+ > 获取敏感词库
6
+
7
+ //获取感词库索引数组
8
+ $wordData = array(
9
+ '察象蚂',
10
+ '拆迁灭',
11
+ '车牌隐',
12
+ '成人电',
13
+ '成人卡通',
14
+ ......
15
+ );
16
+
17
+ > 构建敏感词hashMap
18
+
19
+ //构建敏感词hashMap
20
+ $sensitiveWordMap = LSensitiveWordFilter::init()->setHashMap($wordData);
21
+
22
+ > 敏感词过滤
23
+
24
+ //敏感词替换为***为例
25
+ LSensitiveWordFilter::init()->replaceSensitiveWord($sensitiveWordMap, $content, '***');
26
+
27
+ > 你也可以获取文字中的敏感词
28
+
29
+ //获取内容中所有的敏感词
30
+ $sensitiveWordGroup = LSensitiveWordFilter::init()->getSensitiveWord($sensitiveWordMap, $content);
31
+ //仅且获取一个敏感词
32
+ $sensitiveWordGroup = LSensitiveWordFilter::init()->getSensitiveWord($sensitiveWordMap, $content, 1);
33
+
34
+ * 如果大家有更好的建议,请大家多多指正,O(∩_ ∩)O谢谢*
You can’t perform that action at this time.
0 commit comments