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);
相关推荐
别叫我->学废了->lol在线等4 分钟前
演示 hasattr 和 ** 解包操作符
开发语言·前端·python
霍夫曼11 分钟前
UTC时间与本地时间转换问题
java·linux·服务器·前端·javascript
VX:Fegn089518 分钟前
计算机毕业设计|基于Java人力资源管理系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·后端·课程设计
荔枝hu30 分钟前
springboot和shiro组合引入SseEmitter的一些坑
java·spring boot·后端·sseeitter
老华带你飞1 小时前
健身房|基于springboot + vue健身房管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端
JIngJaneIL1 小时前
基于Java酒店预约系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot
编程小Y1 小时前
php.ini 的核心作用与全面解析
开发语言·php
曹牧1 小时前
Java:List<Map<String, String>>转换为字符串
java·开发语言·windows
我是一棵无人问荆的小草1 小时前
编码演变史
开发语言·c++
Unstoppable222 小时前
代码随想录算法训练营第 56 天 | 拓扑排序精讲、Dijkstra(朴素版)精讲
java·数据结构·算法·