Просмотр исходного кода

更新分词显示效果,更新对部位的处理

MarkHuang 6 лет назад
Родитель
Сommit
36981fca60

+ 32 - 0
nlp/src/main/java/org/diagbot/nlp/relation/analyze/StructureAnalyze.java

@@ -35,6 +35,7 @@ public class StructureAnalyze {
     private static boolean updated = false;
     private static Object current = null;
     private static Object current_treat = null;
+    private static BodyPart bodyPart = null;
     private static String num = "";
     private static List<String> diag_con = Arrays.asList("门诊","诊断");
     private static List<String> past_con = Arrays.asList("既往");
@@ -68,6 +69,8 @@ public class StructureAnalyze {
                         (getPropsize(outputInfo) == 1 && outputInfo.getSymptoms().get(0).getSymptomName().trim().length() == 0)){
                     outputInfos.remove(outputInfos.size() - 1);
                 }
+
+                bodyPart = null;
             }
         }
         catch (IOException ioe) {
@@ -121,6 +124,29 @@ public class StructureAnalyze {
                 case Constants.word_property_vital_result:
                     current = updateClinicalInfo(outputInfo, lexeme.getText(), lexeme.getProperty());
                     updated = true;
+                    if (bodyPart != null) {
+                        switch (lexeme.getProperty()) {
+                            case Constants.word_property_symptom:
+                                if (current instanceof Symptom) {
+                                    ((Symptom)current).setBodyPart(bodyPart);
+                                    bodyPart = null;
+                                }
+                                break;
+                            case Constants.word_property_vital_idx:
+                            case Constants.word_property_vital_result:
+                                if (current instanceof Vital) {
+                                    ((Vital)current).setBodyPart(bodyPart);
+                                    bodyPart = null;
+                                }
+                                break;
+                            case Constants.word_property_PACS:
+                                if (current instanceof Pacs) {
+                                    ((Pacs)current).setBodypart(bodyPart.getPartBodyName());
+                                    bodyPart = null;
+                                }
+                                break;
+                        }
+                    }
                     break;
                 case Constants.word_property_vital_value:
                     if (current instanceof Vital) {
@@ -170,6 +196,12 @@ public class StructureAnalyze {
                     }
                     break;
                 case Constants.word_property_bodypart:
+                    if (bodyPart == null) {
+                        bodyPart = new BodyPart();
+                        bodyPart.setPartBodyName(lexeme.getText());
+                        updated = true;
+                    }
+                    break;
                 case Constants.word_property_direction:
                     if (current instanceof Pacs) {
                         if (((Pacs)current).getBodypart()==null) {