|
@@ -1,7 +1,7 @@
|
|
|
package cn.cslg.pas.service.patentRightSplit;
|
|
|
|
|
|
+import cn.cslg.pas.common.PatentRightContent;
|
|
|
import cn.cslg.pas.common.model.params.PatentRightParams;
|
|
|
-import cn.cslg.pas.domain.PatentRight;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -19,10 +19,10 @@ import java.util.regex.Pattern;
|
|
|
public class PatentRightSplitCNService implements PatentRightSplitService {
|
|
|
|
|
|
@Override
|
|
|
- public List<PatentRight> formatPatentRight(PatentRightParams params) {
|
|
|
+ public List<PatentRightContent> formatPatentRight(PatentRightParams params) {
|
|
|
try {
|
|
|
//创建一个权要集合,用于返回结果
|
|
|
- ArrayList<PatentRight> patentRights = new ArrayList<>();
|
|
|
+ ArrayList<PatentRightContent> patentRightContents = new ArrayList<>();
|
|
|
//原文
|
|
|
String content = params.getContent();
|
|
|
|
|
@@ -53,20 +53,19 @@ public class PatentRightSplitCNService implements PatentRightSplitService {
|
|
|
String[] strs = content.split("\n");
|
|
|
|
|
|
|
|
|
- //第2步:理出每个权要的类型(type为 1主权要还是 0附属权要)、理出权要之间的层级关系(每个权要的父级权要序号parentSort) ↓
|
|
|
+ //第2步:理出权要的类型(type为 1主权要还是 0附属权要)、权要之间的层级关系(每个权要的父级权要序号parentSort) ↓
|
|
|
String regex1 = "权利要求[0-9]+";
|
|
|
String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
|
|
|
for (int i = 0; i < strs.length; i++) {
|
|
|
//创建权要对象装载当前权要
|
|
|
- PatentRight patentRight = new PatentRight()
|
|
|
- .setPatentId(params.getPatentId())
|
|
|
+ PatentRightContent patentRightContent = new PatentRightContent()
|
|
|
.setContent(strs[i])
|
|
|
.setSort(i);
|
|
|
|
|
|
//判断若该权要有逗号(即超过一句话)并且它第一句话中有"权利要求"4个字 或者 该权要没有逗号(即只有一句话),并且它有"权利要求"4个字,则该权要类型为附属权要
|
|
|
if ((strs[i].contains(",") && strs[i].substring(0, strs[i].indexOf(",")).contains("权利要求")) || (!strs[i].contains(",") && strs[i].contains("权利要求"))) {
|
|
|
- //则该权要类型为附属权要
|
|
|
- patentRight.setType(0);
|
|
|
+ //则该权要为附权要
|
|
|
+ patentRightContent.setType(0);
|
|
|
|
|
|
Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
|
|
|
Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
|
|
@@ -83,49 +82,46 @@ public class PatentRightSplitCNService implements PatentRightSplitService {
|
|
|
parentNumStrs = parentNum.split("或");
|
|
|
}
|
|
|
|
|
|
- int[] parentSorts = new int[parentNumStrs.length]; //[1, 3]
|
|
|
- for (int i1 = 0; i1 < parentSorts.length; i1++) {
|
|
|
- parentSorts[i1] = Integer.parseInt(parentNumStrs[i1]) - 1;
|
|
|
+ ArrayList<Integer> parentSorts = new ArrayList<>(); //{1, 3}
|
|
|
+ for (int i1 = 0; i1 < parentNumStrs.length; i1++) {
|
|
|
+ parentSorts.add(Integer.parseInt(parentNumStrs[i1]) - 1); //{1, 3}
|
|
|
}
|
|
|
|
|
|
if (parentNum.contains("或")) {
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- for (int parentSort : parentSorts) {
|
|
|
- builder.append(parentSort).append(",");
|
|
|
- }
|
|
|
- patentRight.setParentSort(builder.substring(0, builder.lastIndexOf(",")));
|
|
|
+ patentRightContent.setParentSorts(parentSorts);
|
|
|
} else {
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- for (int j = parentSorts[0]; j <= parentSorts[parentSorts.length - 1]; j++) {
|
|
|
- if ((builder + "").equals("")) {
|
|
|
- builder.append(j);
|
|
|
- } else {
|
|
|
- builder.append(",").append(j);
|
|
|
- }
|
|
|
+ ArrayList<Integer> parentSorts2 = new ArrayList<>();
|
|
|
+ for (int i1 = parentSorts.get(0); i1 < parentSorts.get(parentSorts.size() - 1); i1++) {
|
|
|
+ parentSorts2.add(i1);
|
|
|
}
|
|
|
- patentRight.setParentSort(builder + "");
|
|
|
+ patentRightContent.setParentSorts(parentSorts2);
|
|
|
}
|
|
|
|
|
|
} else if (matcher1.find()) {
|
|
|
String parentNum = matcher1.group().substring(matcher1.group().indexOf("权利要求") + 4);
|
|
|
- patentRight.setParentSort((Integer.parseInt(parentNum) - 1) + "");
|
|
|
+ int parentSort = Integer.parseInt(parentNum) - 1;
|
|
|
+ ArrayList<Integer> parentSorts = new ArrayList<>();
|
|
|
+ parentSorts.add(parentSort);
|
|
|
+ patentRightContent.setParentSorts(parentSorts);
|
|
|
}
|
|
|
} else {
|
|
|
//否则该权要为主权要
|
|
|
- patentRight
|
|
|
+ ArrayList<Integer> parentSorts = new ArrayList<>();
|
|
|
+ parentSorts.add(-1);
|
|
|
+ patentRightContent
|
|
|
.setType(1)
|
|
|
- .setParentSort("-1");
|
|
|
+ .setParentSorts(parentSorts);
|
|
|
}
|
|
|
|
|
|
- patentRights.add(patentRight);
|
|
|
+ patentRightContents.add(patentRightContent);
|
|
|
}
|
|
|
|
|
|
- return patentRights;
|
|
|
+ return patentRightContents;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- ArrayList<PatentRight> patentRights = new ArrayList<>();
|
|
|
- patentRights.add(new PatentRight().setContent(params.getContent()));
|
|
|
- return patentRights;
|
|
|
+ ArrayList<PatentRightContent> patentRightContents = new ArrayList<>();
|
|
|
+ patentRightContents.add(new PatentRightContent().setContent(params.getContent()));
|
|
|
+ return patentRightContents;
|
|
|
}
|
|
|
|
|
|
}
|