|
@@ -5,6 +5,7 @@ import cn.cslg.pas.domain.PatentRight;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -78,7 +79,8 @@ public class PatentRightUtils {
|
|
|
strs = content.split("。");
|
|
|
strsOut = contentOut.split("。");
|
|
|
//若匹配到,则根据不同情形拆分
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
Matcher matcher = Pattern.compile(regex).matcher(content);
|
|
|
Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
|
|
|
while (matcher.find()) {
|
|
@@ -87,13 +89,11 @@ public class PatentRightUtils {
|
|
|
while (matcherOut.find()) {
|
|
|
contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("@") + 1));
|
|
|
}
|
|
|
-
|
|
|
content = content.replaceAll("@", "");
|
|
|
contentOut = contentOut.replaceAll("@", "");
|
|
|
strs = content.split("\n");
|
|
|
strsOut = contentOut.split("\n");
|
|
|
}
|
|
|
-
|
|
|
//定义父权要排序号
|
|
|
String regex1 = "权利要求[0-9]+";
|
|
|
String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
|
|
@@ -132,7 +132,13 @@ public class PatentRightUtils {
|
|
|
.setSort(i)
|
|
|
.setParentSort(builder + "");
|
|
|
if (strsOut.length - 1 >= i) {
|
|
|
- patentRight.setContentOut(strsOut[i]);
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ patentRight.setContentOut(strsOut[i]);
|
|
|
+ }
|
|
|
}
|
|
|
patentRights.add(patentRight);
|
|
|
} else if (matcher1.find()) {
|
|
@@ -157,12 +163,17 @@ public class PatentRightUtils {
|
|
|
.setSort(i)
|
|
|
.setParentSort("-1");
|
|
|
if (strsOut.length - 1 >= i) {
|
|
|
- patentRight.setContentOut(strsOut[i]);
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ patentRight.setContentOut(strsOut[i]);
|
|
|
+ }
|
|
|
}
|
|
|
patentRights.add(patentRight);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//英文专利的权要拆分 ↓
|
|
|
} else {
|
|
|
if (!content.equals("") && content.contains("1")) {
|
|
@@ -189,7 +200,6 @@ public class PatentRightUtils {
|
|
|
while (matcherOut.find()) {
|
|
|
contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("@") + 1));
|
|
|
}
|
|
|
-
|
|
|
content = content.replaceAll("@", "");
|
|
|
contentOut = contentOut.replaceAll("@", "");
|
|
|
String[] strs = content.split("\n");
|
|
@@ -233,7 +243,13 @@ public class PatentRightUtils {
|
|
|
.setSort(i)
|
|
|
.setParentSort(builder + "");
|
|
|
if (strsOut.length - 1 >= i) {
|
|
|
- patentRight.setContentOut(strsOut[i]);
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ patentRight.setContentOut(strsOut[i]);
|
|
|
+ }
|
|
|
}
|
|
|
patentRights.add(patentRight);
|
|
|
} else if (matcher1.find()) {
|
|
@@ -244,7 +260,11 @@ public class PatentRightUtils {
|
|
|
.setContent(strs[i])
|
|
|
.setSort(i)
|
|
|
.setParentSort((Integer.parseInt(parentNum) - 1) + "");
|
|
|
- if (strsOut.length - 1 >= i) {
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
patentRight.setContentOut(strsOut[i]);
|
|
|
}
|
|
|
patentRights.add(patentRight);
|
|
@@ -262,7 +282,11 @@ public class PatentRightUtils {
|
|
|
.setContent(strs[i])
|
|
|
.setSort(i)
|
|
|
.setParentSort(builder.substring(0, builder.lastIndexOf(",")));
|
|
|
- if (strsOut.length - 1 >= i) {
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
patentRight.setContentOut(strsOut[i]);
|
|
|
}
|
|
|
patentRights.add(patentRight);
|
|
@@ -275,7 +299,11 @@ public class PatentRightUtils {
|
|
|
.setContent(strs[i])
|
|
|
.setSort(i)
|
|
|
.setParentSort("-1");
|
|
|
- if (strsOut.length - 1 >= i) {
|
|
|
+ //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
|
|
|
+ if(strsOut.length>strs.length&&strs.length==(i+1)){
|
|
|
+ patentRight.setContentOut(String.join(" ",Arrays.copyOfRange(strsOut,i,strsOut.length)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
patentRight.setContentOut(strsOut[i]);
|
|
|
}
|
|
|
patentRights.add(patentRight);
|