Explorar el Código

关系抽取 页面展示

louhr hace 6 años
padre
commit
d262847575

+ 3 - 0
bigdata-web/src/main/java/org/diagbot/bigdata/work/ResultDataProxy.java

@@ -101,6 +101,9 @@ public class ResultDataProxy {
         Map<String, Float> result = new HashMap<>();
         String synonym = "";
         for (Map.Entry<String, Float> entry : map.entrySet()) {
+            if (entry.getKey().equals("冠状动脉粥样硬化性心脏病")) {
+                System.out.println("冠状动脉粥样硬化性心脏病");
+            }
             synonym = standardInfoSynonymMap.get(entry.getKey());
             if (synonym != null) {
                 if (result.get(synonym) == null) {

+ 5 - 5
nlp/src/main/java/org/diagbot/nlp/participle/cfg/DefaultConfig.java

@@ -35,7 +35,7 @@ public class DefaultConfig implements Configuration {
             EncrypDES encrypDES = new EncrypDES();
             for (i = 0; i < length; i++) {
                 String s = dicts.get(i);
-                line_string = org.apache.commons.lang3.StringUtils.split(new String(encrypDES.decryptor(dicts.get(i))), "\\|");
+                line_string = org.apache.commons.lang3.StringUtils.split(dicts.get(i), "\\|");
                 chars = line_string[0].toCharArray();
                 if (line_string.length == 3) {
                     segment.fill(segment, chars, 0, chars.length, Float.parseFloat(line_string[1]), line_string[2]);
@@ -56,9 +56,8 @@ public class DefaultConfig implements Configuration {
         String[] line_string;
         Map<String, String> map = new HashMap<>(10, 0.8f);
         try {
-            EncrypDES encrypDES = new EncrypDES();
             for (int i = 0; i < fileContents.size(); i++) {
-                line_string = org.apache.commons.lang3.StringUtils.split(new String(encrypDES.decryptor(fileContents.get(i))), "\\|");
+                line_string = org.apache.commons.lang3.StringUtils.split(fileContents.get(i), "\\|");
                 if (line_string.length == 2) {
                     if (map.get(line_string[0]) != null) {
                         map.put(line_string[0], map.get(line_string[0]) + "," + line_string[1]);
@@ -86,14 +85,15 @@ public class DefaultConfig implements Configuration {
             }
             BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512);
 
+            EncrypDES encrypDES = new EncrypDES();
             String theWord = null;
             do {
                 theWord = br.readLine();
                 if (theWord != null && !"".equals(theWord.trim())) {
-                    fileContents.add(theWord.trim());
+                    fileContents.add(new String(encrypDES.decryptor(theWord.trim())));
                 }
             } while (theWord != null);
-        } catch (IOException ioe) {
+        } catch (Exception ioe) {
             System.err.println("读取文件" + path + "出错.......................");
             ioe.printStackTrace();
         } finally {

+ 20 - 5
nlp/src/main/java/org/diagbot/nlp/relation/analyze/RelationAnalyze.java

@@ -8,10 +8,7 @@ import org.diagbot.nlp.feature.FeatureType;
 import org.diagbot.nlp.participle.ParticipleUtil;
 import org.diagbot.nlp.participle.word.Lexeme;
 import org.diagbot.nlp.participle.word.LexemePath;
-import org.diagbot.nlp.relation.extract.LisExtract;
-import org.diagbot.nlp.relation.extract.PacsExtract;
-import org.diagbot.nlp.relation.extract.PresentExtract;
-import org.diagbot.nlp.relation.extract.VitalExtract;
+import org.diagbot.nlp.relation.extract.*;
 import org.diagbot.nlp.relation.util.OutputInfo;
 import org.diagbot.nlp.relation.util.LemmaUtil;
 
@@ -37,11 +34,15 @@ public class RelationAnalyze {
             //分词结果转词元结构,只提取有词性信息,因为部分特征信息未在三元组中,所以需要把分词结果也一并传入
             List<Lemma> lemmaParticiple = lemmaUtil.lexemeToTriadLemma(lexemes);
             //调用CNN模型
+            long start = System.currentTimeMillis();
             AlgorithmCNNExecutor executor = new RelationExtractionModelImpl();
             List<Triad> triads = executor.execute(part_content, lemmaParticiple);
+            //删除不作为训练样本集
+            triads = lemmaUtil.findPairTraids(triads);
             //模型返回的三元组转树形结构
             List<Lemma> lemmaTree = lemmaUtil.traidToTree(triads, featureType);
-
+            long end = System.currentTimeMillis();
+            System.out.println("end - start : " + (end - start));
             OutputInfo outputInfo = new OutputInfo();
             switch (featureType) {
                 case SYMPTOM:
@@ -49,6 +50,7 @@ public class RelationAnalyze {
                     this.lemmaVitalExtract(outputInfo, lemmaTree, lemmaParticiple);
                     this.lemmaLisExtract(outputInfo, lemmaTree, lemmaParticiple);
                     this.lemmaPacsExtract(outputInfo, lemmaTree, lemmaParticiple);
+                    this.lemmaTreatExtract(outputInfo, lemmaTree, lemmaParticiple);
             }
             if (outputInfo != null) {
                 outputInfos.add(outputInfo);
@@ -102,4 +104,17 @@ public class RelationAnalyze {
         outputInfo = pacsExtract.extract(outputInfo, lemmaTree, lemmaParticiple);
         return outputInfo;
     }
+
+    /**
+     * 治疗特征提取
+     * @param outputInfo
+     * @param lemmaTree
+     * @param lemmaParticiple
+     * @return
+     */
+    public OutputInfo lemmaTreatExtract(OutputInfo outputInfo, List<Lemma> lemmaTree, List<Lemma> lemmaParticiple) {
+        TreatExtract treatExtract = new TreatExtract();
+        outputInfo = treatExtract.extract(outputInfo, lemmaTree, lemmaParticiple);
+        return outputInfo;
+    }
 }

+ 60 - 0
nlp/src/main/java/org/diagbot/nlp/relation/extract/TreatExtract.java

@@ -0,0 +1,60 @@
+package org.diagbot.nlp.relation.extract;
+
+import org.algorithm.core.cnn.entity.Lemma;
+import org.diagbot.nlp.relation.module.Pacs;
+import org.diagbot.nlp.relation.module.Treat;
+import org.diagbot.nlp.relation.util.OutputInfo;
+import org.diagbot.nlp.util.Constants;
+import org.diagbot.nlp.util.NlpUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName org.diagbot.nlp.relation.extract.PacsExtract
+ * @Description TODO
+ * @Author fyeman
+ * @Date 2019/3/25/025 10:05
+ * @Version 1.0
+ **/
+public class TreatExtract extends BaseExtract {
+    public OutputInfo extract(OutputInfo outputInfo, List<Lemma> lemmaTree, List<Lemma> lemmaParticiple) {
+        List<String> repeatTreatList = new ArrayList<>();
+        for (int index = 0; index < lemmaParticiple.size(); index++) {
+            Lemma participle_lemma = lemmaParticiple.get(index);
+            String property = participle_lemma.getProperty();
+            if (NlpUtil.isFeature(property, Constants.medicine_type)) {          //特征词
+                if (repeatTreatList.contains(participle_lemma.getText())) {
+                    continue;
+                }
+                Treat treat = lookTreatRelations(participle_lemma, lemmaTree);
+                outputInfo.getTreats().add(treat);
+
+                repeatTreatList.add(participle_lemma.getText());
+            }
+        }
+        lemmaTree.removeAll(containsLemmaTree);
+        return outputInfo;
+    }
+
+    private Treat lookTreatRelations(Lemma participle_lemma, List<Lemma> lemmaTree) {
+        Treat treat = new Treat();
+        treat.setTreatName(participle_lemma.getText());
+        for (Lemma cnn_l : lemmaTree) {
+            if (cnn_l.getText().equals(participle_lemma.getText())
+                    && cnn_l.getPosition().equals(participle_lemma.getPosition())) {
+                for (Lemma relation_l : cnn_l.getRelationLemmas()) {
+                    addFeatureToTreat(relation_l, treat);
+                }
+                containsLemmaTree.add(cnn_l);
+            }
+        }
+        return treat;
+    }
+
+    private void addFeatureToTreat(Lemma lemma, Treat treat) {
+        if (NlpUtil.isFeature(lemma.getProperty(), Constants.treatment_type)) {
+            treat.setValue(lemma.getText());
+        }
+    }
+}

+ 29 - 0
nlp/src/main/java/org/diagbot/nlp/relation/module/Treat.java

@@ -0,0 +1,29 @@
+package org.diagbot.nlp.relation.module;
+
+/**
+ * @ClassName org.diagbot.nlp.relation.module.Treat
+ * @Description TODO
+ * @Author fyeman
+ * @Date 2019/3/25/025 17:07
+ * @Version 1.0
+ **/
+public class Treat {
+    private String treatName;
+    private String value;
+
+    public String getTreatName() {
+        return treatName;
+    }
+
+    public void setTreatName(String treatName) {
+        this.treatName = treatName;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 17 - 1
nlp/src/main/java/org/diagbot/nlp/relation/module/cell/PD.java

@@ -1,5 +1,11 @@
 package org.diagbot.nlp.relation.module.cell;
 
+import org.diagbot.nlp.participle.ParticipleUtil;
+import org.diagbot.nlp.participle.word.Lexeme;
+import org.diagbot.nlp.participle.word.LexemePath;
+
+import java.io.IOException;
+
 public class PD {
     private String value;
     private String unit;
@@ -9,7 +15,17 @@ public class PD {
     }
 
     public void setValue(String value) {
-        this.value = value;
+        try {
+            LexemePath<Lexeme> lexemes = ParticipleUtil.participle(value);
+            if (lexemes.size() == 2) {
+                this.value = lexemes.get(0).getText();
+                this.unit = lexemes.get(1).getText();
+            } else {
+                this.value = value;
+            }
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
     }
 
     public String getUnit() {

+ 35 - 3
nlp/src/main/java/org/diagbot/nlp/relation/util/LemmaUtil.java

@@ -7,10 +7,12 @@ import org.diagbot.nlp.participle.word.Lexeme;
 import org.diagbot.nlp.participle.word.LexemePath;
 import org.diagbot.nlp.util.Constants;
 import org.diagbot.nlp.util.NegativeEnum;
+import org.diagbot.nlp.util.NlpCache;
 import org.diagbot.nlp.util.NlpUtil;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName org.diagbot.nlp.relation.util.LemmaUtil
@@ -54,6 +56,7 @@ public class LemmaUtil {
                 select(lemmaTree, triads, Constants.vital_type);
                 select(lemmaTree, triads, Constants.lis_name_type);
                 select(lemmaTree, triads, Constants.pacs_name_type);
+                select(lemmaTree, triads, Constants.medicine_type);
         }
         return lemmaTree;
     }
@@ -63,9 +66,6 @@ public class LemmaUtil {
         for (Triad triad : triads) {
             Lemma left_l = null;
             Lemma right_l = null;
-            if (triad.getL_1().getText().equals("体温最高") || triad.getL_2().getText().equals("体温最高")) {
-                System.out.println("体温最高");
-            }
             if (NlpUtil.isFeature(triad.getL_1().getProperty(), type)) {
                 left_l = this.copyProperties(triad.getL_1());
                 right_l = this.copyProperties(triad.getL_2());
@@ -129,4 +129,36 @@ public class LemmaUtil {
         l.setText(lemma.getText());
         return l;
     }
+
+    public List<Triad> findPairTraids(List<Triad> triads) {
+        Map<String, List<String>> extract_relation_property_pair_map = NlpCache.getExtract_relation_property_pair_map();
+
+        String[] prop1;
+        String[] prop2;
+        boolean isPair = false;
+        List<String> props = null;
+
+        List<Triad> pairTriads = new ArrayList<>();
+        for (Triad triad : triads) {
+            prop1 = triad.getL_1().getProperty().split(",");
+            prop2 = triad.getL_2().getProperty().split(",");
+            for (int i = 0; i < prop1.length; i++) {
+                props = extract_relation_property_pair_map.get(prop1[i]);
+                if (props == null) {
+                    continue;
+                }
+                for (int j = 0; j < prop2.length; j++) {
+                    if (props.contains(prop2[j])) {
+                        isPair = true;
+                        break;
+                    }
+                }
+            }
+            if (isPair) {
+                pairTriads.add(triad);
+            }
+            isPair = false;
+        }
+        return pairTriads;
+    }
 }

+ 11 - 4
nlp/src/main/java/org/diagbot/nlp/relation/util/OutputInfo.java

@@ -1,9 +1,7 @@
 package org.diagbot.nlp.relation.util;
 
-import org.diagbot.nlp.relation.module.Lis;
-import org.diagbot.nlp.relation.module.Pacs;
-import org.diagbot.nlp.relation.module.Symptom;
-import org.diagbot.nlp.relation.module.Vital;
+import org.apache.commons.collections.ArrayStack;
+import org.diagbot.nlp.relation.module.*;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -20,6 +18,7 @@ public class OutputInfo {
     List<Vital> vitals = new ArrayList<>();
     List<Lis> lises = new ArrayList<>();
     List<Pacs> pacses = new ArrayList<>();
+    List<Treat> treats = new ArrayList<>();
 
     public List<Symptom> getSymptoms() {
         return symptoms;
@@ -52,4 +51,12 @@ public class OutputInfo {
     public void setPacses(List<Pacs> pacses) {
         this.pacses = pacses;
     }
+
+    public List<Treat> getTreats() {
+        return treats;
+    }
+
+    public void setTreats(List<Treat> treats) {
+        this.treats = treats;
+    }
 }

+ 2 - 0
nlp/src/main/java/org/diagbot/nlp/util/Constants.java

@@ -34,6 +34,8 @@ public class Constants {
     public static NegativeEnum[] lis_result_type = new NegativeEnum[]{NegativeEnum.LIS_RESULT};
     public static NegativeEnum[] pacs_name_type = new NegativeEnum[]{NegativeEnum.PACS_NAME};
     public static NegativeEnum[] pacs_result_type = new NegativeEnum[]{NegativeEnum.PACS_RESULT};
+    public static NegativeEnum[] treatment_type = new NegativeEnum[]{NegativeEnum.TREATMENT};
+    public static NegativeEnum[] medicine_type = new NegativeEnum[]{NegativeEnum.MEDICINE};
 
     public static String[] negative_words = new String[]{"无", "未", "未及", "无殊", "否认", "未见", "不", "未闻", "未闻及", "欠", "非"};
 

+ 50 - 0
nlp/src/main/java/org/diagbot/nlp/util/NlpCache.java

@@ -24,6 +24,8 @@ public class NlpCache {
     public static Map<String, String> standard_info_classify_map = null;
     //树形结构存储大小类
     public static Map<String, Node> standard_info_type_tree_map = null;
+    //后结构化 有可能作为训练样本词性匹配对
+    public static Map<String, List<String>> extract_relation_property_pair_map = null;
 
     public static void createSegmentCache() {
         Configuration configuration = new DefaultConfig();
@@ -50,6 +52,46 @@ public class NlpCache {
         standard_info_classify_map = configuration.loadMapDict("classify.dict");
     }
 
+    public static void createPropertyPairCache() {
+        Configuration configuration = new DefaultConfig();
+        List<String> lines = configuration.readFileContents("relation.dict");
+
+        extract_relation_property_pair_map = new HashMap<>();
+        List<String> list = null;
+        for (String line : lines) {
+            String[] prop = line.split("\\|");
+            if(prop.length != 2) {
+                continue;
+            }
+            String prop1_id = prop[0];
+            String prop2_id = prop[1];
+
+            list = extract_relation_property_pair_map.get(prop1_id);
+            if (list == null) {
+                list = new ArrayList<>();
+                list.add(prop2_id);
+                extract_relation_property_pair_map.put(prop1_id, list);
+            } else {
+                if (!list.contains(prop2_id)) {
+                    list.add(prop2_id);
+                    extract_relation_property_pair_map.put(prop1_id, list);
+                }
+            }
+
+            list = extract_relation_property_pair_map.get(prop2_id);
+            if (list == null) {
+                list = new ArrayList<>();
+                list.add(prop1_id);
+                extract_relation_property_pair_map.put(prop2_id, list);
+            } else {
+                if (!list.contains(prop1_id)) {
+                    list.add(prop1_id);
+                    extract_relation_property_pair_map.put(prop2_id, list);
+                }
+            }
+        }
+    }
+
     public static Segment getSegment_cache() {
         if (segment_cache == null) {
             createSegmentCache();
@@ -78,6 +120,14 @@ public class NlpCache {
         return standard_info_classify_map;
     }
 
+    public static Map<String, List<String>> getExtract_relation_property_pair_map() {
+        if (extract_relation_property_pair_map == null) {
+            createPropertyPairCache();
+        }
+        return extract_relation_property_pair_map;
+    }
+
+
     public static Map<String, Node> getStandard_info_type_tree_map() {
         if (standard_info_type_tree_map == null) {
             standard_info_type_tree_map = new HashMap<>();

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4298 - 5152
nlp/src/main/resources/push-tc.dict


+ 72 - 0
nlp/src/main/resources/relation.dict

@@ -0,0 +1,72 @@
+RNMak3cFWH4=
+ddolNu+ruoI=
+crSKo8ZJQWw=
+z9odaTsZTe4=
+UtapbxnvICk=
+zCUYt/gJFTA=
+Zz6Ubw81PD0=
+yclD2AmKHJg=
+h4pBhb+B4Lk=
+8hKk85iZesU=
+0hgDIdsSBy4=
+rbTBQUekfEs=
+fxkh89TwKsc=
+ENBQhPq5htU=
+nK40VLls5Zw=
+hlUmDNbK6a4=
+rHRYnTdjAKA=
+5JujAdVP5E8=
+X2j2cnCysms=
+YEYDcVHi1BI=
+YLWWPYmlo7s=
+28BY78TjZOw=
+1zF5xvlmigE=
+5iH5AYe9ogQ=
+dCLIxiAaEPQ=
+nLmMNwLd9hU=
+KO6x8jrh1Go=
+PGU7FXe4EVw=
+Vt65EYLJtik=
+MowtsJaT+Eg=
+15XjiZKWWOQ=
+tvD9gnRGuE0=
+TS5FqQfA3Bo=
+8OTyr31+HZE=
+33mX5o5YCuI=
+eN8E9yHmcuQ=
+Wrhyd5KGRwU=
+oXEQgo+FISY=
+In0GOQRAoNc=
+WeQ7RhGnT3E=
+izBKC43U5Do=
+yIxj3i9brYw=
+6/AAsiRaYHk=
+d6U7t3U9wHI=
+N6s43nxbRgM=
+o15aELxdA/0=
+csWORUAoN0g=
+IheffyTAFTQ=
+URoSRuJSqzQ=
+Hu0VMvGeJYM=
+qi/diuSUvPk=
+2lkFuZbZfSo=
+sVfatV4286o=
+JxjFv6u9Xg0=
+GHAXRYXi1X4=
+3PiS9MWTEcU=
+h0qS3XYvg7w=
+exAkRV4R8YY=
+u6Lr+Jfr3PY=
+Slw/FnB9o4g=
+r7bymlovf1w=
+bSkSwBpuGHs=
+Xoa3vcFiseU=
+TXb4vMJd3ok=
+rc7iV++H97Y=
+itwdzE4pvKw=
+yuYZf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SYsqXiVgsJs3WzgRo2va1bm6p+Q5PjCbN1s4EaNr7aClMyVtRtE
 uKyAHyqaIxfXG+wCtdLL17s83OBoLlJqHqU5Lyx5fpKzbiZPFjI/BD+TziM2DqE3
-Si3i0N+haNjbxvLiNJw/h8k4LfnoNlE3
 P4WI8m/LWq3E9Q59E2C13NveCQfKaHmxcPdBYsgvPQg=
 wM+FgacqLJ/O8peESPke16l9UD9WNl4N5iLhPJLE63E2cff/jH5cKUpgEZ36UZf7
 b8nVx09fy5I4ol1WGH/UY00tZnoopWBlhKfxEUnLzjemS28QynV3zClyN7vDVREblwMFIsKVwg0=

+ 7 - 7
nlp/src/test/java/org/diagbot/nlp/test/EntityExtractTest.java

@@ -83,15 +83,15 @@ public class EntityExtractTest {
 
             if (results_pair.size() > 0) {
                 MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
-                nlpJdbc.insert(results_pair, "re_tagging_result_compare", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
+                nlpJdbc.insert(results_pair, "re_tagging_result_part_new", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
                         "entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
             }
 
-            if (results_none_pair.size() > 0) {
-                MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
-                nlpJdbc.insert(results_none_pair, "re_tagging_result_none_compare", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
-                        "entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
-            }
+//            if (results_none_pair.size() > 0) {
+//                MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
+//                nlpJdbc.insert(results_none_pair, "re_tagging_result_none_compare", new String[]{"sentence_id", "sentence_uuid", "sentence", "entity_1_position", "entity_2_position",
+//                        "entity_1_name", "entity_2_name", "entity_1_prop", "entity_2_prop", "entity_1_prop_name", "entity_2_prop_name", "relation"});
+//            }
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -132,7 +132,7 @@ public class EntityExtractTest {
 
     public List<Map<String, String>> searchData() {
         MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8");
-        List<Map<String, String>> data = nlpJdbc.query("tb_ryjl_extract", new String[]{"zyxh", "xbs"}, " limit 0, 3");
+        List<Map<String, String>> data = nlpJdbc.query("tb_ryjl_extract", new String[]{"zyxh", "xbs"}, " limit 3, 3");
         return data;
     }
 

+ 13 - 3
nlp/src/test/java/org/diagbot/nlp/test/LexemeDicTest.java

@@ -43,7 +43,7 @@ public class LexemeDicTest {
             }
             fw.close();
             //推送词典
-            sql = "select distinct name, category_id from kl_standard_info where status = 1 and category_id != 100 and category_id is not null && category is not null order by name";
+            sql = "select distinct name, category_id from kl_standard_info_0318 where status = 1 and category_id != 100 and category_id is not null && category is not null order by name";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
             libraryList = rsToMap(rs, true);
@@ -55,7 +55,7 @@ public class LexemeDicTest {
             }
             fw.close();
 
-            sql = "select distinct name, relation_name from kl_standard_info where relation_type = 2 and relation_name is not null order by name";
+            sql = "select distinct name, relation_name from kl_standard_info_0318 where relation_type = 2 and relation_name is not null order by name";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
 
@@ -68,7 +68,7 @@ public class LexemeDicTest {
             }
             fw.close();
 
-            sql = "select distinct name, relation_name from kl_standard_info where relation_type = 3 and relation_name is not null order by name";
+            sql = "select distinct name, relation_name from kl_standard_info_0318 where relation_type = 3 and relation_name is not null order by name";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
 
@@ -81,6 +81,16 @@ public class LexemeDicTest {
             }
             fw.close();
 
+            fw = new FileWriter(path + "src/main/resources/relation.dict");
+            sql = "select distinct prop1_id, prop2_id from re_lexicon_property_pair where has_relation = 1";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                fw.write(encrypDES.encrytor(rs.getString(1) + "|" + rs.getString(2)));
+                fw.write("\n");
+            }
+            fw.close();
+
         } catch (IOException ioe) {
             ioe.printStackTrace();
         } catch (SQLException sqle) {

+ 176 - 121
push-web/src/main/resources/static/pages/relation/sample.html

@@ -141,133 +141,169 @@
                     </div>
                     <!-- /.box -->
                 </div>
-                <!-- ./col -->
-            </div>
-            <!-- TABLE: LATEST ORDERS -->
-            <div class="box box-info">
-                <div class="box-header with-border">
-                    <h3 class="box-title">症状信息</h3>
-                    <div class="box-tools pull-right">
-                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
-                        </button>
-                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
-                    </div>
-                </div>
-                <!-- /.box-header -->
-                <div class="box-body">
-                    <div class="table-responsive">
-                        <table class="table no-margin">
-                            <thead>
-                            <tr>
-                                <th width="14%">症状</th>
-                                <th width="14%">时间</th>
-                                <th width="14%">性质</th>
-                                <th width="14%">诱因</th>
-                                <th width="14%">程度</th>
-                                <th width="14%">部位</th>
-                                <th width="16%">其他</th>
-                            </tr>
-                            </thead>
-                            <tbody id="symptom_extract_id">
-                            </tbody>
-                        </table>
-                    </div>
-                    <!-- /.table-responsive -->
-                </div>
-            </div>
-            <!-- /.box -->
-
-            <!-- TABLE: LATEST ORDERS -->
-            <div class="box box-info">
-                <div class="box-header with-border">
-                    <h3 class="box-title">体征信息</h3>
-                    <div class="box-tools pull-right">
-                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
-                        </button>
-                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
-                    </div>
-                </div>
-                <!-- /.box-header -->
-                <div class="box-body">
-                    <div class="table-responsive">
-                        <table class="table no-margin">
-                            <thead>
-                            <tr>
-                                <th width="20%">项目名称</th>
-                                <th width="20%">部位</th>
-                                <th width="20%">结果信息</th>
-                                <th width="20%">程度</th>
-                                <th width="20%">阴性标识</th>
-                            </tr>
-                            </thead>
-                            <tbody id="vital_extract_id">
-                            </tbody>
-                        </table>
+
+                <div class="col-md-12" style="height: 300px;overflow: auto">
+                    <!-- TABLE: LATEST ORDERS -->
+                    <div class="box box-info">
+                        <div class="box-header with-border">
+                            <h3 class="box-title">症状信息</h3>
+                            <div class="box-tools pull-right">
+                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
+                                </button>
+                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                        <!-- /.box-header -->
+                        <div class="box-body">
+                            <div class="table-responsive">
+                                <table class="table no-margin">
+                                    <thead>
+                                    <tr>
+                                        <th width="14%">症状</th>
+                                        <th width="14%">时间</th>
+                                        <th width="14%">性质</th>
+                                        <th width="14%">诱因</th>
+                                        <th width="14%">程度</th>
+                                        <th width="14%">部位</th>
+                                        <th width="16%">其他</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody id="symptom_extract_id">
+                                    </tbody>
+                                </table>
+                            </div>
+                            <!-- /.table-responsive -->
+                        </div>
                     </div>
-                    <!-- /.table-responsive -->
-                </div>
-            </div>
-            <!-- /.box -->
-
-            <!-- TABLE: LATEST ORDERS -->
-            <div class="box box-info">
-                <div class="box-header with-border">
-                    <h3 class="box-title">化验信息</h3>
-                    <div class="box-tools pull-right">
-                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
-                        </button>
-                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                    <!-- /.box -->
+
+                    <!-- TABLE: LATEST ORDERS -->
+                    <div class="box box-info">
+                        <div class="box-header with-border">
+                            <h3 class="box-title">体征信息</h3>
+                            <div class="box-tools pull-right">
+                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
+                                </button>
+                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                        <!-- /.box-header -->
+                        <div class="box-body">
+                            <div class="table-responsive">
+                                <table class="table no-margin">
+                                    <thead>
+                                    <tr>
+                                        <th width="20%">项目名称</th>
+                                        <th width="20%">部位</th>
+                                        <th width="20%">结果信息</th>
+                                        <th width="20%">程度</th>
+                                        <th width="20%">阴性标识</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody id="vital_extract_id">
+                                    </tbody>
+                                </table>
+                            </div>
+                            <!-- /.table-responsive -->
+                        </div>
                     </div>
-                </div>
-                <!-- /.box-header -->
-                <div class="box-body">
-                    <div class="table-responsive">
-                        <table class="table no-margin">
-                            <thead>
-                            <tr>
-                                <th width="20%">项目名称</th>
-                                <th width="20%">结果信息</th>
-                                <th width="60%">其他</th>
-                            </tr>
-                            </thead>
-                            <tbody id="lis_extract_id">
-                            </tbody>
-                        </table>
+                    <!-- /.box -->
+
+                    <!-- TABLE: LATEST ORDERS -->
+                    <div class="box box-info">
+                        <div class="box-header with-border">
+                            <h3 class="box-title">化验信息</h3>
+                            <div class="box-tools pull-right">
+                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
+                                </button>
+                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                        <!-- /.box-header -->
+                        <div class="box-body">
+                            <div class="table-responsive">
+                                <table class="table no-margin">
+                                    <thead>
+                                    <tr>
+                                        <th width="20%">项目名称</th>
+                                        <th width="20%">结果信息</th>
+                                        <th width="60%">其他</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody id="lis_extract_id">
+                                    </tbody>
+                                </table>
+                            </div>
+                            <!-- /.table-responsive -->
+                        </div>
                     </div>
-                    <!-- /.table-responsive -->
-                </div>
-            </div>
-            <!-- /.box -->
-
-            <!-- TABLE: LATEST ORDERS -->
-            <div class="box box-info">
-                <div class="box-header with-border">
-                    <h3 class="box-title">检查信息</h3>
-                    <div class="box-tools pull-right">
-                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
-                        </button>
-                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                    <!-- /.box -->
+
+                    <!-- TABLE: LATEST ORDERS -->
+                    <div class="box box-info">
+                        <div class="box-header with-border">
+                            <h3 class="box-title">检查信息</h3>
+                            <div class="box-tools pull-right">
+                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
+                                </button>
+                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                        <!-- /.box-header -->
+                        <div class="box-body">
+                            <div class="table-responsive">
+                                <table class="table no-margin">
+                                    <thead>
+                                    <tr>
+                                        <th width="20%">项目名称</th>
+                                        <th width="20%">结果信息</th>
+                                        <th width="60%">其他</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody id="pacs_extract_id">
+                                    </tbody>
+                                </table>
+                            </div>
+                            <!-- /.table-responsive -->
+                        </div>
                     </div>
-                </div>
-                <!-- /.box-header -->
-                <div class="box-body">
-                    <div class="table-responsive">
-                        <table class="table no-margin">
-                            <thead>
-                            <tr>
-                                <th width="20%">项目名称</th>
-                                <th width="20%">结果信息</th>
-                                <th width="60%">其他</th>
-                            </tr>
-                            </thead>
-                            <tbody id="pacs_extract_id">
-                            </tbody>
-                        </table>
+                    <!-- /.box -->
+
+                    <!-- TABLE: LATEST ORDERS -->
+                    <div class="box box-info">
+                        <div class="box-header with-border">
+                            <h3 class="box-title">治疗信息</h3>
+                            <div class="box-tools pull-right">
+                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
+                                </button>
+                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
+                            </div>
+                        </div>
+                        <!-- /.box-header -->
+                        <div class="box-body">
+                            <div class="table-responsive">
+                                <table class="table no-margin">
+                                    <thead>
+                                    <tr>
+                                        <th width="20%">用药</th>
+                                        <th width="20%">结果</th>
+                                        <th width="60%">其他</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody id="treat_extract_id">
+                                    </tbody>
+                                </table>
+                            </div>
+                            <!-- /.table-responsive -->
+                        </div>
                     </div>
-                    <!-- /.table-responsive -->
+                    <!-- /.box -->
                 </div>
+                <!-- ./col -->
             </div>
-            <!-- /.box -->
+
+
+
             <script>
                 function _ajax(url) {
                     $.support.cors = true;
@@ -292,6 +328,7 @@
                             var vital_h = "";
                             var lis_h = "";
                             var pacs_h = "";
+                            var treat_h = "";
                             $.each(outputInfos, function (index, outputInfo) {
                                 var symptoms = outputInfo.symptoms;
                                 if (symptoms != null) {
@@ -396,7 +433,7 @@
 
                                         lis_h += "<td>";
                                         if (lis.pd != null) {
-                                            lis_h += lis.pd.value;
+                                            lis_h += lis.pd.value + lis.pd.unit;
                                         }
                                         lis_h += "</td>";
 
@@ -424,6 +461,23 @@
                                         pacs_h += "</td><td></td></tr>";
                                     });
                                 }
+
+                                var treats = outputInfo.treats;
+                                if (treats != null) {
+                                    $.each(treats, function (treat_index, treat) {
+                                        treat_h += "<tr><td>";
+                                        if (treat.treatName != null) {
+                                            treat_h += treat.treatName;
+                                        }
+                                        treat_h += "</td>";
+
+                                        treat_h += "<td>";
+                                        if (treat.value != null) {
+                                            treat_h += treat.value;
+                                        }
+                                        treat_h += "</td><td></td></tr>";
+                                    });
+                                }
                             });
 
 
@@ -431,6 +485,7 @@
                             $("#vital_extract_id").html(vital_h);
                             $("#lis_extract_id").html(lis_h);
                             $("#pacs_extract_id").html(pacs_h);
+                            $("#treat_extract_id").html(treat_h);
                         }
                     });
                 };