浏览代码

正则规则优化3

wangfeng 4 年之前
父节点
当前提交
255da7034b

+ 1 - 18
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -93,24 +93,7 @@ public class IndicationFacade {
         }
         CoreUtil.getDebugStr(crfStart, "模型处理耗时", debug);
         //正则匹配开始
-        String symptom = wordCrfDTO.getSymptom();
-        RegularConfigDataVO  regularConfigData= new RegularConfigDataVO();
-        regularConfigData.setText(symptom);
-        List<RegularValueDTO> regularConfigDatas = sysRegularConfigFacade.getRegularConfigDatas(regularConfigData);
-        List<Lis> lisData = wordCrfDTO.getLis();
-        if(ListUtil.isNotEmpty(regularConfigDatas)){
-            for(RegularValueDTO data:regularConfigDatas){
-                if(data.getType().equals(RegularConfigEnum.lis.getKey())){
-                    Lis lis = new Lis();
-                    lis.setUniqueName(data.getKey());
-                    lis.setDetailName(data.getKey());
-                    lis.setName(data.getKey());
-                    lis.setValue(Double.valueOf(data.getValue()));
-                    lisData.add(lis);
-                }
-            }
-        }
-        wordCrfDTO.setLis(lisData);
+        wordCrfDTO = sysRegularConfigFacade.getRegularConfigs(wordCrfDTO);
         //正则匹配结束
         // 标准词转换
         long standStart = System.currentTimeMillis();

+ 41 - 3
src/main/java/com/diagbot/facade/SysRegularConfigFacade.java

@@ -2,10 +2,14 @@ package com.diagbot.facade;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.RegularValueDTO;
+import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.entity.SysRegularConfig;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.RegularConfigEnum;
+import com.diagbot.model.entity.Allergy;
+import com.diagbot.model.label.PastLabel;
 import com.diagbot.service.impl.SysRegularConfigServiceImpl;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.RegularConfigDataVO;
@@ -35,16 +39,15 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
             for (SysRegularConfig data : regularConfigs) {
                 String pattern = data.getRulesValue();
                 // 创建 Pattern 对象
-                Pattern r = Pattern.compile(pattern);
+                Pattern r = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
                 // 现在创建 matcher 对象
                 Matcher m = r.matcher(regularConfigDataVO.getText());
                 while (m.find()) {
                     //System.out.println(m.group());
                     String steing = m.group();
-                    String key ="";
                     String value = "";
                     Integer type = data.getRulesTepy();
-                    if(data.getRulesTepy().equals(RegularConfigEnum.lis.getKey())){
+                    if (data.getRulesTepy().equals(RegularConfigEnum.lis.getKey())) {
                         value = steing.replaceAll("([^\\d\\.]|\\.(?=[^\\.]*\\.))", "");
                     }
                     RegularValueDTO regularValueDTO = new RegularValueDTO();
@@ -59,4 +62,39 @@ public class SysRegularConfigFacade extends SysRegularConfigServiceImpl {
         return listData;
     }
 
+    /**
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    public WordCrfDTO getRegularConfigs(WordCrfDTO wordCrfDTO) {
+        String symptom = wordCrfDTO.getSymptom();
+        RegularConfigDataVO regularConfigData = new RegularConfigDataVO();
+        regularConfigData.setText(symptom);
+        List<RegularValueDTO> regularConfigDatas = getRegularConfigDatas(regularConfigData);
+        List<Lis> lisData = wordCrfDTO.getLis();
+        PastLabel pastLabel = wordCrfDTO.getPastLabel();//获取过敏史数据
+        List<Allergy> allergies = pastLabel.getAllergies();
+        if (ListUtil.isNotEmpty(regularConfigDatas)) {
+            for (RegularValueDTO data : regularConfigDatas) {
+                if (data.getType().equals(RegularConfigEnum.lis.getKey())) {
+                    Lis lis = new Lis();
+                    lis.setUniqueName(data.getKey());
+                    lis.setDetailName(data.getKey());
+                    lis.setName(data.getKey());
+                    lis.setValue(Double.valueOf(data.getValue()));
+                    lisData.add(lis);
+                }else if(data.getType().equals(RegularConfigEnum.allergy.getKey())){
+                    Allergy allergy = new Allergy();
+                    allergy.setName(data.getKey());
+                    allergy.setStandName(data.getKey());
+                    allergies.add(allergy);
+                }
+            }
+        }
+        pastLabel.setAllergies(allergies);
+        wordCrfDTO.setPastLabel(pastLabel);
+        wordCrfDTO.setLis(lisData);
+        return wordCrfDTO;
+    }
 }