|
@@ -16,6 +16,7 @@ import org.diagbot.nlp.util.Constants;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static org.diagbot.nlp.participle.ParticipleUtil.participle;
|
|
@@ -30,10 +31,10 @@ import static org.diagbot.nlp.participle.ParticipleUtil.participle;
|
|
|
public class StructureAnalyze {
|
|
|
|
|
|
private List<OutputInfo> outputInfos = new ArrayList<>();
|
|
|
-// private static OutputInfo outputInfo = null;
|
|
|
private static boolean updated = false;
|
|
|
private static Object current = null;
|
|
|
private static String num = "";
|
|
|
+ private static List<String> diag_con = Arrays.asList("门诊","诊断");
|
|
|
|
|
|
/**
|
|
|
* 分词,提取词性,封装
|
|
@@ -82,7 +83,10 @@ public class StructureAnalyze {
|
|
|
if (lexprop.length > 1) {
|
|
|
prop = lexprop[0];
|
|
|
for (int i=0;i<lexprop.length;i++) {
|
|
|
- if (Integer.parseInt(lexprop[i]) < Integer.parseInt(prop)) {
|
|
|
+ if (current instanceof Treat && Arrays.asList(lexprop).indexOf(Constants.word_property_diagnose)>=0) {
|
|
|
+ prop = Constants.word_property_diagnose;
|
|
|
+ }
|
|
|
+ else if (Integer.parseInt(lexprop[i]) < Integer.parseInt(prop)) {
|
|
|
prop = lexprop[i];
|
|
|
}
|
|
|
}
|
|
@@ -102,28 +106,17 @@ public class StructureAnalyze {
|
|
|
try {
|
|
|
|
|
|
switch (lexeme.getProperty()) {
|
|
|
+ case Constants.word_property_prop:
|
|
|
+
|
|
|
+ case Constants.word_property_degree:
|
|
|
+ case Constants.word_property_degree_quan:
|
|
|
+
|
|
|
case Constants.word_property_cause:
|
|
|
case Constants.word_property_symptom:
|
|
|
case Constants.word_property_vital_idx:
|
|
|
current = updateClinicalInfo(outputInfo, lexeme.getText(), lexeme.getProperty());
|
|
|
updated = true;
|
|
|
break;
|
|
|
- case Constants.word_property_prop:
|
|
|
- Property property = new Property();
|
|
|
- property.setPropertyName(lexeme.getText());
|
|
|
- if (symptom != null) {
|
|
|
- symptom.setProperty(property);
|
|
|
- }
|
|
|
- updated = true;
|
|
|
- break;
|
|
|
- case Constants.word_property_degree:
|
|
|
- Degree degree = new Degree();
|
|
|
- degree.setDegreeName(lexeme.getText());
|
|
|
- if (current instanceof Symptom) {
|
|
|
- ((Symptom)current).setDegree(degree);
|
|
|
- }
|
|
|
- updated = true;
|
|
|
- break;
|
|
|
case Constants.word_property_LIS:
|
|
|
case Constants.word_property_LIS_Detail:
|
|
|
lis = new Lis();
|
|
@@ -279,6 +272,11 @@ public class StructureAnalyze {
|
|
|
updated = true;
|
|
|
}
|
|
|
break;
|
|
|
+ case Constants.word_property_other:
|
|
|
+ if (diag_con.indexOf(lexeme.getText()) >= 0) {
|
|
|
+ current = new Treat();
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
@@ -382,6 +380,48 @@ public class StructureAnalyze {
|
|
|
|
|
|
obj = symptom;
|
|
|
|
|
|
+ break;
|
|
|
+ case Constants.word_property_degree:
|
|
|
+ case Constants.word_property_degree_quan:
|
|
|
+ Degree degree = new Degree();
|
|
|
+ degree.setDegreeName(name);
|
|
|
+
|
|
|
+ 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())) {
|
|
|
+ outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1).setSymptomName(symptom.getSymptomName());
|
|
|
+ symptom = outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ symptom.setDegree(degree);
|
|
|
+
|
|
|
+ obj = symptom;
|
|
|
+ break;
|
|
|
+ case Constants.word_property_prop:
|
|
|
+ Property property = new Property();
|
|
|
+ property.setPropertyName(name);
|
|
|
+
|
|
|
+ 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())) {
|
|
|
+ outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1).setSymptomName(symptom.getSymptomName());
|
|
|
+ symptom = outputInfo.getSymptoms().get(outputInfo.getSymptoms().size() - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ symptom.setProperty(property);
|
|
|
+ obj = symptom;
|
|
|
break;
|
|
|
}
|
|
|
|