代码功能bug修复

优化问答功能
v_0.0.2
xueqingkun 2 weeks ago
parent 06aab1d9aa
commit 89140d638f

@ -26,8 +26,10 @@ public class ErAttributeServiceImpl extends ServiceImpl<ErAttributeMapper, ErAtt
public void saveIfAbsents(ErAttribute erAttribute, String domainMetadataId) {
Assert.notEmpty(domainMetadataId, "领域分类id不能为空");
List<ErAttribute> erAttributes = this.listByDomainMetadataId(domainMetadataId);
boolean exists = erAttributes.stream().anyMatch(item -> StrUtil.equals(item.getAttrName(), erAttribute.getAttrName())
&& StrUtil.equals(item.getErLabel(), erAttribute.getErLabel()));
boolean exists = erAttributes.stream().anyMatch(item ->
StrUtil.equals(item.getAttrName(), erAttribute.getAttrName())
&& StrUtil.equals(item.getErLabel(), erAttribute.getErLabel())
&& StrUtil.equals(item.getErType(), erAttribute.getErType()));
if (exists){
log.info("属性已存在,{},不进行保存...", erAttribute.getAttrName());
return;

@ -204,18 +204,22 @@ public class KnowledgeGraphServiceImpl implements KnowledgeGraphService {
}
log.info("开始意图元数据识别,切分文档id:{}", truncateDTO.getId());
interval.start("makeOutDomainMetadata");
List<DomainMetadataDTO> domainMetadataDTOS = tripleConversionPipeline.makeOutDomainMetadata(truncateDTO, intents);
log.info("意图元数据识别完成,切分文档id:{},耗时:{}毫秒", truncateDTO.getId(),interval.intervalMs("makeOutDomainMetadata"));
// 保存意图数据
List<List<String>> intentSplit = CollUtil.split(intents, 10);
log.info("切分意图列表,切分前数据总数:{},切分出:{}组数据", intents.size(), intentSplit.size());
for (List<String> intentList : intentSplit) {
// 每10个意图进行一次元数据识别
List<DomainMetadataDTO> domainMetadataDTOS = tripleConversionPipeline.makeOutDomainMetadata(truncateDTO, intentList);
log.info("意图元数据识别完成,切分文档id:{},耗时:{}毫秒", truncateDTO.getId(),interval.intervalMs("makeOutDomainMetadata"));
// 保存意图数据
List<Intention> intentions = intentionService.batchSaveIfAbsent(intents, pdfInfo.getDomainCategoryId(), pdfId.toString());
for (Intention intention : intentions) {
List<DomainMetadataDTO> metadataDTOS = domainMetadataDTOS.stream()
.filter(d -> StrUtil.equals(d.getIntentDigest(), intention.getDigest())).toList();
domainMetadataService.batchSaveOrUpdateMetadata(metadataDTOS,intention.getId(), pdfInfo.getDomainCategoryId());
}
}
intentSize ++;
index ++;
List<Intention> intentions = intentionService.batchSaveIfAbsent(intents, pdfInfo.getDomainCategoryId(), pdfId.toString());
for (Intention intention : intentions) {
List<DomainMetadataDTO> metadataDTOS = domainMetadataDTOS.stream()
.filter(d -> StrUtil.equals(d.getIntentDigest(), intention.getDigest())).toList();
domainMetadataService.batchSaveOrUpdateMetadata(metadataDTOS,intention.getId(), pdfInfo.getDomainCategoryId());
}
}catch (Exception e){
index ++;
log.error("切分文档id:{},意图识别失败", truncateDTO.getId(), e);

@ -116,7 +116,12 @@ public class TripleConversionPipelineImpl implements TripleConversionPipeline {
log.info("makeOutDomainMetadata:format{}", format);
String call = aiCallService.call(format);
log.info("makeOutDomainMetadata:响应结果:{}", call);
return parseDomainMetadataObj(call);
try {
return parseDomainMetadataObj(call);
} catch (Exception e) {
log.error("makeOutDomainMetadata:解析失败:{}", call);
throw new RuntimeException(e);
}
}
/**
@ -351,6 +356,7 @@ public class TripleConversionPipelineImpl implements TripleConversionPipeline {
TruncateDTO truncateDTO = new TruncateDTO(documentDTO, truncateTextBuild.toString());
truncateDTO.setLayoutType(String.valueOf(LayoutTypeEnum.TEXT.getCode()));//强制设置为文本类型
truncateDTOS.add(truncateDTO);
truncateTextBuild = new StringBuilder(INITIAL_BUFFER_SIZE);
}
// 提前抽取表名
TableTitleDTO tableTitleDTO = this.extractTableTitle(documentDTO.getTitle());

Loading…
Cancel
Save