mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
release branch 0.0.14
This commit is contained in:
@@ -99,4 +99,10 @@
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:---|:---|:---|:--|
|
||||
| 1 | A | 新增 Helper 工具类 | 2021-5-12 20:51:58 | |
|
||||
| 2 | A | 新增动态词库初始化支持 | 2021-5-12 20:51:58 | |
|
||||
| 2 | A | 新增动态词库初始化支持 | 2021-5-12 20:51:58 | |
|
||||
|
||||
# release_0.0.14
|
||||
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:---|:---|:---|:--|
|
||||
| 1 | A | 开发样式配置特性 | 2021-5-31 20:51:58 | |
|
||||
|
||||
40
README.md
40
README.md
@@ -188,6 +188,46 @@ List<String> wordList = SensitiveWordHelper.findAll(text);
|
||||
Assert.assertEquals("[sensitiveword@xx.com]", wordList.toString());
|
||||
```
|
||||
|
||||
# 特性配置
|
||||
|
||||
## 说明
|
||||
|
||||
上面的特性默认都是开启的,有时业务需要灵活定义相关的配置特性。
|
||||
|
||||
所以 v0.0.14 开放了属性配置。
|
||||
|
||||
## 配置方法
|
||||
|
||||
为了让使用更加优雅,统一使用 fluent-api 的方式定义。
|
||||
|
||||
用户可以使用 `SensitiveWordBs` 进行如下定义:
|
||||
|
||||
```java
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.ignoreCase(true)
|
||||
.ignoreWidth(true)
|
||||
.ignoreNumStyle(true)
|
||||
.ignoreChineseStyle(true)
|
||||
.ignoreEnglishStyle(true)
|
||||
.ignoreRepeat(true)
|
||||
.init();
|
||||
|
||||
final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
|
||||
Assert.assertTrue(wordBs.contains(text));
|
||||
```
|
||||
## 配置说明
|
||||
|
||||
其中各项配置的说明如下:
|
||||
|
||||
| 序号 | 方法 | 说明 |
|
||||
|:---|:---|:---|
|
||||
| 1 | ignoreCase | 忽略大小写 |
|
||||
| 2 | ignoreWidth | 忽略半角圆角 |
|
||||
| 3 | ignoreNumStyle | 忽略数字的写法 |
|
||||
| 4 | ignoreChineseStyle | 忽略中文的书写格式 |
|
||||
| 5 | ignoreEnglishStyle | 忽略英文的书写格式 |
|
||||
| 6 | ignoreRepeat | 忽略重复词 |
|
||||
|
||||
# 用户自定义
|
||||
|
||||
## 敏感词和白名单
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.0.14-SNAPSHOT</version>
|
||||
<version>0.0.14</version>
|
||||
|
||||
<properties>
|
||||
<!--============================== All Plugins START ==============================-->
|
||||
@@ -25,7 +25,7 @@
|
||||
<project.compiler.level>1.7</project.compiler.level>
|
||||
|
||||
<!--============================== INTER ==============================-->
|
||||
<heaven.version>0.1.73</heaven.version>
|
||||
<heaven.version>0.1.129</heaven.version>
|
||||
<opencc4j.version>1.2.0</opencc4j.version>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
|
||||
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
|
||||
|
||||
:: 版本号信息(需要手动指定)
|
||||
:::: 旧版本名称
|
||||
SET version=0.0.13
|
||||
SET version=0.0.14
|
||||
:::: 新版本名称
|
||||
SET newVersion=0.0.14
|
||||
SET newVersion=0.0.15
|
||||
:::: 组织名称
|
||||
SET groupName=com.github.houbb
|
||||
:::: 项目名称
|
||||
|
||||
@@ -3,10 +3,11 @@ package com.github.houbb.sensitive.word.bs;
|
||||
import com.github.houbb.heaven.constant.CharConst;
|
||||
import com.github.houbb.heaven.util.common.ArgUtil;
|
||||
import com.github.houbb.heaven.util.util.CollectionUtil;
|
||||
import com.github.houbb.sensitive.word.api.*;
|
||||
import com.github.houbb.sensitive.word.exception.SensitiveWordException;
|
||||
import com.github.houbb.sensitive.word.api.IWordAllow;
|
||||
import com.github.houbb.sensitive.word.api.IWordContext;
|
||||
import com.github.houbb.sensitive.word.api.IWordDeny;
|
||||
import com.github.houbb.sensitive.word.api.IWordMap;
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.data.SensitiveWordData;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import com.github.houbb.sensitive.word.support.map.SensitiveWordMap;
|
||||
|
||||
@@ -156,6 +157,72 @@ public class SensitiveWordBs {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略大小写
|
||||
* @param ignoreCase 大小写
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreCase(boolean ignoreCase) {
|
||||
this.context.ignoreCase(ignoreCase);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略半角全角
|
||||
* @param ignoreWidth 半角全角
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreWidth(boolean ignoreWidth) {
|
||||
this.context.ignoreWidth(ignoreWidth);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略数字格式
|
||||
* @param ignoreNumStyle 数字格式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreNumStyle(boolean ignoreNumStyle) {
|
||||
this.context.ignoreNumStyle(ignoreNumStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略中文样式
|
||||
* @param ignoreChineseStyle 中文样式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreChineseStyle(boolean ignoreChineseStyle) {
|
||||
this.context.ignoreChineseStyle(ignoreChineseStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略英文样式
|
||||
* @param ignoreEnglishStyle 英文样式
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreEnglishStyle(boolean ignoreEnglishStyle) {
|
||||
this.context.ignoreEnglishStyle(ignoreEnglishStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否忽略重复
|
||||
* @param ignoreRepeat 忽略重复
|
||||
* @return this
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public SensitiveWordBs ignoreRepeat(boolean ignoreRepeat) {
|
||||
this.context.ignoreRepeat(ignoreRepeat);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建默认的上下文
|
||||
*
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.github.houbb.sensitive.word.bs;
|
||||
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* <p> project: sensitive-word-SensitiveWordBsConfigTest </p>
|
||||
* <p> create on 2020/1/7 23:43 </p>
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 0.0.14
|
||||
*/
|
||||
public class SensitiveWordBsConfigTest {
|
||||
|
||||
@Test
|
||||
public void configTest() {
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.ignoreCase(true)
|
||||
.ignoreWidth(true)
|
||||
.ignoreNumStyle(true)
|
||||
.ignoreChineseStyle(true)
|
||||
.ignoreEnglishStyle(true)
|
||||
.ignoreRepeat(true)
|
||||
.init();
|
||||
|
||||
final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
|
||||
Assert.assertTrue(wordBs.contains(text));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user