Browse Source

更新分词准确性

MarkHuang 6 years ago
parent
commit
3fc7047f98

+ 57 - 22
nlp/src/main/java/org/diagbot/nlp/relation/analyze/StructureAnalyze.java

@@ -37,10 +37,11 @@ public class StructureAnalyze {
     private static Object current_treat = null;
     private static String current_diag = "";
     private static BodyPart bodyPart = null;
+    private static Negative negative = null;
     private static String num = "";
     private static String pacs_content = "";
     private static List<String> diag_con = Arrays.asList("门诊","诊断","入院","拟");
-    private static List<String> past_con = Arrays.asList("既往","史");
+    private static List<String> past_con = Arrays.asList("既往","史","病史");
     private static String colon = ":|:|提示|示";
     private static String note = "";
 
@@ -110,6 +111,7 @@ public class StructureAnalyze {
 
 
     public void preprocess(String token, String note) {
+
     }
 
     public void postprocess(String token, OutputInfo outputInfo) {
@@ -288,28 +290,33 @@ public class StructureAnalyze {
                     }
                     break;
                 case Constants.word_property_neg:
-                    Negative negative = new Negative();
+                    negative = new Negative();
                     negative.setNegaName(lexeme.getText());
-                    symptom.setNegative(negative);
+//                    symptom.setNegative(negative);
                     updated = true;
                     break;
                 case Constants.word_property_timestamp:
                     PD pd = new PD();
                     pd.setValue(lexeme.getText());
                     pd.setUnit("");
-                    List<PD> pds = new ArrayList<>();
-                    pds.add(pd);
                     if (current instanceof Symptom) {
                         symptom = (Symptom)current;
                     }
                     else if (current == null && outputInfo.getSymptoms().get(0).getSymptomName() == "") {
                         symptom = outputInfo.getSymptoms().get(0);
                     }
-                    if (symptom != null) {
+                    if (symptom.getTimestamp() == null) {
+                        List<PD> pds = new ArrayList<>();
+                        pds.add(pd);
                         symptom.setTimestamp(pds);
-                        updated = true;
-                        current = symptom;
                     }
+                    else {
+                        List<PD> pds = symptom.getTimestamp();
+                        pds.add(pd);
+                    }
+                    updated = true;
+                    current = symptom;
+
                     break;
                 case Constants.word_property_freq:
                 case Constants.word_property_number:
@@ -406,6 +413,7 @@ public class StructureAnalyze {
                     updated = true;
                     break;
                 case Constants.word_property_other:
+                default:
                     if (diag_con.indexOf(lexeme.getText()) >= 0) {
                         outputInfo.getTreats().add(new Treat());
                         treat = outputInfo.getTreats().get(outputInfo.getTreats().size() - 1);
@@ -421,6 +429,10 @@ public class StructureAnalyze {
                             outputInfo.getPasts().add(new Past());
                         }
                         past = outputInfo.getPasts().get(outputInfo.getPasts().size() - 1);
+                        if (current_diag != "") {
+                            past.setDiagnose(current_diag);
+                            current_diag = "";
+                        }
                         current = past;
                     }
                     break;
@@ -460,6 +472,19 @@ public class StructureAnalyze {
     }
 
 
+    public Boolean checkSymptom(Symptom symptom) {
+        Boolean isfilled = false;
+
+        if (symptom.getSymptomName().trim().length() > 0 || symptom.getNegative() != null
+                || symptom.getProperty() != null || symptom.getCause() != null
+                || symptom.getBodyPart() != null || symptom.getDegree() != null
+                || symptom.getTimestamp() != null || symptom.getPds() != null) {
+            isfilled = true;
+        }
+        return isfilled;
+    }
+
+
     public Object updateClinicalInfo(OutputInfo outputInfo, String name, String type) {
 
         Object obj = null;
@@ -479,6 +504,11 @@ public class StructureAnalyze {
                     symptom.setSymptomName(symptom.getSymptomName() + ", " + name);
                 }
 
+                if (negative != null) {
+                    symptom.setSymptomName(negative.getNegaName()+symptom.getSymptomName());
+                    negative = null;
+                }
+
                 obj = symptom;
                 break;
             case Constants.word_property_vital_idx:
@@ -540,12 +570,12 @@ public class StructureAnalyze {
                 Cause cause = new Cause();
                 cause.setCauseName(name);
 
-                if (current instanceof Symptom) {
-                    symptom = (Symptom)current;
-                }
-                else {
+//                if (current instanceof Symptom) {
+//                    symptom = (Symptom)current;
+//                }
+//                else {
                     symptom = outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1);
-                }
+//                }
 
                 if (symptom.getCause() != null) {
                     if (!outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1).getSymptomName().equals(symptom.getSymptomName())) {
@@ -563,12 +593,12 @@ public class StructureAnalyze {
                 Degree degree = new Degree();
                 degree.setDegreeName(name);
 
-                if (current instanceof Symptom) {
-                    symptom = (Symptom)current;
-                }
-                else {
+//                if (current instanceof Symptom) {
+//                    symptom = (Symptom)current;
+//                }
+//                else {
                     symptom = outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1);
-                }
+//                }
 
                 if (symptom.getDegree() != null) {
                     if (!outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1).getSymptomName().equals(symptom.getSymptomName())) {
@@ -584,12 +614,17 @@ public class StructureAnalyze {
                 Property property = new Property();
                 property.setPropertyName(name);
 
-                if (current instanceof Symptom) {
-                    symptom = (Symptom)current;
+                if (negative != null) {
+                    property.setPropertyName(negative.getNegaName()+property.getPropertyName());
+                    negative = null;
                 }
-                else {
+
+//                if (current instanceof Symptom) {
+//                    symptom = (Symptom)current;
+//                }
+//                else {
                     symptom = outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1);
-                }
+//                }
 
                 if (symptom.getProperty() != null) {
                     if (!outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1).getSymptomName().equals(symptom.getSymptomName())) {

+ 1 - 1
nlp/src/main/resources/tc.dict

@@ -227383,7 +227383,7 @@ OESGBHsLKOW7CNtH1H6ERh+7hMs2K1HzSmARnfpRl/s=
 gBfJANxfJVmIpWDaZmeTXo3HGKvS4WAC
 Kwoho6f+JnkhcyLCPGT0hxLm/Su78Csu
 9V3L0qWDN2KIpWDaZmeTXlj64JCLG1kT
-HWvdZwymY7DTcycghkRvrvE/6oXNoKS/5opE3Fvtcpc=
+HWvdZwymY7CIpWDaZmeTXpRs+QR/TraH
 KWQF9s4VXgh2alpq3Hf1b1yWtZYK62oNqyADOAHZsjM=
 ZkdV7qOSHEeUEckvewcmoPgcqHjjjgwqG72qJ7RSZ0ppYYVnNruUWA==
 ZkdV7qOSHEevtKVvxRvQCVyWtZYK62oNmzf01B6boBU=

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

@@ -380,7 +380,7 @@
                                             h += "<td>";
                                             if (symptom.timestamp != null) {
                                                 $.each(symptom.timestamp, function (ts_index, ts) {
-                                                    h += ts.value + ts.unit + " ";
+                                                    h += ts.value + ts.unit + ", ";
                                                 });
                                             }
                                             h += "</td>";