|
@@ -4,7 +4,7 @@ import org.algorithm.core.cnn.model.Lemma;
|
|
|
import org.algorithm.core.cnn.model.Triad;
|
|
|
import org.diagbot.nlp.participle.word.Lexeme;
|
|
|
import org.diagbot.nlp.participle.word.LexemePath;
|
|
|
-import org.diagbot.nlp.relation.extract.cell.BodyPart;
|
|
|
+import org.diagbot.nlp.relation.extract.cell.*;
|
|
|
import org.diagbot.nlp.relation.extract.module.Symptom;
|
|
|
import org.diagbot.nlp.util.NegativeEnum;
|
|
|
import org.diagbot.nlp.util.NlpUtil;
|
|
@@ -22,8 +22,10 @@ import java.util.List;
|
|
|
public class PresentExtract extends BaseExtract {
|
|
|
|
|
|
private NegativeEnum[] symptom_type = new NegativeEnum[]{NegativeEnum.SYMPTOM};
|
|
|
+ private NegativeEnum[] unit_time_type = new NegativeEnum[]{NegativeEnum.EVENT_TIME, NegativeEnum.UNIT};
|
|
|
private NegativeEnum[] vital_type = new NegativeEnum[]{NegativeEnum.VITAL_INDEX};
|
|
|
private NegativeEnum[] body_part_type = new NegativeEnum[]{NegativeEnum.BODY_PART};
|
|
|
+ private NegativeEnum[] position_type = new NegativeEnum[]{NegativeEnum.POSITION};
|
|
|
private NegativeEnum[] property_type = new NegativeEnum[]{NegativeEnum.PROPERTY};
|
|
|
private NegativeEnum[] degree_type = new NegativeEnum[]{NegativeEnum.DEEP};
|
|
|
private NegativeEnum[] cause_type = new NegativeEnum[]{NegativeEnum.CAUSE};
|
|
@@ -38,26 +40,65 @@ public class PresentExtract extends BaseExtract {
|
|
|
property = param_lemma.getProperty();
|
|
|
if (NlpUtil.isFeature(property, symptom_type)) { //特征词 症状
|
|
|
Symptom symptom = new Symptom();
|
|
|
- lookSymptomRelations(param_lemma, triads, symptom);
|
|
|
+ lookSymptomRelations(param_lemma, cnn_lemmas, symptom);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void lookSymptomRelations(Lemma param_lemma, List<Triad> triads, Symptom symptom) {
|
|
|
- Lemma lemma = null;
|
|
|
- for (Triad triad : triads) {
|
|
|
- if (triad.getL_1().getText().equals(param_lemma.getText())
|
|
|
- && triad.getL_1().getPosition().equals(param_lemma.getPosition())) {
|
|
|
- addFeatureToSymptom(triad.getL_2(), symptom);
|
|
|
+ private void lookSymptomRelations(Lemma param_lemma, List<Lemma> cnn_lemmas, Symptom symptom) {
|
|
|
+ for (Lemma cnn_l : cnn_lemmas) {
|
|
|
+ if (cnn_l.getText().equals(param_lemma.getText())
|
|
|
+ && cnn_l.getPosition().equals(param_lemma.getPosition())) {
|
|
|
+ for (Lemma relation_l : cnn_l.getRelationLemmas()) {
|
|
|
+ addFeatureToSymptom(relation_l, symptom);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void addFeatureToSymptom(Lemma lemma, Symptom symptom) {
|
|
|
+ //时间信息
|
|
|
+ if (NlpUtil.isFeature(lemma.getProperty(), unit_time_type)) {
|
|
|
+ PD pd = new PD();
|
|
|
+ pd.setValue(lemma.getText());
|
|
|
+ symptom.setPd(pd);
|
|
|
+ }
|
|
|
//部位信息
|
|
|
if (NlpUtil.isFeature(lemma.getProperty(), body_part_type)) {
|
|
|
BodyPart bodyPart = new BodyPart();
|
|
|
bodyPart.setPartBodyName(lemma.getText());
|
|
|
+ if (lemma.getRelationLemmas().size() > 0) {
|
|
|
+ Lemma l = lemma.getRelationLemmas().get(0);
|
|
|
+ if (NlpUtil.isFeature(l.getProperty(), position_type)) {
|
|
|
+ bodyPart.setDirection(l.getText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ symptom.setBodyPart(bodyPart);
|
|
|
+ }
|
|
|
+ //程度
|
|
|
+ if (NlpUtil.isFeature(lemma.getProperty(), degree_type)) {
|
|
|
+ Degree degree = new Degree();
|
|
|
+ degree.setDegreeName(lemma.getText());
|
|
|
+ for (Lemma l : lemma.getRelationLemmas()) {
|
|
|
+ if (NlpUtil.isFeature(l.getProperty(), unit_time_type)) {
|
|
|
+ PD pd = new PD();
|
|
|
+ pd.setValue(l.getText());
|
|
|
+ degree.setPd(pd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ symptom.setDegree(degree);
|
|
|
+ }
|
|
|
+ //性质
|
|
|
+ if (NlpUtil.isFeature(lemma.getProperty(), property_type)) {
|
|
|
+ Property property = new Property();
|
|
|
+ property.setPropertyName(lemma.getText());
|
|
|
+ symptom.setProperty(property);
|
|
|
+ }
|
|
|
+ //诱因
|
|
|
+ if (NlpUtil.isFeature(lemma.getProperty(), cause_type)) {
|
|
|
+ Cause cause = new Cause();
|
|
|
+ cause.setCauseName(lemma.getText());
|
|
|
+ symptom.setCause(cause);
|
|
|
}
|
|
|
}
|
|
|
|