Commit 54d41e3e authored by 刘基明's avatar 刘基明

文本查重

parent e4b5c37d
...@@ -20,10 +20,12 @@ public class ThemeTextCheckService { ...@@ -20,10 +20,12 @@ public class ThemeTextCheckService {
@Resource @Resource
private ThemeCheckDuplicateMapper themeCheckDuplicateMapper; private ThemeCheckDuplicateMapper themeCheckDuplicateMapper;
private final String regex = "[,。!?;;, ]";
public void insert(String content, String themeId, String userId,Integer themeType) { public void insert(String content, String themeId, String userId,Integer themeType) {
themeCheckDuplicateMapper.deleteByThemeId(themeId); themeCheckDuplicateMapper.deleteByThemeId(themeId);
content = content.replaceAll("[,。!? ]", "。"); content = content.replaceAll(regex, "。");
String[] split = content.split("。"); String[] split = content.split("。");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
getMD5(split[i]); getMD5(split[i]);
...@@ -52,7 +54,7 @@ public class ThemeTextCheckService { ...@@ -52,7 +54,7 @@ public class ThemeTextCheckService {
if (content.length()<15){ if (content.length()<15){
return false; return false;
} }
content = content.replaceAll("[,。!? ]", "。"); content = content.replaceAll(regex, "。");
String[] split = content.split("。"); String[] split = content.split("。");
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
...@@ -86,7 +88,8 @@ public class ThemeTextCheckService { ...@@ -86,7 +88,8 @@ public class ThemeTextCheckService {
public void insertInit(String content, String themeId,String userId, LocalDateTime createTime) { public void insertInit(String content, String themeId,String userId, LocalDateTime createTime) {
themeCheckDuplicateMapper.deleteByThemeId(themeId); themeCheckDuplicateMapper.deleteByThemeId(themeId);
content = content.replaceAll("[,。!? ]", "。");
content = content.replaceAll(regex, "。");
String[] split = content.split("。"); String[] split = content.split("。");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
getMD5(split[i]); getMD5(split[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment