|
|
|
@ -59,6 +59,27 @@ public class Text2vecServiceImpl implements Text2vecService {
|
|
|
|
|
return "success".equals(JSONUtil.parseObj(body).get("status"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean updateDataset(Map<String, QuestionAnswerDTO> questionAnswerDTOMap) {
|
|
|
|
|
if (CollUtil.isEmpty(questionAnswerDTOMap)){
|
|
|
|
|
log.info("updateDataset: questionAnswerDTOMap is empty");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 更新text2vec数据信息
|
|
|
|
|
List<Text2vecDataVo> text2vecDataVoList = questionAnswerDTOMap.entrySet().stream()
|
|
|
|
|
.filter(entry -> Objects.nonNull(entry.getValue())
|
|
|
|
|
&& CollUtil.isNotEmpty(entry.getValue().getQuestionList())
|
|
|
|
|
&& CollUtil.isNotEmpty(entry.getValue().getAnswerList()))
|
|
|
|
|
.flatMap(entry -> entry.getValue().getQuestionList().stream()
|
|
|
|
|
.map(question -> new Text2vecDataVo(entry.getValue().getAnswerList().get(0), question))).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(text2vecDataVoList)){
|
|
|
|
|
log.info("updateDataset: text2vecDataVoList is empty");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return updateDataset(text2vecDataVoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Text2vecMatchesRes> matches(Text2vecMatchesReq text2vecMatchesReq) {
|
|
|
|
|
|
|
|
|
@ -83,19 +104,9 @@ public class Text2vecServiceImpl implements Text2vecService {
|
|
|
|
|
log.info("question.json文件已经存在,不进行text2vec数据初始化操作....");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<String, QuestionAnswerDTO> intentCodeAndIdMap = rasaCmdService.getIntentCodeAndIdMap();
|
|
|
|
|
// 更新text2vec数据信息
|
|
|
|
|
List<Text2vecDataVo> text2vecDataVoList = intentCodeAndIdMap.entrySet().stream()
|
|
|
|
|
.filter(entry -> Objects.nonNull(entry.getValue())
|
|
|
|
|
&& CollUtil.isNotEmpty(entry.getValue().getQuestionList())
|
|
|
|
|
&& CollUtil.isNotEmpty(entry.getValue().getAnswerList()))
|
|
|
|
|
.flatMap(entry -> entry.getValue().getQuestionList().stream()
|
|
|
|
|
.map(question -> new Text2vecDataVo(entry.getValue().getAnswerList().get(0), question))).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isEmpty(text2vecDataVoList)){
|
|
|
|
|
log.info("text2vec数据初始化失败,text2vec数据为空....");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.updateDataset(text2vecDataVoList);
|
|
|
|
|
Map<String, QuestionAnswerDTO> intentCodeAndIdMap = rasaCmdService.getIntentCodeAndIdMap();
|
|
|
|
|
this.updateDataset(intentCodeAndIdMap);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|