mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
release branch 0.27.0
This commit is contained in:
@@ -437,3 +437,10 @@
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:-----|------------------|:------------------|:---------------------------------------------------|
|
||||
| 1 | F | 修正数字等默认策略,忽略字符问题 | 2025-7-5 15:58:55 | https://github.com/houbb/sensitive-word/issues/120 |
|
||||
|
||||
# release_0.27.0
|
||||
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:-----|------------------------|:-------------------|:---------------------------------------------------|
|
||||
| 1 | D | 移除火车 | 2025-7-19 15:58:55 | https://github.com/houbb/sensitive-word/issues/124 |
|
||||
| 1 | A | 将词库外置为另外一下独立的项目,可以单独排除 | 2025-7-19 15:58:55 | |
|
||||
|
||||
69
README.md
69
README.md
@@ -110,7 +110,7 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.26.2</version>
|
||||
<version>0.27.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -1216,6 +1216,73 @@ Assert.assertEquals("[我的自定义敏感词]", wordBs.findAll(text).toString(
|
||||
|
||||
注意:**我们初始化了新的 wordBs,那么用新的 wordBs 去判断。而不是用以前的 `SensitiveWordHelper` 工具方法,工具方法配置是默认的!**
|
||||
|
||||
|
||||
# 系统内置词库及如何排除
|
||||
|
||||
## 内置词库文件说明
|
||||
|
||||
v0.27.0 将词库和当前项目拆分开,词库可以在 [https://github.com/houbb/sensitive-word-data](https://github.com/houbb/sensitive-word-data) 项目查看。
|
||||
|
||||
对应的资源文件在 [https://github.com/houbb/sensitive-word-data/tree/main/src/main/resources](https://github.com/houbb/sensitive-word-data/tree/main/src/main/resources) 目录下
|
||||
|
||||
| 文件 | 说明 | 默认加载类
|
||||
|:-----------------------------|:-----------|:-------------------|
|
||||
| `sensitive_word_allow.txt` | 内置自定义白名单词库 | `WordAllowSystem` |
|
||||
| `sensitive_word_deny.txt` | 内置自定义黑名单词库 | `WordDenySystem` |
|
||||
| `sensitive_word_dict.txt` | 内置黑名单词库 | `WordDenySystem` |
|
||||
| `sensitive_word_dict_en.txt` | 内置黑名单英文词库 | `WordDenySystem` |
|
||||
| `sensitive_word_tags.txt` | 内置敏感词标签词库 | `WordTagSystem` |
|
||||
|
||||
## 如何排除
|
||||
|
||||
比如一些 android app 引入时不希望包中内置敏感的信息,希望对词库加解密或者是放在服务端初始化加载。
|
||||
|
||||
系统的内置词库通过下面的 maven 依赖导入
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word-data</artifactId>
|
||||
<version>${sensitive-word-data.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 依赖排除
|
||||
|
||||
所以可以按照 maven 排除规范,如下将其排除
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>${sensitive-word.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word-data</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 排除后自定义
|
||||
|
||||
不希望使用内置词库,那就需要将原来内置的词库依赖改为自己的依赖
|
||||
|
||||
默认配置项:
|
||||
|
||||
```java
|
||||
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
|
||||
.wordAllow(WordAllows.defaults())
|
||||
.wordDeny(WordDenys.defaults())
|
||||
.wordTag(WordTags.defaults())
|
||||
.init();
|
||||
```
|
||||
|
||||
你可以将用到的这3个类,改为自己的实现。
|
||||
|
||||
可以通过加解密,或者加载远程服务的文件信息都可以。
|
||||
|
||||
# spring 整合
|
||||
|
||||
## 背景
|
||||
|
||||
14
pom.xml
14
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.26.2</version>
|
||||
<version>0.27.0</version>
|
||||
|
||||
<properties>
|
||||
<!--============================== All Plugins START ==============================-->
|
||||
@@ -27,6 +27,7 @@
|
||||
<!--============================== INTER ==============================-->
|
||||
<heaven.version>0.13.0</heaven.version>
|
||||
<opencc4j.version>1.8.1</opencc4j.version>
|
||||
<sensitive-word-data.version>1.0.0</sensitive-word-data.version>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
<junit.version>4.13.1</junit.version>
|
||||
@@ -58,6 +59,12 @@
|
||||
<artifactId>heaven</artifactId>
|
||||
<version>${heaven.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word-data</artifactId>
|
||||
<version>${sensitive-word-data.version}</version>
|
||||
</dependency>
|
||||
<!--============================== OTHER ==============================-->
|
||||
|
||||
<dependency>
|
||||
@@ -93,6 +100,11 @@
|
||||
<artifactId>opencc4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word-data</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
|
||||
|
||||
:: 版本号信息(需要手动指定)
|
||||
:::: 旧版本名称
|
||||
SET version=0.26.2
|
||||
SET version=0.27.0
|
||||
:::: 新版本名称
|
||||
SET newVersion=0.27.0
|
||||
SET newVersion=0.28.0
|
||||
:::: 组织名称
|
||||
SET groupName=com.github.houbb
|
||||
:::: 项目名称
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
生日快乐
|
||||
曹操
|
||||
幸运
|
||||
幸运儿
|
||||
17年前
|
||||
1条
|
||||
1梯两户
|
||||
1比1
|
||||
年检
|
||||
幸存
|
||||
恶搞
|
||||
游戏机
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
fuck
|
||||
duck
|
||||
shit
|
||||
chicken
|
||||
fowl
|
||||
sex
|
||||
sexy
|
||||
prostitute
|
||||
whore
|
||||
harlot
|
||||
hooker
|
||||
gender
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
package com.github.houbb.sensitive.word.bs;
|
||||
|
||||
import com.github.houbb.sensitive.word.api.IWordAllow;
|
||||
import com.github.houbb.sensitive.word.api.IWordDeny;
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import com.github.houbb.sensitive.word.support.tag.WordTags;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> project: sensitive-word-SensitiveWordBsTest </p>
|
||||
* <p> create on 2020/1/7 23:43 </p>
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 0.27.0
|
||||
*/
|
||||
public class SensitiveWordBsSystemDictTest {
|
||||
|
||||
@Test
|
||||
public void configTest() {
|
||||
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
|
||||
.wordAllow(WordAllows.defaults())
|
||||
.wordDeny(WordDenys.defaults())
|
||||
.wordTag(WordTags.defaults())
|
||||
.init();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user