Browse Source

label中标准词初始化

kwzbigdata 4 years ago
parent
commit
2f526fb07b

+ 1 - 0
src/main/java/com/diagbot/facade/BillFacade.java

@@ -38,6 +38,7 @@ public class BillFacade {
 
         // 标准词转换 TODO
         Map<String, Map<String, String>> typeStand = neoFacade.standConvert(standConvert);
+        wordBillCrfDTO = commonFacade.dataTypeSet(wordBillCrfDTO, typeStand);
 
         // 图谱接口调用
         BillNeoVO billNeoVO = new BillNeoVO();

+ 2 - 8
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -61,16 +61,10 @@ public class CommonFacade {
         return standConvert;
     }
     //把图谱返回的标准词set到label中
-    public StandConvert dataTypeSet(WordBillCrfDTO wordBillCrfDTO, Map<String, Map<String, String>> map){
-        StandConvert standConvert = new StandConvert();
-        List<String> clinicalList = new ArrayList<>();
-
+    public WordBillCrfDTO dataTypeSet(WordBillCrfDTO wordBillCrfDTO, Map<String, Map<String, String>> map){
         ChiefLabel chiefLabel = wordBillCrfDTO.getChiefLabel();
-
         CoreUtil.setPropertyList(chiefLabel.getClinicals(),map.get("clinicalList"));
-
-        standConvert.setClinicalList(clinicalList);
-        return standConvert;
+        return wordBillCrfDTO;
     }
 
 }

+ 144 - 143
src/main/java/com/diagbot/model/ai/process/EntityProcessClinic.java

@@ -1,143 +1,144 @@
-package com.diagbot.model.ai.process;
-
-
-import com.alibaba.fastjson.JSONObject;
-import com.diagbot.model.ai.model.EntityEnum;
-import com.diagbot.model.ai.model.Lemma;
-import com.diagbot.model.entity.*;
-import com.diagbot.model.label.PresentLabel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * 现病史处理
- */
-public class EntityProcessClinic extends EntityProcess {
-    private Logger logger = LoggerFactory.getLogger(EntityProcessClinic.class);
-
-    public PresentLabel extractEntity(JSONObject aiOut) {
-        PresentLabel presentLabel = new PresentLabel();
-        try {
-            //临床表现
-            List<Lemma> clinicLemmas = createEntityTree(aiOut, EntityEnum.CLINICAL_FEATURE.toString());
-            for (Lemma lemma : clinicLemmas) {
-                Clinical clinical = new Clinical();
-                clinical.setName(lemma.getText());
-
-                List<PD> timestamp = new LinkedList<>();
-                for (Lemma relationLemma : lemma.getRelationLemmas()) {
-                    if (relationLemma.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
-                        clinical.setNegative(findNegative(lemma));
-                    }
-                    clinical.setModification(findT(lemma, new Modification(), EntityEnum.MODIFICATION.toString()));//修饰
-                    clinical.setBodyPart(findT(lemma, new BodyPart(), EntityEnum.BODY.toString()));//部位
-                    clinical.setTrend(findT(lemma, new Trend(), EntityEnum.TREND.toString()));//趋势
-                    clinical.setCause(findT(lemma, new Cause(), EntityEnum.CAUSE.toString()));//诱因
-                    clinical.setProperty(findT(lemma, new Property(), EntityEnum.PROPERTY.toString()));//性质
-                    clinical.setDegree(findT(lemma, new Degree(), EntityEnum.DEGREE.toString()));//程度
-                    clinical.setAggravate(findT(lemma, new Aggravate(), EntityEnum.AGGRAVATE.toString()));//加重因素
-                    clinical.setRelief(findT(lemma, new Relief(), EntityEnum.RELIEF.toString()));//缓解因素
-                    if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
-                        String[] time_split = relationLemma.getText().split(",");
-                        for (String time : time_split) {
-                            PD pd = new PD();
-                            String[] val_unit = new String[2];
-                            if (time.trim().length() > 0) {
-                                val_unit = extract_digit(time);
-                            }
-                            pd.setValue(val_unit[0]);
-                            pd.setUnit(val_unit[1]);
-                            pd.setName(time);
-                            timestamp.add(pd);
-                        }
-                    }
-                }
-                clinical.setTimestamp(timestamp);
-                presentLabel.add(presentLabel.getClinicals(), clinical);
-            }
-            //入院途径
-            List<Lemma> beHospitalizedWayLemmas = createEntityTree(aiOut, EntityEnum.BEHOSPITALIZEDWAY.toString());
-            for (Lemma lemma : beHospitalizedWayLemmas) {
-                BeHospitalizedWay beHospitalizedWay = new BeHospitalizedWay();
-                beHospitalizedWay.setName(lemma.getText());
-                presentLabel.setBeHospitalizedWay(beHospitalizedWay);
-            }
-            //诊断信息
-            EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
-            List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
-            presentLabel.setDiags(diags);
-
-            //一般情况信息
-            List<Lemma> geneLemmas = createEntityTree(aiOut, EntityEnum.GENERAL_DESCRIPT.toString());
-            for (Lemma lemma : geneLemmas) {
-                General general = new General();
-                general.setName(lemma.getText());
-                presentLabel.add(presentLabel.getGens(), general);
-            }
-            List<Lemma> causeLemmas = createEntityTree(aiOut, EntityEnum.CAUSE.toString());
-            List<Cause> causes = new ArrayList<>();
-            for (Lemma lemma : causeLemmas) {
-                Cause cause = new Cause();
-                cause.setName(lemma.getText());
-                causes.add(cause);
-            }
-            presentLabel.setCauses(causes);
-
-            //一般情况描述信息
-            EntityProcessGenerals entityProcessGeneral = new EntityProcessGenerals();
-            List<GeneralDesc> generals = entityProcessGeneral.extractEntity(aiOut);
-            presentLabel.setGenerals(generals);
-
-            //辅检信息
-            EntityProcessPacs entityProcessLis = new EntityProcessPacs();
-            List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
-            presentLabel.setPacses(pacses);
-
-            //治疗
-            List<Lemma> cureLemmas = createEntityTree(aiOut, EntityEnum.CURE.toString());
-            List<Treat> treats = new ArrayList<>();
-            for (Lemma lemma : cureLemmas) {
-                Treat treat = new Treat();
-                treat.setName(lemma.getText());
-                treats.add(treat);
-            }
-            presentLabel.setTreats(treats);
-            //治疗
-            List<Lemma> cureLemmas_me = createEntityTree(aiOut, EntityEnum.DRUG.toString());
-            List<Medicine> medicines = new ArrayList<>();
-            for (Lemma lemma : cureLemmas_me) {
-                Medicine medicine = new Medicine();
-                medicine.setName(lemma.getText());
-                medicines.add(medicine);
-            }
-            presentLabel.setMedicines(medicines);
-
-            //手术
-            List<Lemma> operationLemmas = createEntityTree(aiOut, EntityEnum.OPERATION.toString());
-            for (Lemma lemma : operationLemmas) {
-                Operation operation = new Operation();
-                operation.setName(lemma.getText());
-                presentLabel.add(presentLabel.getOperations(), operation);
-            }
-
-            //时间
-            List<Lemma> pdLemmas = createEntityTree(aiOut, EntityEnum.TIME.toString());
-            List<PD> pds = new ArrayList<>();
-            for (Lemma lemma : pdLemmas) {
-                PD pd = new PD();
-                pd.setName(lemma.getText());
-                pds.add(pd);
-            }
-            presentLabel.setPds(pds);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            logger.error(e.getMessage(), e);
-        }
-        return presentLabel;
-    }
-}
+package com.diagbot.model.ai.process;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.diagbot.model.ai.model.EntityEnum;
+import com.diagbot.model.ai.model.Lemma;
+import com.diagbot.model.entity.*;
+import com.diagbot.model.label.PresentLabel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * 现病史处理
+ */
+public class EntityProcessClinic extends EntityProcess {
+    private Logger logger = LoggerFactory.getLogger(EntityProcessClinic.class);
+
+    public PresentLabel extractEntity(JSONObject aiOut) {
+        PresentLabel presentLabel = new PresentLabel();
+        try {
+            //临床表现
+            List<Lemma> clinicLemmas = createEntityTree(aiOut, EntityEnum.CLINICAL_FEATURE.toString());
+            for (Lemma lemma : clinicLemmas) {
+                Clinical clinical = new Clinical();
+                clinical.setName(lemma.getText());
+                clinical.setStandName(lemma.getText());
+
+                List<PD> timestamp = new LinkedList<>();
+                for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                    if (relationLemma.getProperty().equals(EntityEnum.NEGATIVE.toString())) {
+                        clinical.setNegative(findNegative(lemma));
+                    }
+                    clinical.setModification(findT(lemma, new Modification(), EntityEnum.MODIFICATION.toString()));//修饰
+                    clinical.setBodyPart(findT(lemma, new BodyPart(), EntityEnum.BODY.toString()));//部位
+                    clinical.setTrend(findT(lemma, new Trend(), EntityEnum.TREND.toString()));//趋势
+                    clinical.setCause(findT(lemma, new Cause(), EntityEnum.CAUSE.toString()));//诱因
+                    clinical.setProperty(findT(lemma, new Property(), EntityEnum.PROPERTY.toString()));//性质
+                    clinical.setDegree(findT(lemma, new Degree(), EntityEnum.DEGREE.toString()));//程度
+                    clinical.setAggravate(findT(lemma, new Aggravate(), EntityEnum.AGGRAVATE.toString()));//加重因素
+                    clinical.setRelief(findT(lemma, new Relief(), EntityEnum.RELIEF.toString()));//缓解因素
+                    if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                        String[] time_split = relationLemma.getText().split(",");
+                        for (String time : time_split) {
+                            PD pd = new PD();
+                            String[] val_unit = new String[2];
+                            if (time.trim().length() > 0) {
+                                val_unit = extract_digit(time);
+                            }
+                            pd.setValue(val_unit[0]);
+                            pd.setUnit(val_unit[1]);
+                            pd.setName(time);
+                            timestamp.add(pd);
+                        }
+                    }
+                }
+                clinical.setTimestamp(timestamp);
+                presentLabel.add(presentLabel.getClinicals(), clinical);
+            }
+            //入院途径
+            List<Lemma> beHospitalizedWayLemmas = createEntityTree(aiOut, EntityEnum.BEHOSPITALIZEDWAY.toString());
+            for (Lemma lemma : beHospitalizedWayLemmas) {
+                BeHospitalizedWay beHospitalizedWay = new BeHospitalizedWay();
+                beHospitalizedWay.setName(lemma.getText());
+                presentLabel.setBeHospitalizedWay(beHospitalizedWay);
+            }
+            //诊断信息
+            EntityProcessDiag entityProcessDiag = new EntityProcessDiag();
+            List<Diag> diags = entityProcessDiag.extractEntity(aiOut);
+            presentLabel.setDiags(diags);
+
+            //一般情况信息
+            List<Lemma> geneLemmas = createEntityTree(aiOut, EntityEnum.GENERAL_DESCRIPT.toString());
+            for (Lemma lemma : geneLemmas) {
+                General general = new General();
+                general.setName(lemma.getText());
+                presentLabel.add(presentLabel.getGens(), general);
+            }
+            List<Lemma> causeLemmas = createEntityTree(aiOut, EntityEnum.CAUSE.toString());
+            List<Cause> causes = new ArrayList<>();
+            for (Lemma lemma : causeLemmas) {
+                Cause cause = new Cause();
+                cause.setName(lemma.getText());
+                causes.add(cause);
+            }
+            presentLabel.setCauses(causes);
+
+            //一般情况描述信息
+            EntityProcessGenerals entityProcessGeneral = new EntityProcessGenerals();
+            List<GeneralDesc> generals = entityProcessGeneral.extractEntity(aiOut);
+            presentLabel.setGenerals(generals);
+
+            //辅检信息
+            EntityProcessPacs entityProcessLis = new EntityProcessPacs();
+            List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
+            presentLabel.setPacses(pacses);
+
+            //治疗
+            List<Lemma> cureLemmas = createEntityTree(aiOut, EntityEnum.CURE.toString());
+            List<Treat> treats = new ArrayList<>();
+            for (Lemma lemma : cureLemmas) {
+                Treat treat = new Treat();
+                treat.setName(lemma.getText());
+                treats.add(treat);
+            }
+            presentLabel.setTreats(treats);
+            //治疗
+            List<Lemma> cureLemmas_me = createEntityTree(aiOut, EntityEnum.DRUG.toString());
+            List<Medicine> medicines = new ArrayList<>();
+            for (Lemma lemma : cureLemmas_me) {
+                Medicine medicine = new Medicine();
+                medicine.setName(lemma.getText());
+                medicines.add(medicine);
+            }
+            presentLabel.setMedicines(medicines);
+
+            //手术
+            List<Lemma> operationLemmas = createEntityTree(aiOut, EntityEnum.OPERATION.toString());
+            for (Lemma lemma : operationLemmas) {
+                Operation operation = new Operation();
+                operation.setName(lemma.getText());
+                presentLabel.add(presentLabel.getOperations(), operation);
+            }
+
+            //时间
+            List<Lemma> pdLemmas = createEntityTree(aiOut, EntityEnum.TIME.toString());
+            List<PD> pds = new ArrayList<>();
+            for (Lemma lemma : pdLemmas) {
+                PD pd = new PD();
+                pd.setName(lemma.getText());
+                pds.add(pd);
+            }
+            presentLabel.setPds(pds);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage(), e);
+        }
+        return presentLabel;
+    }
+}

+ 1 - 0
src/main/java/com/diagbot/model/ai/process/EntityProcessDiag.java

@@ -24,6 +24,7 @@ public class EntityProcessDiag extends EntityProcess {
             for (Lemma lemma : diagLemmas) {
                 Diag diag = new Diag();
                 diag.setName(lemma.getText());
+                diag.setStandName(lemma.getText());
                 if (lemma.isHaveChildren()) {
                     diag.setNegative(findNegative(lemma));//阴性
                     diag.setPossible(findT(lemma, new Possible(), EntityEnum.POSSIBLE.toString()));//可能的

+ 1 - 0
src/main/java/com/diagbot/model/ai/process/EntityProcessPast.java

@@ -30,6 +30,7 @@ public class EntityProcessPast extends EntityProcess {
 
                 Diag diag = new Diag();
                 diag.setName(lemma.getText());
+                diag.setStandName(lemma.getText());
                 if (lemma.isHaveChildren()) {
                     //阴性
                     diag.setNegative(findNegative(lemma));