Browse Source

关系抽取症状 时间判断 推送公共Bean抽取放入common-service模块

louhr 6 years ago
parent
commit
51bde9ef6d

+ 5 - 5
bigdata-web/src/main/java/org/diagbot/bigdata/controller/AlgorithmController.java

@@ -1,8 +1,8 @@
 package org.diagbot.bigdata.controller;
 
 import org.diagbot.bigdata.work.AlgorithmCore;
-import org.diagbot.bigdata.work.ResponseData;
-import org.diagbot.bigdata.work.SearchData;
+import org.diagbot.bigdata.work.BigDataSearchData;
+import org.diagbot.common.work.ResponseData;
 import org.diagbot.nlp.util.Constants;
 import org.diagbot.pub.api.Response;
 import org.diagbot.pub.web.BaseController;
@@ -21,17 +21,17 @@ public class AlgorithmController extends BaseController {
 
     @RequestMapping(value = "/page_neural")
     @ResponseBody
-    public Response<ResponseData> neuralData(HttpServletRequest request, SearchData searchData) throws Exception {
+    public Response<ResponseData> neuralData(HttpServletRequest request, BigDataSearchData searchData) throws Exception {
         return algorithm(request, searchData);
     }
 
     @RequestMapping(value = "/neural", method = RequestMethod.POST)
     @ResponseBody
-    public Response<ResponseData> bayesPageData(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
+    public Response<ResponseData> bayesPageData(HttpServletRequest request, @RequestBody BigDataSearchData searchData) throws Exception {
         return algorithm(request, searchData);
     }
 
-    public Response<ResponseData> algorithm(HttpServletRequest request, SearchData searchData) throws Exception {
+    public Response<ResponseData> algorithm(HttpServletRequest request, BigDataSearchData searchData) throws Exception {
         Response<ResponseData> response = new Response();
         AlgorithmCore core = new AlgorithmCore();
         ResponseData responseData = core.algorithm(request, searchData);

+ 3 - 1
bigdata-web/src/main/java/org/diagbot/bigdata/work/AlgorithmCore.java

@@ -3,6 +3,8 @@ package org.diagbot.bigdata.work;
 import org.algorithm.core.AlgorithmExecutor;
 import org.algorithm.factory.AlgorithmFactory;
 import org.algorithm.util.AlgorithmClassify;
+import org.diagbot.common.work.FeatureRate;
+import org.diagbot.common.work.ResponseData;
 import org.diagbot.nlp.feature.FeatureType;
 
 import javax.servlet.http.HttpServletRequest;
@@ -16,7 +18,7 @@ import java.util.*;
  * @Version 1.0
  **/
 public class AlgorithmCore {
-    public ResponseData algorithm(HttpServletRequest request, SearchData searchData) throws Exception {
+    public ResponseData algorithm(HttpServletRequest request, BigDataSearchData searchData) throws Exception {
         ResponseData responseData = new ResponseData();
         //录入文本处理,包括提取特征、推送类型转换等
         ParamsDataProxy paramsDataProxy = new ParamsDataProxy();

+ 27 - 0
bigdata-web/src/main/java/org/diagbot/bigdata/work/BigDataSearchData.java

@@ -0,0 +1,27 @@
+package org.diagbot.bigdata.work;
+
+import org.algorithm.util.AlgorithmClassify;
+import org.diagbot.common.work.SearchData;
+
+public class BigDataSearchData extends SearchData {
+    //模型
+    private AlgorithmClassify algorithmClassify[];
+    //模型
+    private String algorithmClassifyValue;
+
+    public AlgorithmClassify[] getAlgorithmClassify() {
+        return algorithmClassify;
+    }
+
+    public void setAlgorithmClassify(AlgorithmClassify[] algorithmClassify) {
+        this.algorithmClassify = algorithmClassify;
+    }
+
+    public String getAlgorithmClassifyValue() {
+        return algorithmClassifyValue;
+    }
+
+    public void setAlgorithmClassifyValue(String algorithmClassifyValue) {
+        this.algorithmClassifyValue = algorithmClassifyValue;
+    }
+}

+ 2 - 2
bigdata-web/src/main/java/org/diagbot/bigdata/work/ParamsDataProxy.java

@@ -20,7 +20,7 @@ import java.util.Map;
  * @Version 1.0
  **/
 public class ParamsDataProxy {
-    public void createSearchData(HttpServletRequest request, SearchData searchData) throws Exception {
+    public void createSearchData(HttpServletRequest request, BigDataSearchData searchData) throws Exception {
         //消除空格
         if (searchData.getSymptom() != null) {
             searchData.setSymptom(searchData.getSymptom().trim());
@@ -161,7 +161,7 @@ public class ParamsDataProxy {
      * @param featureType
      * @throws Exception
      */
-    private void paramFeatureInit(SearchData searchData, List<Map<String, Object>> featuresList, String property_list, FeatureType featureType) throws Exception {
+    private void paramFeatureInit(BigDataSearchData searchData, List<Map<String, Object>> featuresList, String property_list, FeatureType featureType) throws Exception {
         if (featuresList != null && featuresList.size() > 0) {
             BeanUtils.setProperty(searchData, property_list, featuresList);
             Map<String, String> map = new HashMap<>();

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

@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.diagbot.bigdata.common.ApplicationCacheUtil;
 import org.diagbot.bigdata.dao.model.ResultMappingFilter;
 import org.diagbot.bigdata.util.BigDataConstants;
+import org.diagbot.common.work.FeatureRate;
 import org.diagbot.nlp.feature.FeatureType;
 
 import javax.servlet.http.HttpServletRequest;
@@ -21,7 +22,7 @@ import java.util.Map;
  * @Version 1.0
  **/
 public class ResultDataProxy {
-    public List<FeatureRate> proxy(HttpServletRequest request, SearchData searchData, List<Map.Entry<String, Float>> featuresOrderList, String featureType) {
+    public List<FeatureRate> proxy(HttpServletRequest request, BigDataSearchData searchData, List<Map.Entry<String, Float>> featuresOrderList, String featureType) {
         int cursor = 1;
         DecimalFormat df = new DecimalFormat("0.####");
         List<FeatureRate> featureList = new ArrayList<>(10);
@@ -81,7 +82,7 @@ public class ResultDataProxy {
         return featureList;
     }
 
-    public boolean resultFilter(HttpServletRequest request, SearchData searchData, String featureType, String result, float threshold) {
+    public boolean resultFilter(HttpServletRequest request, BigDataSearchData searchData, String featureType, String result, float threshold) {
         //过滤录入条件中已有的特征信息
         if (searchData.getInputs().get(result) != null && FeatureType.parse(featureType) != FeatureType.DIAG) {
             return false;

+ 1 - 1
bigdata-web/src/main/java/org/diagbot/bigdata/work/FeatureRate.java

@@ -1,4 +1,4 @@
-package org.diagbot.bigdata.work;
+package org.diagbot.common.work;
 
 /**
  * Created by fyeman on 2018/1/17.

+ 1 - 1
bigdata-web/src/main/java/org/diagbot/bigdata/work/ResponseData.java

@@ -1,4 +1,4 @@
-package org.diagbot.bigdata.work;
+package org.diagbot.common.work;
 
 import java.util.ArrayList;
 import java.util.HashMap;

+ 18 - 40
bigdata-web/src/main/java/org/diagbot/bigdata/work/SearchData.java

@@ -1,38 +1,32 @@
-package org.diagbot.bigdata.work;
-
-import org.algorithm.util.AlgorithmClassify;
+package org.diagbot.common.work;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public class SearchData {
-    private int length = 10;
-    private int age_start = 0;
-    private int age_end = 200;
-    private int age = 0;
-    private String sex;
+    protected int length = 10;
+    protected int age_start = 0;
+    protected int age_end = 200;
+    protected int age = 0;
+    protected String sex;
     // 搜索结果的贝叶斯阈值
-    private String threshold = "0";
+    protected String threshold = "0";
     //特征类别
-    private String featureType;
+    protected String featureType;
     //特征类别对","进行分割后数据
-    private String[] featureTypes;
+    protected String[] featureTypes;
     //门诊 住院分类
-    private String resourceType;
-    //模型
-    private AlgorithmClassify algorithmClassify[];
-    //模型
-    private String algorithmClassifyValue;
+    protected String resourceType;
     //外部系统编码 用于返回映射数据,如果sysCode为空或null,则返回kl_standard_info标准名称
-    private String sysCode;
+    protected String sysCode;
 
-    private String symptom = "";
-    private String vital = "";
-    private String lis = "";
-    private String pacs = "";
-    private String diag = "";
-    private String past = "";
-    private String other = "";
+    protected String symptom = "";
+    protected String vital = "";
+    protected String lis = "";
+    protected String pacs = "";
+    protected String diag = "";
+    protected String past = "";
+    protected String other = "";
 
     private Map<String, Map<String, String>> inputs = new HashMap<>(10, 0.8f);
 
@@ -122,22 +116,6 @@ public class SearchData {
         this.inputs = inputs;
     }
 
-    public String getAlgorithmClassifyValue() {
-        return algorithmClassifyValue;
-    }
-
-    public void setAlgorithmClassifyValue(String algorithmClassifyValue) {
-        this.algorithmClassifyValue = algorithmClassifyValue;
-    }
-
-    public AlgorithmClassify[] getAlgorithmClassify() {
-        return algorithmClassify;
-    }
-
-    public void setAlgorithmClassify(AlgorithmClassify[] algorithmClassify) {
-        this.algorithmClassify = algorithmClassify;
-    }
-
     public String getSymptom() {
         return symptom;
     }

+ 22 - 5
nlp/src/main/java/org/diagbot/nlp/participle/ParticipleToken.java

@@ -32,7 +32,7 @@ public class ParticipleToken {
     //分词截止位置
     private int stop_position = 0;
     //字符不会被打断  即使词库中未找到对应词
-    private char[] join_symbols = new char[]{'~', '-', '/', '.', '*', '^'};
+    private char[] join_symbols = new char[]{'~', '-', '/', '.', '*', '^', '+'};
     //待分词数据包
     private Reader reader;
     //词库二叉树
@@ -104,8 +104,8 @@ public class ParticipleToken {
             //先依据词库是否成词判断
             this.matchCHN(segment, cursor, 0, false);
             //不成词所有英文字符拼接
-            if (cursor - offset <= 1 && this.property == null) {
-                this.matchARABIC();
+            if (cursor - offset <= 1) {
+                this.matchENGLISH();
             } else {
                 this.addLexeme(offset, cursor - offset, this.property);
                 this.offset = this.cursor;
@@ -132,12 +132,29 @@ public class ParticipleToken {
         int position;
         while (cursor < available) {
             position = Arrays.binarySearch(join_symbols, buffer[cursor]);
-            if (CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_ARABIC        //数字后跟英文、'-'、'/'、'.'作为数字处理
+            if (CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_ARABIC        //数字后跟'-'、'/'、'.'作为数字处理
 //                    || CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_ENGLISH
                     || position > -1) {
                 cursor++;
             } else if (CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_CHINESE) {    //数字后跟中文单位
-//                this.matchCHN(unit_segment, offset, 0, part_length, true);
+                break;
+            } else {
+                break;
+            }
+        }
+        this.addLexeme(this.offset, this.cursor - this.offset, this.ARABIC_PROPERTY);
+        this.offset = this.cursor;
+    }
+
+    private void matchENGLISH() throws IOException {
+        int position;
+        while (cursor < available) {
+            position = Arrays.binarySearch(join_symbols, buffer[cursor]);
+            if (CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_ENGLISH //英文拼接
+                    || position > -1
+                    || CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_ARABIC) {
+                cursor++;
+            } else if (CharacterUtil.identifyCharType(buffer[cursor]) == CharacterUtil.CHAR_CHINESE) {    //英文后跟中文单位
                 break;
             } else {
                 break;

+ 121 - 32
nlp/src/main/java/org/diagbot/nlp/participle/ParticipleUtil.java

@@ -5,11 +5,13 @@ import org.diagbot.nlp.participle.cfg.DefaultConfig;
 import org.diagbot.nlp.participle.word.Lexeme;
 import org.diagbot.nlp.participle.word.LexemePath;
 import org.diagbot.nlp.participle.word.Segment;
+import org.diagbot.nlp.util.Constants;
 import org.diagbot.nlp.util.NlpUtil;
 import org.diagbot.nlp.util.NlpCache;
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.util.regex.Pattern;
 
 /**
  * Created by fyeman on 2018/1/31.
@@ -18,35 +20,24 @@ public class ParticipleUtil {
 
     public static LexemePath<Lexeme> participle(String content, boolean isCombineUnit) throws IOException {
         LexemePath<Lexeme> lexemes = participle(content);
-
-        LexemePath<Lexeme> results = new LexemePath<>();
         if (isCombineUnit) {
-            Lexeme l = null;
-            Lexeme last_l = null;
-            for (int i = 0, len = lexemes.size(); i < len; i++) {
-                l = lexemes.get(i);
-                if (l.getProperty() != null && ("2".equals(l.getProperty()) || "9".equals(l.getProperty()))) {
-                    if (i > 0) {
-                        last_l = lexemes.get(i - 1);
-                        if (NlpUtil.isNumberString(last_l)) {
-                            last_l.setText(last_l.getText() + l.getText());
-                            last_l.setProperty(l.getProperty());
-                            last_l.setLength(last_l.getLength() +  l.getLength());
-
-                            results.remove(results.size() - 1);
-                            results.add(last_l);
-                        } else {
-                            results.add(l);
-                        }
-                    } else {
-                        results.add(l);
+            ParticipleUtil util = new ParticipleUtil();
+            lexemes = util.combineValidate(lexemes);
+            lexemes = util.joinTime(lexemes);
+
+            String year_pattern = "([1-2][0-9]{3}|[0-9]{2})";
+            String mouth_day_pattern = "([0-9]{2}|[0-9])";
+            String join_pattern = "([-/.]?)";
+            String pattern_string = year_pattern + join_pattern + mouth_day_pattern + join_pattern + mouth_day_pattern;
+            for (Lexeme l : lexemes) {
+                if (l.getProperty().equals(Constants.word_property_number)) {
+                    if (Pattern.matches(pattern_string,l.getText())) {
+                        l.setProperty(Constants.word_property_time);
                     }
-                } else {
-                    results.add(l);
                 }
             }
         }
-        return results;
+        return lexemes;
     }
 
     public static LexemePath<Lexeme> participle(String content) throws IOException {
@@ -77,19 +68,117 @@ public class ParticipleUtil {
         LexemePath<Lexeme> lexemePath = participle(content, true);
         String separator = "&nbsp;*&nbsp;";
         StringBuffer sb = new StringBuffer();
-        for (Lexeme lexeme : lexemePath) {
+        Lexeme lexeme = null;
+        boolean new_line = true;
+        for (int i = 0; i < lexemePath.size(); i++) {
+            lexeme = lexemePath.get(i);
             if (lexeme.getOffset() > -1) {
-                if (lexeme.getProperty() != null && !"99".equals(lexeme.getProperty())) {
-                    sb.append(separator);
-                    sb.append("<font color='blue'>");
+                if ("\r".equals(lexeme.getText()) || "\n".equals(lexeme.getText())) {
                     sb.append(lexeme.getText());
-                    sb.append("</font>");
+                    new_line = true;
                 } else {
-                    sb.append(separator);
-                    sb.append(lexeme.getText());
+                    if (!new_line) {
+                        sb.append(separator);
+                    }
+                    if (lexeme.getProperty() != null && !"99".equals(lexeme.getProperty())) {
+                        sb.append("<font color='blue'>");
+                        sb.append(lexeme.getText());
+                        sb.append("</font>");
+                    } else {
+                        sb.append(lexeme.getText());
+                    }
+                    new_line = false;
                 }
             }
         }
-        return sb.toString();
+        String s = sb.toString();
+        s = s.replaceAll("\r\n", "</br>");
+        return s;
+    }
+
+    public static void main(String args[]) {
+        String year_pattern = "([1-2][0-9]{3}|[0-9]{2})";
+        String mouth_day_pattern = "([0-9]{2}|[0-9])";
+        String join_pattern = "([-/.]?)";
+
+        String pattern_string = year_pattern + join_pattern + mouth_day_pattern + join_pattern + mouth_day_pattern;
+
+        System.out.println(Pattern.matches(pattern_string,"12.434"));
+        try {
+            ParticipleUtil util = new ParticipleUtil();
+            String content = "2017-01,9毫克7斤重量015年6月23日出现";
+            LexemePath<Lexeme> lexemes = util.participle(content);
+
+            lexemes = util.combineValidate(lexemes);
+
+            lexemes = util.joinTime(lexemes);
+            for (Lexeme l : lexemes) {
+                System.out.println(l.getText() + " | ");
+                if (l.getProperty().equals(Constants.word_property_number)) {
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private LexemePath<Lexeme> combineValidate(LexemePath<Lexeme> lexemes) {
+        Lexeme l = null;
+        LexemePath<Lexeme> results = new LexemePath<>();
+        for (int i = 0, len = lexemes.size(); i < len; i++) {
+            l = lexemes.get(i);
+            if (l.getProperty() != null
+                    && (l.getProperty().equals(Constants.word_property_time) || l.getProperty().equals(Constants.word_property_unit))) {
+                findLast(lexemes, i, l, results);
+            } else {
+                results.add(l);
+            }
+        }
+        return results;
+    }
+
+    private void findLast(LexemePath<Lexeme> lexemes, int index, Lexeme lexeme, LexemePath<Lexeme> results) {
+        Lexeme last_l = null;
+        if (index > 0) {
+            index--;
+            last_l = lexemes.get(index);
+            if (NlpUtil.isNumberString(last_l)) {
+                lexeme.setOffset(last_l.getOffset());
+                lexeme.setLength(last_l.getLength() + lexeme.getLength());
+                lexeme.setText(last_l.getText() + lexeme.getText());
+                results.remove(results.size() - 1);
+            }
+            results.add(lexeme);
+        }
+    }
+
+    private LexemePath<Lexeme> joinTime(LexemePath<Lexeme> lexemes) {
+        Lexeme l = null;
+        Lexeme next_l = null;
+        LexemePath<Lexeme> results = new LexemePath<>();
+        int cursor = 1;
+        for (int i = 0, len = lexemes.size(); i < len; i++) {
+            l = lexemes.get(i);
+            if (l.getProperty() != null
+                    && (l.getProperty().equals(Constants.word_property_time))) {
+                while (i + cursor < len) {
+                    next_l = lexemes.get(i + cursor);
+                    if (next_l.getProperty() != null
+                            && (next_l.getProperty().equals(Constants.word_property_time))) {
+                        l.setText(l.getText() + next_l.getText());
+                        l.setLength(l.getLength() + next_l.getLength());
+                        cursor++;
+                    } else {
+                        break;
+                    }
+                }
+            }
+            if (cursor > 1) {
+                i = i + cursor - 1;
+                cursor = 1;
+            }
+            results.add(l);
+        }
+        return results;
     }
 }

+ 33 - 7
nlp/src/main/java/org/diagbot/nlp/relation/extract/PresentExtract.java

@@ -75,13 +75,11 @@ public class PresentExtract extends BaseExtract {
         if (NlpUtil.isFeature(lemma.getProperty(), Constants.degree_type)) {
             Degree degree = new Degree();
             degree.setDegreeName(lemma.getText());
-            if (lemma.getRelationLemmas() != null) {
-                for (Lemma l : lemma.getRelationLemmas()) {
-                    if (NlpUtil.isFeature(l.getProperty(), Constants.unit_time_type)) {
-                        PD pd = new PD();
-                        pd.setValue(l.getText());
-                        degree.setPd(pd);
-                    }
+            for (Lemma l : lemma.getRelationLemmas()) {
+                if (NlpUtil.isFeature(l.getProperty(), Constants.unit_time_type)) {
+                    PD pd = new PD();
+                    pd.setValue(l.getText());
+                    degree.setPd(pd);
                 }
             }
             symptom.setDegree(degree);
@@ -105,5 +103,33 @@ public class PresentExtract extends BaseExtract {
             negative.setNegaName(lemma.getText());
             symptom.setNegative(negative);
         }
+
+        //体征指标
+        if (NlpUtil.isFeature(lemma.getProperty(), Constants.vital_index_type)) {
+            Item item = new Item();
+            item.setItemName(lemma.getText());
+            for (Lemma l : lemma.getRelationLemmas()) {
+                if (NlpUtil.isFeature(l.getProperty(), Constants.vital_type)) {
+                    Desc desc = new Desc();
+                    desc.setInfo(l.getText());
+                    item.setDesc(desc);
+                }
+            }
+            symptom.setItem(item);
+        }
+
+        //体征指标值 体征结果放入描述信息
+        if (NlpUtil.isFeature(lemma.getProperty(), Constants.vital_type)) {
+            Desc desc = new Desc();
+            desc.setInfo(lemma.getText());
+            for (Lemma l : lemma.getRelationLemmas()) {
+                if (NlpUtil.isFeature(l.getProperty(), Constants.degree_type)) {
+                    Degree degree = new Degree();
+                    degree.setDegreeName(l.getText());
+                    desc.setDegree(degree);
+                }
+            }
+            symptom.setDesc(desc);
+        }
     }
 }

+ 10 - 10
nlp/src/main/java/org/diagbot/nlp/relation/extract/cell/Desc.java

@@ -8,22 +8,22 @@ package org.diagbot.nlp.relation.extract.cell;
  * @Version 1.0
  **/
 public class Desc {
-    private String name;
-    private String value;
+    private String info;
+    private Degree degree;
 
-    public String getName() {
-        return name;
+    public String getInfo() {
+        return info;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public void setInfo(String info) {
+        this.info = info;
     }
 
-    public String getValue() {
-        return value;
+    public Degree getDegree() {
+        return degree;
     }
 
-    public void setValue(String value) {
-        this.value = value;
+    public void setDegree(Degree degree) {
+        this.degree = degree;
     }
 }

+ 10 - 0
nlp/src/main/java/org/diagbot/nlp/relation/extract/cell/Item.java

@@ -10,6 +10,8 @@ package org.diagbot.nlp.relation.extract.cell;
 public class Item {
     private String itemName;
 
+    private Desc desc;
+
     public String getItemName() {
         return itemName;
     }
@@ -17,4 +19,12 @@ public class Item {
     public void setItemName(String itemName) {
         this.itemName = itemName;
     }
+
+    public Desc getDesc() {
+        return desc;
+    }
+
+    public void setDesc(Desc desc) {
+        this.desc = desc;
+    }
 }

+ 18 - 0
nlp/src/main/java/org/diagbot/nlp/relation/extract/module/Symptom.java

@@ -19,6 +19,8 @@ public class Symptom {
     private Property property;
     private PD pd;
     private Factor factor;
+    private Item item;
+    private Desc desc;
 
     public String getSymptomName() {
         return symptomName;
@@ -83,4 +85,20 @@ public class Symptom {
     public void setFactor(Factor factor) {
         this.factor = factor;
     }
+
+    public Item getItem() {
+        return item;
+    }
+
+    public void setItem(Item item) {
+        this.item = item;
+    }
+
+    public Desc getDesc() {
+        return desc;
+    }
+
+    public void setDesc(Desc desc) {
+        this.desc = desc;
+    }
 }

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

@@ -31,4 +31,8 @@ public class Constants {
     public static NegativeEnum[] negative_type = new NegativeEnum[]{NegativeEnum.FEMININE};
 
     public static String[] negative_words = new String[]{"无", "未", "未及", "无殊", "否认", "未见", "不", "未闻", "未闻及", "欠"};
+
+    public final static String word_property_time = "2";
+    public final static String word_property_unit = "9";
+    public final static String word_property_number = "35";
 }

+ 0 - 11
nlp/src/main/resources/synonym.dict

@@ -443,7 +443,6 @@ pO2|血氧分压
 上腹部不适|腹部不适
 上腹部增强+MRCP|上腹部MRI增强,上腹部MRCP
 上腹部平扫+MRCP|上腹部MRI平扫,上腹部MRCP
-上腹部疼痛|上腹痛
 上腹部胀痛|腹胀痛
 上腹部隐痛|上腹痛
 上腹闷胀|腹胀
@@ -552,7 +551,6 @@ pO2|血氧分压
 下腔静脉栓塞|下肢下腔静脉栓塞
 下腹坠胀|下腹坠胀感
 下腹痛(可疑)|下腹痛
-下腹胀|下腹腹胀
 下腹部坠胀感|下腹坠胀感
 下腹部肿块|腹部包块
 下运动神经元瘫痪|软瘫
@@ -1931,7 +1929,6 @@ pO2|血氧分压
 哮喘(可疑)|支气管哮喘
 哮喘(可疑)(可疑)|支气管哮喘
 哮喘持续状态|支气管哮喘
-哮喘病|支气管哮喘
 哽噎感|哽咽感
 唇沟消失|鼻唇沟变浅
 唇畸形|口唇畸形
@@ -2276,7 +2273,6 @@ pO2|血氧分压
 大便潜血(可疑)|大便潜血
 大便燥结|大便干燥
 大便硬结|大便干燥
-大便稀|便溏
 大便稀水样|大便稀
 大便稀溏|便溏
 大便结燥|大便干燥
@@ -4087,7 +4083,6 @@ APCA
 浅静脉抽剥|浅静脉抽剥术
 测定酸碱度|酸碱度
 测血压偏低|血压降低
-测血压偏高|血压升高
 测血压升高|血压升高
 浑身乏力|乏力
 浑身酸痛|全身酸痛
@@ -5722,7 +5717,6 @@ APCA
 肛门瘙痒|肛周瘙痒
 肛门瘙痒症(可疑)|肛门瘙痒症
 肛门神经传导速度检测+肌电图检查|神经传导速度检测+肌电图检查(肛门括约肌)
-肛门肿|肛门肿胀
 肛门胀|肛门肿胀
 肛门脓肿|肛周脓肿
 肛门阻塞感|排便阻塞感
@@ -6365,7 +6359,6 @@ APCA
 胆道疾患(可疑)|胆道疾患
 胆道疾患(术后)|胆道疾患
 背疼|背痛
-背疼痛|背痛
 背部增宽|水牛背
 背部疼|背痛
 背部疼痛|背痛
@@ -6382,7 +6375,6 @@ APCA
 胎儿系统彩色多普勒超声检查|常规胎儿彩超检查
 胎动如常|胎动正常
 胎心监护+声刺激|胎心监护,声刺激
-胚移植|胚移植术
 胚胎停止发育(术前)|胚胎停止发育
 胚胎发育不良(可疑)|胚胎发育不良
 胚胎发育不良(术前)|胚胎发育不良
@@ -6910,7 +6902,6 @@ APCA
 腱鞘脓肿(可疑)|腱鞘脓肿
 腱鞘脓肿(术前)|腱鞘脓肿
 腱鞘脓肿(术后)|腱鞘脓肿
-腹不适|腹部不适
 腹主动脉MR增强|腹主动脉MRI增强
 腹主动脉X线检查|腹主动脉X线
 腹主动脉动脉瘤(可疑)|腹主动脉动脉瘤
@@ -7004,14 +6995,12 @@ APCA
 腹部恶性肿瘤(术后)|腹部恶性肿瘤
 腹部溃疡|皮肤溃疡
 腹部满闷不舒|脘腹满闷不舒
-腹部疼痛|腹痛
 腹部肿块|腹部包块
 腹部肿块切除|腹部肿块切除术
 腹部肿物(可疑)|腹部肿物
 腹部肿物(术前)|腹部肿物
 腹部肿物(术后)|腹部肿物
 腹部肿物切除|腹部肿物切除术
-腹部胀痛|腹胀痛
 腹部钝痛|腹钝痛
 腹部隐痛|腹隐痛
 腹隆起|腹膨隆

File diff suppressed because it is too large
+ 165 - 167
nlp/src/main/resources/tc.dict


+ 23 - 16
nlp/src/test/java/org/diagbot/nlp/test/ParticipleTest.java

@@ -25,29 +25,36 @@ public class ParticipleTest {
         try {
             String content = "剑突下痛胀痛1天,";
             ParticipleTest test = new ParticipleTest();
-//            InputStream is = test.getClass().getClassLoader().getResourceAsStream("present.txt");
-//            BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512);
-//
-//            String line="";
-//            StringBuffer  buffer = new StringBuffer();
-//            while((line=br.readLine())!=null){
-//                buffer.append(line);
-//            }
-//            content = buffer.toString();
+            InputStream is = test.getClass().getClassLoader().getResourceAsStream("present.txt");
+            BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512);
+
+            String line="";
+            StringBuffer  buffer = new StringBuffer();
+            while((line=br.readLine())!=null){
+                buffer.append(line);
+            }
+            content = buffer.toString();
 
             long start = System.currentTimeMillis();
 
 //            Configuration configuration = new DefaultConfig();
 //            Segment segment = configuration.loadMainDict("tc.dict");
 
-            List<Lexeme> lexemes = ParticipleUtil.participle(content, true);
+            List<Lexeme> lexemes = ParticipleUtil.participle(content, false);
             String result = "";
-            for (Lexeme lexeme : lexemes) {
-                if (lexeme.getOffset() > -1) {
-                    result = result + " | " + lexeme.getText();
-                }
-            }
-            System.out.println(JSON.toJSONString(lexemes));
+//            for (Lexeme lexeme : lexemes) {
+//                if (lexeme.getOffset() > -1) {
+//                    result = result + " | " + lexeme.getText();
+//                }
+//            }
+            long end = System.currentTimeMillis();
+
+            start = System.currentTimeMillis();
+            lexemes = ParticipleUtil.participle(content, false);
+            end = System.currentTimeMillis();
+
+            System.out.println(end - start);
+//            System.out.println(JSON.toJSONString(lexemes));
 //            ParticipleToken token = new ParticipleToken();
 //            token.start(new StringReader(content), segment);
 //            LexemePath<Lexeme> lexemePath = token.getLexemePath();

+ 16 - 0
push-web/src/main/resources/static/pages/relation/sample.html

@@ -183,6 +183,22 @@
                                             h += "<dd>" + symptom.negative.negaName + "</dd>";
                                             hasProp = true;
                                         }
+                                        if (symptom.item != null) {
+                                            if (symptom.item.desc != null) {
+                                                h += "<dd>" + symptom.item.itemName + "(" + symptom.item.desc.info + ")</dd>";
+                                            } else {
+                                                h += "<dd>" + symptom.item.itemName + "</dd>";
+                                            }
+                                            hasProp = true;
+                                        }
+                                        if (symptom.desc != null) {
+                                            if (symptom.desc.degree != null) {
+                                                h += "<dd>" + symptom.desc.info + "(" + symptom.item.degree.degreeName + ")</dd>";
+                                            } else {
+                                                h += "<dd>" + symptom.desc.info + "</dd>";
+                                            }
+                                            hasProp = true;
+                                        }
                                         if (hasProp == false) {
                                             h += "<dd></dd>";
                                         }