|
@@ -0,0 +1,63 @@
|
|
|
|
+package com.lantone.structure.facade;
|
|
|
|
+
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
+import com.lantone.common.util.FastJsonUtils;
|
|
|
|
+import com.lantone.structure.ai.AIAnalyze;
|
|
|
|
+import com.lantone.structure.client.CRFServiceClient;
|
|
|
|
+import com.lantone.structure.client.SimilarityServiceClient;
|
|
|
|
+import com.lantone.structure.dto.AnalysisDTO;
|
|
|
|
+import com.lantone.structure.model.InputInfo;
|
|
|
|
+import com.lantone.structure.model.doc.BeHospitalizedDoc;
|
|
|
|
+import com.lantone.structure.model.label.PresentLabel;
|
|
|
|
+import com.lantone.structure.vo.AnalysisVO;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description:
|
|
|
|
+ * @author: rengb
|
|
|
|
+ * @time: 2020/12/18 16:22
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Component
|
|
|
|
+public class StructureFacade {
|
|
|
|
+ @Autowired
|
|
|
|
+ CRFServiceClient crfServiceClient;
|
|
|
|
+ @Autowired
|
|
|
|
+ SimilarityServiceClient similarityServiceClient;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public AnalysisDTO analysis(AnalysisVO analysisVO) {
|
|
|
|
+ AnalysisDTO analysisDTO = new AnalysisDTO();
|
|
|
|
+ InputInfo inputInfo = new InputInfo();
|
|
|
|
+
|
|
|
|
+ BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
|
|
|
|
+
|
|
|
|
+ PresentLabel presentLabel = new PresentLabel();
|
|
|
|
+ presentLabel.setText(analysisVO.getText());
|
|
|
|
+ beHospitalizedDoc.setPresentLabel(presentLabel);
|
|
|
|
+
|
|
|
|
+ inputInfo.setBeHospitalizedDoc(beHospitalizedDoc);
|
|
|
|
+
|
|
|
|
+ AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient, similarityServiceClient);
|
|
|
|
+ try {
|
|
|
|
+ aiAnalyze.aiProcess(inputInfo);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("AI模型执行错误:" + e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
|
+ Map<String, Object> jsonMap = FastJsonUtils.getJsonToMap(FastJsonUtils.getBeanToJson(inputInfo.getBeHospitalizedDoc().getPresentLabel()));
|
|
|
|
+ jsonMap.remove("text");
|
|
|
|
+ jsonMap.remove("aiText");
|
|
|
|
+ jsonMap.remove("crfLabel");
|
|
|
|
+ jsonMap.remove("crfOutput");
|
|
|
|
+ map.put("现病史", jsonMap);
|
|
|
|
+ analysisDTO.setResult(map);
|
|
|
|
+ return analysisDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|