|
@@ -1,6 +1,7 @@
|
|
|
package com.pavis.backend.slim.project.system.controller;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.pavis.backend.slim.common.utils.CommonUtils;
|
|
|
import com.pavis.backend.slim.framework.web.domain.AjaxResult;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntity;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntityRelation;
|
|
@@ -72,7 +73,7 @@ public class AnnotationController {
|
|
|
if (null != annotationListParam.getKgId() && StringUtils.isNotEmpty(annotationListParam.getKgId()) && null != annotationListParam.getPageNum() && null != annotationListParam.getPageSize()) {
|
|
|
return AjaxResult.success("获取数据标注列表成功", annotationListService.getAnnotationLists(annotationListParam));
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除标注数据列表接口")
|
|
@@ -87,7 +88,7 @@ public class AnnotationController {
|
|
|
return AjaxResult.error("删除标注数据列表失败", delRes);
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("数据集导入之知识库文档导入接口")
|
|
@@ -102,7 +103,7 @@ public class AnnotationController {
|
|
|
return AjaxResult.error("数据集导入失败", saveRes);
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("数据集导入之本地文件导入接口")
|
|
@@ -111,14 +112,14 @@ public class AnnotationController {
|
|
|
})
|
|
|
@PostMapping(value = "/importLocalAnnotationDataset")
|
|
|
public AjaxResult importLocalAnnotationDataset(String kgId, @RequestParam("file") MultipartFile file) throws Exception {
|
|
|
- if (null != kgId && StringUtils.isNotEmpty(kgId)){
|
|
|
- if (!file.isEmpty()){
|
|
|
- return AjaxResult.success("数据集导入之本地文件导入成功!", annotationListService.importLocalAnnotationDataset(kgId,file));
|
|
|
- }else {
|
|
|
+ if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ return AjaxResult.success("数据集导入之本地文件导入成功!", annotationListService.importLocalAnnotationDataset(kgId, file));
|
|
|
+ } else {
|
|
|
return AjaxResult.error("文件不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -153,6 +154,7 @@ public class AnnotationController {
|
|
|
/**
|
|
|
* 文档标注实体数据删除接口,传主键ID。
|
|
|
* 文档标注实体间关系数据删除接口,传主键ID。
|
|
|
+ *
|
|
|
* @param delAnnotation
|
|
|
* @return
|
|
|
*/
|
|
@@ -169,7 +171,7 @@ public class AnnotationController {
|
|
|
if (null != annotationFront.getKgId() && null != annotationFront.getFileId() && StringUtils.isNotEmpty(annotationFront.getKgId()) && StringUtils.isNotEmpty(annotationFront.getFileId())) {
|
|
|
return AjaxResult.success("文档标注最终实体数据保存成功", annotationListService.saveAnnotation(annotationFront));
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -205,7 +207,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("算法通知后端更新生成图谱结果接口")
|
|
|
@PostMapping("/generateKgGraphResult")
|
|
|
public AjaxResult generateKgGraphResult(@RequestBody GenerateGraphResult genGraphResult) {
|
|
|
- log.info("算法通知后端更新生成图谱结果genGraphResult:{}",JSON.toJSONString(genGraphResult));
|
|
|
+ log.info("算法通知后端更新生成图谱结果genGraphResult:{}", JSON.toJSONString(genGraphResult));
|
|
|
if (null != genGraphResult.getTaskId() && StringUtils.isNotEmpty(genGraphResult.getTaskId())) {
|
|
|
log.info("---> taskId:{}", genGraphResult.getTaskId());
|
|
|
generateGraphService.generateKgGraphResult(genGraphResult);
|
|
@@ -222,7 +224,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("标注数据导出")
|
|
|
@ResponseBody
|
|
|
public void exportDatabase(@RequestBody ExportAnnotationData exportAnnotationData, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- log.info("export annotationToAlg param--->:{}",JSON.toJSONString(exportAnnotationData));
|
|
|
+ log.info("export annotationToAlg param--->:{}", JSON.toJSONString(exportAnnotationData));
|
|
|
entityLablesRelationService.exportDataBase(exportAnnotationData, request, response);
|
|
|
}
|
|
|
|
|
@@ -233,19 +235,20 @@ public class AnnotationController {
|
|
|
@ApiOperation("标注数据导导入")
|
|
|
@ResponseBody
|
|
|
public AjaxResult importDatabase(String kgId, @RequestParam("file") MultipartFile file) throws IOException {
|
|
|
- log.info("import annotationToAlg param--->kgId:{},fileName:{}",JSON.toJSONString(kgId),file.getOriginalFilename());
|
|
|
- if (null != kgId && StringUtils.isNotEmpty(kgId)){
|
|
|
- if (!file.isEmpty()){
|
|
|
- return AjaxResult.success("标注数据导入成功!", entityLablesRelationService.importDataBase(kgId,file));
|
|
|
- }else {
|
|
|
+ log.info("import annotationToAlg param--->kgId:{},fileName:{}", JSON.toJSONString(kgId), file.getOriginalFilename());
|
|
|
+ if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ return AjaxResult.success("标注数据导入成功!", entityLablesRelationService.importDataBase(kgId, file));
|
|
|
+ } else {
|
|
|
return AjaxResult.error("文件不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 停止生成图谱。
|
|
|
+
|
|
|
/**
|
|
|
* 前端传入知识库id,后端调用算法停止生成图谱。
|
|
|
* 后端请求算法--->入参taskId。
|
|
@@ -266,7 +269,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("算法通知后端更新文本内容接口")
|
|
|
@PostMapping("/toUpText")
|
|
|
public AjaxResult toUpText(@RequestBody ConvertAlgRes convertAlgRes) {
|
|
|
- log.info("算法通知后端更新文本内容 convertAlgRes:{}",JSON.toJSONString(convertAlgRes));
|
|
|
+ log.info("算法通知后端更新文本内容 convertAlgRes:{}", JSON.toJSONString(convertAlgRes));
|
|
|
if (null != convertAlgRes && null != convertAlgRes.getFileId() && null != convertAlgRes.getErrorCode()) {
|
|
|
log.info("---> fileId:{}", convertAlgRes.getFileId());
|
|
|
entityLablesRelationService.toUpText(convertAlgRes);
|
|
@@ -277,14 +280,54 @@ public class AnnotationController {
|
|
|
|
|
|
@ApiOperation("用户手动解析txt文本内容接口")
|
|
|
@GetMapping("/handsToParseTxt")
|
|
|
- public AjaxResult handsToParseTxt(@RequestParam("kgId") String kgId,@RequestParam("fileId") String fileId) {
|
|
|
- log.info("用户手动解析txt文本内容 kgId:{},fileId:{}",kgId,fileId);
|
|
|
+ public AjaxResult handsToParseTxt(@RequestParam("kgId") String kgId, @RequestParam("fileId") String fileId) {
|
|
|
+ log.info("用户手动解析txt文本内容 kgId:{},fileId:{}", kgId, fileId);
|
|
|
if (null != kgId && StringUtils.isNotEmpty(kgId) && null != fileId && StringUtils.isNotEmpty(fileId)) {
|
|
|
- return AjaxResult.success("算法通知后端更新文本内容成功",sysFileService.handsToParseTxt(kgId,fileId));
|
|
|
+ return AjaxResult.success("算法通知后端更新文本内容成功", sysFileService.handsToParseTxt(kgId, fileId));
|
|
|
}
|
|
|
return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ // String str = "2021年11月,获得2021年休斯敦世界乒乓球锦标赛女单冠军、女双冠军。 [113]2022年12月,获得2022赛季乒超联赛女团冠军。 [219]2023年4月,获得2023年WTT冠军赛澳门站<span class=\"entityhig\" style=\"border-bottom: 8px #E73B28 solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E73B28\" data-before=\"荣誉\" id=\"10\">女单冠军</span> [232];9月,获得亚洲乒乓球锦标赛女单、女双冠军 [251] [254] [264];9月26日,王曼昱帮助中国队获得杭州第19届亚运会乒乓球女子团体冠军。";
|
|
|
+ //
|
|
|
+ // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)");
|
|
|
+ // Matcher matcher = pattern.matcher(str);
|
|
|
+ //
|
|
|
+ // StringBuffer sb = new StringBuffer();
|
|
|
+ // while (matcher.find()) {
|
|
|
+ // String replacement = "<span class=\"entityhig\"" + matcher.group(1) + "--color:#ffffff";
|
|
|
+ // matcher.appendReplacement(sb, replacement);
|
|
|
+ // }
|
|
|
+ // matcher.appendTail(sb);
|
|
|
+ //
|
|
|
+ // String modifiedStr = sb.toString();
|
|
|
+ // System.out.println(modifiedStr);
|
|
|
+
|
|
|
+
|
|
|
+ String str = "<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#448DFF\" data-before=\"运动员\" id=\"59\">王曼昱</span> 身高176cm 生于1999年02月09日 出生地<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E62BCA\" data-before=\"出生地\" id=\"60\">黑龙江省齐齐哈尔</span>。2008年入选<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"61\">黑龙江省集训队</span>,2013年进入<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"62\">国家青年队</span>。2016年进入<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"63\">国家一队</span>。2021年,获得<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#1DEB19\" data-before=\"比赛\" id=\"64\">2021赛季中国乒乓球俱乐部超级联赛</span><span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E73B28\" data-before=\"荣誉\" id=\"65\">女团冠军</span>。\n";
|
|
|
+
|
|
|
+ // // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)(.*?)");
|
|
|
+ // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)(.*?data-before=\"运动员\".*?)(.*?)>");
|
|
|
+ // // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)");
|
|
|
+ // Matcher matcher = pattern.matcher(str);
|
|
|
+ //
|
|
|
+ // StringBuffer sb = new StringBuffer();
|
|
|
+ // while (matcher.find()) {
|
|
|
+ // String replacement = "<span class=\"entityhig\"" + matcher.group(1) + "--color:#ffffff";
|
|
|
+ // matcher.appendReplacement(sb, replacement);
|
|
|
+ // }
|
|
|
+ // matcher.appendTail(sb);
|
|
|
+
|
|
|
+ // String modifiedStr = str.toString();
|
|
|
+ // System.out.println(modifiedStr);
|
|
|
+
|
|
|
+ String regex = "<span[^>]*data-before=\"队伍\"[^>]*>([^<]+)<\\/span>";
|
|
|
+ CommonUtils.dealTextFrontWithColor(str,"队伍","#f28500");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// todo ----------------------------以下接口均为模拟算法测试接口,后续可删除下列接口------------------------------------。
|
|
|
|