敏感词过滤方案汇总以及高效工具sensitive-word
导入pom文件
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.12.0</version>
</dependency>
接下来我们编写相关测试类,来测试对应方法
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);