|
|
|
@ -436,6 +436,24 @@ public class VecTest {
|
|
|
|
|
saveVec(vecData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void initQuestionJoinVecData(){
|
|
|
|
|
List<AskTemplateQuestionLibrary> questionLibraries = askTemplateQuestionLibraryService.list();
|
|
|
|
|
// load vec data
|
|
|
|
|
List<Map<String, Object>> vecData = questionLibraries.stream().map(library -> {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("questionCode", library.getId());
|
|
|
|
|
if (StrUtil.isEmpty(library.getDefaultAnswer())){
|
|
|
|
|
log.warn("defaultAnswer is empty . libraryId is :{}",library.getId());
|
|
|
|
|
}
|
|
|
|
|
List<String> joinList= library.getQuestion().stream()
|
|
|
|
|
.map(question -> question + " " + library.getDefaultAnswer()).collect(Collectors.toList());
|
|
|
|
|
map.put("questionList",joinList);
|
|
|
|
|
return map;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
saveVec(vecData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void initMedicalVecData(){
|
|
|
|
|
String medicalId = "1";
|
|
|
|
@ -637,4 +655,49 @@ public class VecTest {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void questionJoinAnswerTest(){
|
|
|
|
|
List<AskTemplateQuestionLibrary> questionLibraries = askTemplateQuestionLibraryService.list();
|
|
|
|
|
List<CommonDic> commonDics = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
|
|
|
|
Map<Long, CommonDic> dicMap = commonDics.stream().collect(Collectors.toMap(CommonDic::getId, v -> v));
|
|
|
|
|
Map<String, AskTemplateQuestionLibrary> libraryMap = questionLibraries.stream().collect(Collectors.toMap(AskTemplateQuestionLibrary::getId, library -> library));
|
|
|
|
|
|
|
|
|
|
String path = "F:\\tmp\\1\\门诊收集0524.xlsx";
|
|
|
|
|
|
|
|
|
|
ExcelReader reader = ExcelUtil.getReader(path);
|
|
|
|
|
List<Map<String, Object>> maps = reader.readAll();
|
|
|
|
|
|
|
|
|
|
for (Map<String, Object> map : maps) {
|
|
|
|
|
String question = MapUtil.getStr(map, "日常问诊");
|
|
|
|
|
List<Map<String, Object>> matchMapList = questionMatch(question);
|
|
|
|
|
if (CollUtil.isEmpty(matchMapList)) {
|
|
|
|
|
log.warn("questionMatch:问题:{}没有匹配到结果", question);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> first = CollUtil.getFirst(matchMapList);
|
|
|
|
|
String matchQuestion = MapUtil.getStr(first, "matchQuestion");
|
|
|
|
|
String score = MapUtil.getStr(first, "matchScore");
|
|
|
|
|
String targetId = MapUtil.getStr(first, "matchQuestionCode");
|
|
|
|
|
map.put("targetId", targetId);
|
|
|
|
|
map.put("targetQuestion", matchQuestion);
|
|
|
|
|
AskTemplateQuestionLibrary targetLibrary = libraryMap.get(targetId);
|
|
|
|
|
map.put("targetDesc", targetLibrary.getDescription());
|
|
|
|
|
Long dictId = targetLibrary.getDictId();
|
|
|
|
|
map.put("targetDicPath", dicMap.get(dictId).getNameZhPath());
|
|
|
|
|
map.put("matchScore", score);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExcelWriter writer = ExcelUtil.getWriter(path, "问询结果-问答拼接");
|
|
|
|
|
writer.addHeaderAlias("病例", "病例");
|
|
|
|
|
writer.addHeaderAlias("日常问诊", "日常问诊");
|
|
|
|
|
writer.addHeaderAlias("targetId", "目标问题");
|
|
|
|
|
writer.addHeaderAlias("targetDesc", "目标问题描述");
|
|
|
|
|
writer.addHeaderAlias("targetQuestion", "目标问题");
|
|
|
|
|
writer.addHeaderAlias("matchScore", "相似度");
|
|
|
|
|
writer.addHeaderAlias("targetDicPath", "目标分类");
|
|
|
|
|
writer.write(maps,true);
|
|
|
|
|
writer.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|