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