diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md index aac44f1..38bb3e0 100644 --- a/CHANGE_LOG.md +++ b/CHANGE_LOG.md @@ -444,3 +444,9 @@ |:---|:-----|------------------------|:-------------------|:---------------------------------------------------| | 1 | D | 移除火车 | 2025-7-19 15:58:55 | https://github.com/houbb/sensitive-word/issues/124 | | 1 | A | 将词库外置为另外一下独立的项目,可以单独排除 | 2025-7-19 15:58:55 | | + +# release_0.27.1 + +| 序号 | 变更类型 | 说明 | 时间 | 备注 | +|:---|:-----|-----------|:-------------------|:---------------------------------------------------| +| 1 | F | 修正词库缺失的问题 | 2025-7-24 23:09:10 | https://github.com/houbb/sensitive-word/issues/125 | diff --git a/README.md b/README.md index 60fb955..97a297b 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大 com.github.houbb sensitive-word - 0.27.0 + 0.27.1 ``` diff --git a/pom.xml b/pom.xml index 0e35857..e975135 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.houbb sensitive-word - 0.27.0 + 0.27.1 diff --git a/release.bat b/release.bat index 90d5a99..7aa8332 100644 --- a/release.bat +++ b/release.bat @@ -10,7 +10,7 @@ ECHO "============================= RELEASE START..." :: 版本号信息(需要手动指定) :::: 旧版本名称 -SET version=0.27.0 +SET version=0.27.1 :::: 新版本名称 SET newVersion=0.28.0 :::: 组织名称 diff --git a/src/main/java/com/github/houbb/sensitive/word/support/allow/WordAllowSystem.java b/src/main/java/com/github/houbb/sensitive/word/support/allow/WordAllowSystem.java index c596776..23d9500 100644 --- a/src/main/java/com/github/houbb/sensitive/word/support/allow/WordAllowSystem.java +++ b/src/main/java/com/github/houbb/sensitive/word/support/allow/WordAllowSystem.java @@ -1,9 +1,8 @@ package com.github.houbb.sensitive.word.support.allow; import com.github.houbb.heaven.annotation.ThreadSafe; -import com.github.houbb.heaven.util.io.StreamUtil; import com.github.houbb.sensitive.word.api.IWordAllow; -import com.github.houbb.sensitive.word.api.IWordDeny; +import com.github.houbb.sensitive.word.utils.InnerStreamUtils; import java.util.List; @@ -26,7 +25,7 @@ public class WordAllowSystem implements IWordAllow { @Override public List allow() { - return StreamUtil.readAllLines("/sensitive_word_allow.txt"); + return InnerStreamUtils.readAllLines("/sensitive_word_allow.txt"); } } diff --git a/src/main/java/com/github/houbb/sensitive/word/support/deny/WordDenySystem.java b/src/main/java/com/github/houbb/sensitive/word/support/deny/WordDenySystem.java index 81e6286..4102ec7 100644 --- a/src/main/java/com/github/houbb/sensitive/word/support/deny/WordDenySystem.java +++ b/src/main/java/com/github/houbb/sensitive/word/support/deny/WordDenySystem.java @@ -1,8 +1,8 @@ package com.github.houbb.sensitive.word.support.deny; import com.github.houbb.heaven.annotation.ThreadSafe; -import com.github.houbb.heaven.util.io.StreamUtil; import com.github.houbb.sensitive.word.api.IWordDeny; +import com.github.houbb.sensitive.word.utils.InnerStreamUtils; import java.util.List; @@ -25,9 +25,9 @@ public class WordDenySystem implements IWordDeny { @Override public List deny() { - List results = StreamUtil.readAllLines("/sensitive_word_dict.txt"); - results.addAll(StreamUtil.readAllLines("/sensitive_word_dict_en.txt")); - results.addAll(StreamUtil.readAllLines("/sensitive_word_deny.txt")); + List results = InnerStreamUtils.readAllLines("/sensitive_word_dict.txt"); + results.addAll(InnerStreamUtils.readAllLines("/sensitive_word_dict_en.txt")); + results.addAll(InnerStreamUtils.readAllLines("/sensitive_word_deny.txt")); return results; } diff --git a/src/main/java/com/github/houbb/sensitive/word/support/tag/WordTagSystem.java b/src/main/java/com/github/houbb/sensitive/word/support/tag/WordTagSystem.java index a0f7af3..d4eb963 100644 --- a/src/main/java/com/github/houbb/sensitive/word/support/tag/WordTagSystem.java +++ b/src/main/java/com/github/houbb/sensitive/word/support/tag/WordTagSystem.java @@ -1,7 +1,7 @@ package com.github.houbb.sensitive.word.support.tag; -import com.github.houbb.heaven.util.io.StreamUtil; import com.github.houbb.sensitive.word.api.IWordTag; +import com.github.houbb.sensitive.word.utils.InnerStreamUtils; import java.util.List; import java.util.Set; @@ -16,7 +16,7 @@ public class WordTagSystem extends AbstractWordTag { private final IWordTag wordTag; public WordTagSystem() { - List lines = StreamUtil.readAllLines("/sensitive_word_tags.txt"); + List lines = InnerStreamUtils.readAllLines("/sensitive_word_tags.txt"); this.wordTag = WordTags.lines(lines); } diff --git a/src/main/java/com/github/houbb/sensitive/word/utils/InnerStreamUtils.java b/src/main/java/com/github/houbb/sensitive/word/utils/InnerStreamUtils.java new file mode 100644 index 0000000..4ee52d9 --- /dev/null +++ b/src/main/java/com/github/houbb/sensitive/word/utils/InnerStreamUtils.java @@ -0,0 +1,33 @@ +package com.github.houbb.sensitive.word.utils; + +import com.github.houbb.heaven.util.io.StreamUtil; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.List; + +/** + * @since 0.27.1 + */ +public class InnerStreamUtils { + + /** + * 获取文件,兼容为空的场景 + * @param path 路径 + * @return 结果 + */ + public static List readAllLines(String path) { + try(InputStream inputStream = StreamUtil.class.getResourceAsStream(path);) { + if(inputStream == null) { + return Collections.emptyList(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + + return StreamUtil.readAllLines(path); + } + +} +