[Feature] add for new

This commit is contained in:
bbhou
2025-12-25 00:46:58 +08:00
parent 3a444e8034
commit 855659a864
7 changed files with 44 additions and 6 deletions

View File

@@ -482,4 +482,10 @@
| 序号 | 变更类型 | 说明 | 时间 | 备注 | | 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|----------------|:------------------|:--------| |:---|:-----|----------------|:------------------|:--------|
| 1 | O | opencc4j 简化繁简体 | 2025-9-6 16:22:24 | 优化性能+内存 | | 1 | O | opencc4j 简化繁简体 | 2025-9-6 16:22:24 | 优化性能+内存 |
# release_0.29.4
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|------------|:--------------------|:-----------|
| 1 | O | 默认改为英文全词匹配 | 2025-12-25 00:37:52 | 更加符合实际使用场景 |

View File

@@ -110,7 +110,7 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大
<dependency> <dependency>
<groupId>com.github.houbb</groupId> <groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId> <artifactId>sensitive-word</artifactId>
<version>0.29.2</version> <version>0.29.4</version>
</dependency> </dependency>
``` ```
@@ -767,6 +767,7 @@ WordResultConditions 工具类可以获取匹配策略
| 实现 | 说明 | 支持版本 | | 实现 | 说明 | 支持版本 |
|:-------------------------------------------|:--------------------|:--------| |:-------------------------------------------|:--------------------|:--------|
| defaults | 默认策略 | v0.29.4 |
| alwaysTrue | 恒为真 | | | alwaysTrue | 恒为真 | |
| englishWordMatch | 英文单词全词匹配 | v0.13.0 | | englishWordMatch | 英文单词全词匹配 | v0.13.0 |
| englishWordNumMatch | 英文单词/数字全词匹配 | v0.20.0 | | englishWordNumMatch | 英文单词/数字全词匹配 | v0.20.0 |

View File

@@ -6,7 +6,7 @@
<groupId>com.github.houbb</groupId> <groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId> <artifactId>sensitive-word</artifactId>
<version>0.29.3</version> <version>0.29.4</version>
<properties> <properties>
<!--============================== All Plugins START ==============================--> <!--============================== All Plugins START ==============================-->

View File

@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
:: 版本号信息(需要手动指定) :: 版本号信息(需要手动指定)
:::: 旧版本名称 :::: 旧版本名称
SET version=0.28.0 SET version=0.29.4
:::: 新版本名称 :::: 新版本名称
SET newVersion=0.29.0 SET newVersion=0.29.4
:::: 组织名称 :::: 组织名称
SET groupName=com.github.houbb SET groupName=com.github.houbb
:::: 项目名称 :::: 项目名称

View File

@@ -189,7 +189,7 @@ public class SensitiveWordBs implements ISensitiveWordDestroy {
* 敏感词结果匹配策略 * 敏感词结果匹配策略
* @since 0.13.0 * @since 0.13.0
*/ */
private IWordResultCondition wordResultCondition = WordResultConditions.alwaysTrue(); private IWordResultCondition wordResultCondition = WordResultConditions.defaults();
/** /**
* 单词检测策略 * 单词检测策略

View File

@@ -14,6 +14,15 @@ import java.util.List;
*/ */
public final class WordResultConditions { public final class WordResultConditions {
/**
* 默认策略
* @return 结果
* @since 0.29.4
*/
public static IWordResultCondition defaults() {
return englishWordMatch();
}
/** /**
* 恒为真 * 恒为真
* @return 结果 * @return 结果

View File

@@ -1,11 +1,15 @@
package com.github.houbb.sensitive.word.bs; package com.github.houbb.sensitive.word.bs;
import com.github.houbb.sensitive.word.api.IWordDeny;
import com.github.houbb.sensitive.word.support.allow.WordAllows; 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.deny.WordDenys;
import com.github.houbb.sensitive.word.support.replace.WordReplaces; import com.github.houbb.sensitive.word.support.replace.WordReplaces;
import com.github.houbb.sensitive.word.support.resultcondition.WordResultConditions;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@@ -114,4 +118,22 @@ public class SensitiveWordBsTest {
Assert.assertTrue(wordBs.contains(text)); Assert.assertTrue(wordBs.contains(text));
} }
/**
* 是否包含
* @since 0.29.4
*/
@Test
public void wordMatchTest() {
IWordDeny wordDeny = new IWordDeny() {
@Override
public List<String> deny() {
return Arrays.asList("av");
}
};
final String text = "have a nice day";
Assert.assertFalse(SensitiveWordBs.newInstance().wordDeny(wordDeny).init().contains(text));
Assert.assertTrue(SensitiveWordBs.newInstance().wordDeny(wordDeny).wordResultCondition(WordResultConditions.alwaysTrue()).init().contains(text));
}
} }