Browse Source

Merge remote-tracking branch 'origin/push-dev-pacs' into push-debug

louhr 6 years ago
parent
commit
af8912af40

+ 12 - 0
common-push/src/main/java/org/diagbot/common/push/cache/CacheFileManager.java

@@ -163,6 +163,18 @@ public class CacheFileManager {
 
 
             fw = new FileWriter(path + "classify.dict");
             fw = new FileWriter(path + "classify.dict");
             fw.close();
             fw.close();
+
+            sql = "select name, type from kl_library_info_pacs order by name";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            fw = new FileWriter(path + "pacs-tc.dict");
+            while (rs.next()) {
+                r1 = rs.getString(1);
+                r2 = rs.getString(2);
+                fw.write(encrypDES.encrytor(r1 + "|9|"+ r2 + "|" + r1));
+                fw.write("\n");
+            }
+            fw.close();
         } catch (IOException ioe) {
         } catch (IOException ioe) {
             ioe.printStackTrace();
             ioe.printStackTrace();
         } catch (SQLException sqle) {
         } catch (SQLException sqle) {

+ 31 - 14
nlp/src/main/java/org/diagbot/nlp/participle/ParticipleUtil.java

@@ -23,20 +23,7 @@ public class ParticipleUtil {
         LexemePath<Lexeme> lexemes = participle(content);
         LexemePath<Lexeme> lexemes = participle(content);
         if (isCombineUnit) {
         if (isCombineUnit) {
             ParticipleUtil util = new ParticipleUtil();
             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);
-                    }
-                }
-            }
+            util.combine(util, lexemes);
         }
         }
         return lexemes;
         return lexemes;
     }
     }
@@ -48,6 +35,19 @@ public class ParticipleUtil {
         return participle(content, NlpCache.segment_cache);
         return participle(content, NlpCache.segment_cache);
     }
     }
 
 
+    public static LexemePath<Lexeme> participlePacs(String content) throws IOException {
+        if (NlpCache.segment_cache_pacs == null) {
+            NlpCache.createSegmentCachePacs();
+        }
+        ParticipleToken token = new ParticipleToken();
+        token.start(new StringReader(content), NlpCache.segment_cache_pacs);
+        LexemePath<Lexeme> lexemePath = token.getLexemePath();
+        ParticipleUtil util = new ParticipleUtil();
+        util.combine(util, lexemePath);
+        token.end();
+        return lexemePath;
+    }
+
     public static LexemePath<Lexeme> participle(String content, String path) throws IOException {
     public static LexemePath<Lexeme> participle(String content, String path) throws IOException {
         Configuration configuration = new DefaultConfig();
         Configuration configuration = new DefaultConfig();
         NlpCache.segment_cache = configuration.loadMainDict(path);
         NlpCache.segment_cache = configuration.loadMainDict(path);
@@ -65,6 +65,23 @@ public class ParticipleUtil {
         return lexemePath;
         return lexemePath;
     }
     }
 
 
+    private void combine(ParticipleUtil util, LexemePath<Lexeme> lexemes) {
+        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);
+                }
+            }
+        }
+    }
+
     public static String participleAndHighlight(String content) throws IOException {
     public static String participleAndHighlight(String content) throws IOException {
         LexemePath<Lexeme> lexemePath = participle(content, false);
         LexemePath<Lexeme> lexemePath = participle(content, false);
         String separator = "&nbsp;*&nbsp;";
         String separator = "&nbsp;*&nbsp;";

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

@@ -49,7 +49,7 @@ public class Constants {
             "神清","神志清","睡眠可","精神可","精神佳","二便无殊","体重无明显减轻","睡眠一般","小便无殊","大便无殊","胃纳可","食欲可"
             "神清","神志清","睡眠可","精神可","精神佳","二便无殊","体重无明显减轻","睡眠一般","小便无殊","大便无殊","胃纳可","食欲可"
     };
     };
 
 
-    public final static String word_property_timestamp = "74";
+    public final static String word_property_timestamp = "40";
     public final static String word_property_symptom = "1";
     public final static String word_property_symptom = "1";
     public final static String word_property_bodypart = "3";
     public final static String word_property_bodypart = "3";
     public final static String word_property_prop = "4";
     public final static String word_property_prop = "4";
@@ -57,7 +57,7 @@ public class Constants {
     public final static String word_property_degree = "6";
     public final static String word_property_degree = "6";
     public final static String word_property_neg = "7";
     public final static String word_property_neg = "7";
     public final static String word_property_med = "53";
     public final static String word_property_med = "53";
-    public final static String word_property_medcom = "54";
+    public final static String word_property_med_com = "54";
     public final static String word_property_treat = "11";
     public final static String word_property_treat = "11";
     public final static String word_property_LIS = "12";
     public final static String word_property_LIS = "12";
     public final static String word_property_LIS_Detail = "13";
     public final static String word_property_LIS_Detail = "13";

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

@@ -16,6 +16,8 @@ import java.util.*;
 public class NlpCache {
 public class NlpCache {
     //词典库
     //词典库
     public static Segment segment_cache = null;
     public static Segment segment_cache = null;
+    //词典库
+    public static Segment segment_cache_pacs = null;
     //推送字典
     //推送字典
     public static Map<String, String> standard_info_push_map = null;
     public static Map<String, String> standard_info_push_map = null;
     //词库同义词定义
     //词库同义词定义
@@ -34,6 +36,11 @@ public class NlpCache {
         segment_cache = configuration.loadMainDict( "tc.dict");
         segment_cache = configuration.loadMainDict( "tc.dict");
     }
     }
 
 
+    public static void createSegmentCachePacs() {
+        Configuration configuration = new DefaultConfig();
+        segment_cache_pacs = configuration.loadMainDict("pacs-tc.dict");
+    }
+
     public static void createPushCache() {
     public static void createPushCache() {
         Configuration configuration = new DefaultConfig();
         Configuration configuration = new DefaultConfig();
         standard_info_push_map = configuration.loadMapDict( "push-tc.dict");
         standard_info_push_map = configuration.loadMapDict( "push-tc.dict");
@@ -120,6 +127,13 @@ public class NlpCache {
         return segment_cache;
         return segment_cache;
     }
     }
 
 
+    public static Segment getSegment_cache_pacs() {
+        if (segment_cache_pacs == null) {
+            createSegmentCachePacs();
+        }
+        return segment_cache_pacs;
+    }
+
     public static Map<String, String> getStandard_info_push_map() {
     public static Map<String, String> getStandard_info_push_map() {
         if (standard_info_push_map == null) {
         if (standard_info_push_map == null) {
             createPushCache();
             createPushCache();

+ 11 - 0
push-web/src/main/java/org/diagbot/push/controller/ParticipleController.java

@@ -20,6 +20,17 @@ public class ParticipleController extends BaseController {
         return listView;
         return listView;
     }
     }
 
 
+    @ResponseBody
+    @RequestMapping("/split_pacs")
+    public Response split(String content) throws IOException {
+        Response response = new Response();
+        long start = System.currentTimeMillis();
+        response.setData(ParticipleUtil.participlePacs(content));
+        long end = System.currentTimeMillis();
+        System.out.println("总耗时:........." + (end - start));
+        return response;
+    }
+
     @ResponseBody
     @ResponseBody
     @RequestMapping("/split_and_highlight")
     @RequestMapping("/split_and_highlight")
     public Response splitAndHighlight(String content) throws IOException {
     public Response splitAndHighlight(String content) throws IOException {