|
|
|
@ -97,10 +97,13 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
}
|
|
|
|
|
// 判断,如果已经有确定的叶子节点了,这时,就可以直接根据意图来问了,就不要要提取实体了
|
|
|
|
|
if (ObjectUtil.isNotEmpty(sessionParamDTO.getMatchItemLeaf())) {
|
|
|
|
|
log.info("上一个问题继续问,直接根据用户的新问题找结果");
|
|
|
|
|
sessionParamDTO.setOriginalQuestion(roundTalkReqVO.getUserTalk());
|
|
|
|
|
// 识别意图
|
|
|
|
|
String intent = identifyIntentHandler.identifyIntentExample(roundTalkReqVO.getUserTalk());
|
|
|
|
|
sessionParamDTO.setIntent(intent);
|
|
|
|
|
redisTemplate.opsForValue().set(SESSION_PARAM + sessionId, sessionParamDTO);
|
|
|
|
|
// 回答
|
|
|
|
|
return afterMatchReturnAnswer(sessionParamDTO);
|
|
|
|
|
}
|
|
|
|
|
// 判断意图是否为空,如果意图为空,进行识别意图
|
|
|
|
@ -115,9 +118,8 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
if (CollUtil.isEmpty(sessionParamDTO.getEntityValueByExtract()) && ObjectUtil.isEmpty(sessionParamDTO.getMatchItemLeaf())) {
|
|
|
|
|
// 识别实体(先从图中获取所有的节点名称,然后识别)
|
|
|
|
|
List<String> allItemNode = findItemNodeHandler.findAllItemNode();
|
|
|
|
|
List<String> extractValue = itemExtractHandler.itemExtractByPossibleItemWithExample(sessionParamDTO.getOriginalQuestion(), allItemNode);
|
|
|
|
|
// 识别问题中,用户可能问的业务是什么
|
|
|
|
|
// String extractValue = itemExtractHandler.itemExtractBusiness(sessionParamDTO.getOriginalQuestion());
|
|
|
|
|
List<String> extractValue = itemExtractHandler.itemExtractByPossibleItemWithExample(sessionParamDTO.getOriginalQuestion(), allItemNode);
|
|
|
|
|
sessionParamDTO.setEntityValueByExtract(extractValue);
|
|
|
|
|
// 根据提取的内容,开始在知识图谱中寻找节点(首先找叶子节点,如果叶子节点有数据,直接返回,如果叶子节点没数据,再去找分支节点)
|
|
|
|
|
List<ItemLeaf> allMatchLeafNode = findItemNodeHandler.findAllMatchLeafNode(extractValue);
|
|
|
|
@ -129,8 +131,6 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
} else {
|
|
|
|
|
// 如果不等于1,说明可能有不确定的节点,这时就要开始找节点
|
|
|
|
|
Map<String, ItemLeaf> waitMatchItemLeafMap = allMatchLeafNode.stream().collect(Collectors.toMap(ItemLeaf::getVid, Function.identity(), (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 所有的实体类型以及出现次数计数
|
|
|
|
|
Map<String, Integer> entityCountMap = new HashMap<>();
|
|
|
|
|
// 用来存放所有的节点以及节点路径(key是节点ID,value是节点路径)
|
|
|
|
|