Browse Source

拆分权要工具类改代码,特殊符号由@升级为$%&@

chendayu 2 years ago
parent
commit
57d3d7fd95
1 changed files with 25 additions and 26 deletions
  1. 25 26
      PAS/src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

+ 25 - 26
PAS/src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

@@ -16,7 +16,6 @@ import java.util.regex.Pattern;
  * @Author chenyu
  * @Author chenyu
  * @Date 2023/4/25
  * @Date 2023/4/25
  */
  */
-@Component
 public class PatentRightUtils {
 public class PatentRightUtils {
 
 
     public static List<PatentRight> formatPatentRight(PatentRightParams params) {
     public static List<PatentRight> formatPatentRight(PatentRightParams params) {
@@ -40,19 +39,19 @@ public class PatentRightUtils {
                 contentOut = "";
                 contentOut = "";
             }
             }
 
 
-            //将原文和译文的所有换行符 "\r\n"或是"\n" 替换成 "@",这样首先可以使得全文连在一起,其次再根据特殊符号@拆分权要
+            //将原文和译文的所有换行符 "\r\n"或是"\n" 替换成 "$#&@",这样首先可以使得全文连在一起,其次再根据特殊符号$#&@拆分权要
             if (content.contains("\r\n")) {
             if (content.contains("\r\n")) {
-                content = content.replaceAll("\r\n", "@");
+                content = content.replaceAll("\r\n", "$#&@");
             }
             }
             if (content.contains("\n")) {
             if (content.contains("\n")) {
-                content = content.replaceAll("\n", "@");
+                content = content.replaceAll("\n", "$#&@");
             }
             }
 
 
             if (contentOut.contains("\r\n")) {
             if (contentOut.contains("\r\n")) {
-                contentOut = contentOut.replaceAll("\r\n", "@");
+                contentOut = contentOut.replaceAll("\r\n", "$#&@");
             }
             }
             if (contentOut.contains("\n")) {
             if (contentOut.contains("\n")) {
-                contentOut = contentOut.replaceAll("\n", "@");
+                contentOut = contentOut.replaceAll("\n", "$#&@");
             }
             }
 
 
             //去掉译文的所有空格
             //去掉译文的所有空格
@@ -61,14 +60,14 @@ public class PatentRightUtils {
             //中日韩权要↓
             //中日韩权要↓
             if (country.equals("CN") || country.equals("JP") || country.equals("KR") || content.contains("权利要求")) {
             if (country.equals("CN") || country.equals("JP") || country.equals("KR") || content.contains("权利要求")) {
                 String regex;
                 String regex;
-                if (content.contains("@2")) {
-                    regex = "@[0-9]+";
-                } else if (content.contains("@[00")) {
-                    regex = "@\\[[0-9]+]";
-                } else if (content.contains("@請求項")) {
-                    regex = "@【請求項[0-9]+】";
-                } else if (content.contains("@청구항")) {
-                    regex = "@청구항 [0-9]+";
+                if (content.contains("$#&@2")) {
+                    regex = "\\$#&@[0-9]+";
+                } else if (content.contains("$#&@[00")) {
+                    regex = "\\$#&@\\[[0-9]+]";
+                } else if (content.contains("$#&@請求項")) {
+                    regex = "\\$#&@【請求項[0-9]+】";
+                } else if (content.contains("$#&@청구항")) {
+                    regex = "\\$#&@청구항 [0-9]+";
                 } else {
                 } else {
                     regex = "";
                     regex = "";
                 }
                 }
@@ -76,8 +75,8 @@ public class PatentRightUtils {
                 String[] strsOut;  //译文数组
                 String[] strsOut;  //译文数组
                 //若以上没有匹配到,则权要直接以句号 "。" 拆分
                 //若以上没有匹配到,则权要直接以句号 "。" 拆分
                 if (regex.equals("")) {
                 if (regex.equals("")) {
-                    content = content.replaceAll("@", "");
-                    contentOut = contentOut.replaceAll("@", "");
+                    content = content.replaceAll("\\$#&@", "");
+                    contentOut = contentOut.replaceAll("\\$#&@", "");
                     strs = content.split("。");
                     strs = content.split("。");
                     strsOut = contentOut.split("。");
                     strsOut = contentOut.split("。");
                     //若匹配到,则根据不同情形拆分
                     //若匹配到,则根据不同情形拆分
@@ -85,13 +84,13 @@ public class PatentRightUtils {
                     Matcher matcher = Pattern.compile(regex).matcher(content);
                     Matcher matcher = Pattern.compile(regex).matcher(content);
                     Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
                     Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
                     while (matcher.find()) {
                     while (matcher.find()) {
-                        content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("@") + 1));
+                        content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("$#&@") + 1));
                     }
                     }
                     while (matcherOut.find()) {
                     while (matcherOut.find()) {
-                        contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("@") + 1));
+                        contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("$#&@") + 1));
                     }
                     }
-                    content = content.replaceAll("@", "");
-                    contentOut = contentOut.replaceAll("@", "");
+                    content = content.replaceAll("\\$#&@", "");
+                    contentOut = contentOut.replaceAll("\\$#&@", "");
                     strs = content.split("\n");
                     strs = content.split("\n");
                     strsOut = contentOut.split("\n");
                     strsOut = contentOut.split("\n");
                 }
                 }
@@ -183,8 +182,8 @@ public class PatentRightUtils {
                 }
                 }
 
 
                 String regex;
                 String regex;
-                if (content.contains("@2")) {
-                    regex = "@[0-9]+";
+                if (content.contains("$#&@2")) {
+                    regex = "\\$#&@[0-9]+";
                 } else if (content.contains("[001]")) {
                 } else if (content.contains("[001]")) {
                     regex = "\\[[0-9]+]";
                     regex = "\\[[0-9]+]";
                 } else {
                 } else {
@@ -194,13 +193,13 @@ public class PatentRightUtils {
                 Matcher matcher = Pattern.compile(regex).matcher(content);
                 Matcher matcher = Pattern.compile(regex).matcher(content);
                 Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
                 Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
                 while (matcher.find()) {
                 while (matcher.find()) {
-                    content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("@") + 1));
+                    content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("$#&@") + 1));
                 }
                 }
                 while (matcherOut.find()) {
                 while (matcherOut.find()) {
-                    contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("@") + 1));
+                    contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("$#&@") + 1));
                 }
                 }
-                content = content.replaceAll("@", "");
-                contentOut = contentOut.replaceAll("@", "");
+                content = content.replaceAll("\\$#&@", "");
+                contentOut = contentOut.replaceAll("\\$#&@", "");
                 String[] strs = content.split("\n");
                 String[] strs = content.split("\n");
                 String[] strsOut = contentOut.split("\n");
                 String[] strsOut = contentOut.split("\n");