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);
相关推荐
bagadesu4 分钟前
15.<Spring Boot 日志>
java·后端
小龙报6 分钟前
《嵌入式成长系列之51单片机 --- Keil5创建工程》
c语言·开发语言·c++·单片机·嵌入式硬件·51单片机·学习方法
laplace012313 分钟前
Maven
java·maven
wdfk_prog15 分钟前
Xshell终端连接Ubuntu/Debian无颜色的解决方案
java·ubuntu·debian
无限进步_30 分钟前
【C语言】贪吃蛇游戏设计思路深度解析:从零开始理解每个模块
c语言·开发语言·c++·git·游戏·github·visual studio
艾迪的技术之路32 分钟前
linux上gitlab runner部署文档
java·github
凌波粒35 分钟前
SpringMVC基础教程(3)--SSM框架整合
java·sql·spring·intellij-idea·mybatis
听风吟丶38 分钟前
Java 函数式编程深度实战:从 Lambda 到 Stream API 的工程化落地
开发语言·python
2021_fc1 小时前
分布式应用可观测全链路追踪技术
java
数据的世界011 小时前
JAVA和C#的语法对比
java·windows·c#