for (FeatureStructure binaryTextRelationFS: locationOfTextRelations) {
i++;
//logger.info("binaryTextRelationFS = " + binaryTextRelationFS);
BinaryTextRelation binaryTextRelation = (BinaryTextRelation) binaryTextRelationFS;
LocationOfTextRelation locationOfTextRelation = null;
if (binaryTextRelation instanceof LocationOfTextRelation) {
locationOfTextRelation = (LocationOfTextRelation) binaryTextRelationFS;
}
RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention OR location
RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier OR what is located at location
String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"
if (relation.equals("degree_of")) {
// do nothing here, this loop is for dealing with location_of
// degree_of has its own loop.
} else if (relation.equals("location_of")) {
IdentifiedAnnotation arg1Arg = (IdentifiedAnnotation) arg1.getArgument();
IdentifiedAnnotation ia = mapToMentions.get(arg1Arg);
if (ia instanceof EntityMention) {
// Note you apparently can have an AnatomicalSiteMention be the location_of an AnatomicalSiteMention
// from running rec041, end up with things like "Left lower extremity" location_of "common femoral vein"
// and "left renal vein" in relation location_of to anatomical site mention "renal vein"
// and "vein" in relation location_of to anatomical site mention "renal vein"
EntityMention entityMention = (EntityMention) ia;
IdentifiedAnnotation location = (IdentifiedAnnotation) arg2.getArgument();
IdentifiedAnnotation loc = (IdentifiedAnnotation)mapToMentions.get(location);
if (loc instanceof AnatomicalSiteMention) {
AnatomicalSiteMention asm = (AnatomicalSiteMention) loc;
//asm.setBodyLocation(binaryTextRelation); // uncomment iff AnatomicalSiteMention ends up with a bodyLocation attribute
} else {
logger.error("Need to implement cases for handling EntityMention " + entityMention + " within relation: " + relation);
logger.error(" loc " + loc + " in relation " + relation + " with/to " + entityMention);
logger.error(" Using covered text: loc " + loc.getCoveredText() + " in relation " + relation + " with/to " + entityMention.getCoveredText());
}
} else {
EventMention eventMention = (EventMention) ia;
if (eventMention instanceof DiseaseDisorderMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_DISORDER) {
DiseaseDisorderMention ddm = (DiseaseDisorderMention) eventMention;
ddm.setBodyLocation(locationOfTextRelation);
} else if (eventMention instanceof ProcedureMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_PROCEDURE) {
ProcedureMention pm = (ProcedureMention) eventMention;
pm.setBodyLocation(locationOfTextRelation);
} else if (eventMention instanceof SignSymptomMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_FINDING) {
SignSymptomMention ssm = (SignSymptomMention) eventMention;
ssm.setBodyLocation(locationOfTextRelation);
} else {
logger.error("Need to implement more cases for handling EventMention " + eventMention + " within relation: " + relation);
}
}
} else {
logger.error("Need to implement more cases for relation: " + relation);
}
}
}
if (degreeOfTextRelations != null) {
for (FeatureStructure binaryTextRelationFS: degreeOfTextRelations) {
i++;
//logger.info("binaryTextRelationFS = " + binaryTextRelationFS);
BinaryTextRelation binaryTextRelation = (BinaryTextRelation) binaryTextRelationFS;
DegreeOfTextRelation degreeOfTextRelation = null;
if (binaryTextRelation instanceof DegreeOfTextRelation) {
degreeOfTextRelation = (DegreeOfTextRelation) binaryTextRelationFS;
}
RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention OR location
RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier OR what is located at location
String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"
if (relation.equals("degree_of")) {
Modifier severity = (Modifier) arg2.getArgument();
// degree_of is aka severity, which applies to SignSymptomMention/SignSymptom and DiseaseDisorder