DFA算法 敏感词过滤方案汇总以及高效工具sensitive-word

敏感词过滤方案汇总以及高效工具sensitive-word

导入pom文件

c 复制代码
<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>sensitive-word</artifactId>
    <version>0.12.0</version>
</dependency>

接下来我们编写相关测试类,来测试对应方法

c 复制代码
final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前";
//判断是否包含敏感词
boolean result = SensitiveWordHelper.contains(text);
System.out.println(result);
//返回第一个敏感词
String word = SensitiveWordHelper.findFirst(text);
System.out.println(word);
//返回所有敏感词
List<String> wordList = SensitiveWordHelper.findAll(text);
System.out.println(wordList);
//默认的替换策略
String replace = SensitiveWordHelper.replace(text);
System.out.println(replace);
//指定替换内容
String replace1 = SensitiveWordHelper.replace(text, '0');
System.out.println(replace1);
相关推荐
松涛和鸣15 小时前
22、双向链表作业实现与GDB调试实战
c语言·开发语言·网络·数据结构·链表·排序算法
h***047717 小时前
SpringBoot(7)-Swagger
java·spring boot·后端
v***913018 小时前
Spring boot创建时常用的依赖
java·spring boot·后端
xlq2232221 小时前
22.多态(上)
开发语言·c++·算法
666HZ66621 小时前
C语言——高精度加法
c语言·开发语言·算法
代码or搬砖21 小时前
MyBatisPlus讲解(二)
java·mybatis
星释21 小时前
Rust 练习册 100:音乐音阶生成器
开发语言·后端·rust
lcu11121 小时前
Java 学习42:抽象
java
Mr.朱鹏21 小时前
RocketMQ安装与部署指南
java·数据库·spring·oracle·maven·rocketmq·seata
雨中飘荡的记忆21 小时前
Spring表达式详解:SpEL从入门到实战
java·spring