delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
} else if ("Clinical_attribute".equals(annotation.type)) {
EventMention mention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_CLINICAL_ATTRIBUTE,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
} else if ("Devices".equals(annotation.type)) {
EntityMention mention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_DEVICE,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
} else if ("Disease_Disorder".equals(annotation.type)) {
DiseaseDisorderMention mention = new DiseaseDisorderMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_DISORDER,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
KnowtatorAnnotation alleviatingFactor = annotationSlots.remove("alleviating_factor");
delayedFeatures.add(DelayedRelationFeature.forArg2(
mention,
"alleviatingFactor",
alleviatingFactor,
ManagesTreatsTextRelation.class,
EventMention.class));
KnowtatorAnnotation signOrSymptom = annotationSlots.remove("associated_sign_or_symptom");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"associatedSignSymptom",
signOrSymptom,
ManifestationOfTextRelation.class,
EventMention.class));
KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"bodyLocation",
bodyLocation,
LocationOfTextRelation.class,
AnatomicalSiteMention.class));
KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
KnowtatorAnnotation course = annotationSlots.remove("course");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"course",
course,
DegreeOfTextRelation.class,
CourseModifier.class));
KnowtatorAnnotation exacerbatingFactor = annotationSlots.remove("exacerbating_factor");
delayedFeatures.add(DelayedRelationFeature.forArg2(
mention,
"exacerbatingFactor",
exacerbatingFactor,
ComplicatesDisruptsTextRelation.class,
EventMention.class));
KnowtatorAnnotation severity = annotationSlots.remove("severity");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"severity",
severity,
DegreeOfTextRelation.class,
SeverityModifier.class));
} else if ("Lab".equals(annotation.type)) {
LabMention mention = new LabMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_LAB,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
KnowtatorAnnotation ordinal = annotationSlots.remove("ordinal_interpretation");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"ordinalInterpretation",
ordinal,
DegreeOfTextRelation.class,
LabInterpretationModifier.class));
KnowtatorAnnotation referenceRange = annotationSlots.remove("reference_range_narrative");
delayedFeatures.add(new DelayedFeature(mention, "referenceRangeNarrative", referenceRange));
KnowtatorAnnotation labValue = annotationSlots.remove("lab_value");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"labValue",
labValue,
ResultOfTextRelation.class,
LabValueModifier.class));
} else if ("Medications/Drugs".equals(annotation.type)) {
MedicationMention mention = new MedicationMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_DRUG,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
KnowtatorAnnotation allergy = annotationSlots.remove("allergy_indicator");
delayedFeatures.add(new DelayedFeature(mention, "medicationAllergy", allergy));
KnowtatorAnnotation changeStatus = annotationSlots.remove("change_status_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationStatusChange", changeStatus));
KnowtatorAnnotation dosage = annotationSlots.remove("dosage_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationDosage", dosage));
KnowtatorAnnotation duration = annotationSlots.remove("duration_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationDuration", duration));
KnowtatorAnnotation form = annotationSlots.remove("form_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationForm", form));
KnowtatorAnnotation frequency = annotationSlots.remove("frequency_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationFrequency", frequency));
KnowtatorAnnotation route = annotationSlots.remove("route_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationRoute", route));
KnowtatorAnnotation startDate = annotationSlots.remove("start_date");
delayedFeatures.add(new DelayedFeature(mention, "startDate", startDate));
KnowtatorAnnotation strength = annotationSlots.remove("strength_model");
delayedFeatures.add(new DelayedFeature(mention, "medicationStrength", strength));
} else if ("Phenomena".equals(annotation.type)) {
EventMention mention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_PHENOMENA,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
} else if ("Procedure".equals(annotation.type)) {
ProcedureMention mention = new ProcedureMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_PROCEDURE,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"bodyLocation",
bodyLocation,
LocationOfTextRelation.class,
AnatomicalSiteMention.class));
KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
KnowtatorAnnotation device = annotationSlots.remove("device");
delayedFeatures.add(new DelayedFeature(mention, "procedureDevice", device));
KnowtatorAnnotation method = annotationSlots.remove("method");
delayedFeatures.add(new DelayedFeature(mention, "method", method));
} else if ("Sign_symptom".equals(annotation.type)) {
SignSymptomMention mention = new SignSymptomMention(jCas, coveringSpan.begin, coveringSpan.end);
addIdentifiedAnnotationFeatures(
annotation,
mention,
jCas,
CONST.NE_TYPE_ID_FINDING,
stringSlots,
booleanSlots,
annotationSlots,
idAnnotationMap,
delayedFeatures);
KnowtatorAnnotation alleviatingFactor = annotationSlots.remove("alleviating_factor");
delayedFeatures.add(DelayedRelationFeature.forArg2(
mention,
"alleviatingFactor",
alleviatingFactor,
ManagesTreatsTextRelation.class,
ProcedureMention.class));
KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"bodyLocation",
bodyLocation,
LocationOfTextRelation.class,
AnatomicalSiteMention.class));
KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
KnowtatorAnnotation course = annotationSlots.remove("course");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"course",
course,
DegreeOfTextRelation.class,
CourseModifier.class));
KnowtatorAnnotation exacerbatingFactor = annotationSlots.remove("exacerbating_factor");
delayedFeatures.add(DelayedRelationFeature.forArg2(
mention,
"exacerbatingFactor",
exacerbatingFactor,
ComplicatesDisruptsTextRelation.class,
EventMention.class));
KnowtatorAnnotation severity = annotationSlots.remove("severity");
delayedFeatures.add(DelayedRelationFeature.forArg1(
mention,
"severity",
severity,
DegreeOfTextRelation.class,
SeverityModifier.class));
} else if ("EVENT".equals(annotation.type)) {
// collect the event properties (setting defaults as necessary)
EventProperties eventProperties = new EventProperties(jCas);
eventProperties.setCategory(stringSlots.remove("type"));
if (eventProperties.getCategory() == null) {
eventProperties.setCategory("N/A");
}
eventProperties.setContextualModality(stringSlots.remove("contextualmoduality"));
if (eventProperties.getContextualModality() == null) {
eventProperties.setContextualModality("ACTUAL");
}
eventProperties.setContextualAspect(stringSlots.remove("contextualaspect"));
if (eventProperties.getContextualAspect() == null) {
eventProperties.setContextualAspect("N/A");
}
eventProperties.setDegree(stringSlots.remove("degree"));
if (eventProperties.getDegree() == null) {
eventProperties.setDegree("N/A");
}
eventProperties.setDocTimeRel(stringSlots.remove("DocTimeRel"));
if (eventProperties.getDocTimeRel() == null) {
LOGGER.warn(String.format(
"assuming docTimeRel=OVERLAP for annotation with id \"%s\"",
annotation.id));
eventProperties.setDocTimeRel("OVERLAP");
}
eventProperties.setPermanence(stringSlots.remove("permanence"));
if (eventProperties.getPermanence() == null) {
eventProperties.setPermanence("UNDETERMINED");
}
String polarityStr = stringSlots.remove("polarity");
int polarity;
if (polarityStr == null || polarityStr.equals("POS")) {
polarity = CONST.NE_POLARITY_NEGATION_ABSENT;
} else if (polarityStr.equals("NEG")) {
polarity = CONST.NE_POLARITY_NEGATION_PRESENT;
} else {
throw new IllegalArgumentException("Invalid polarity: " + polarityStr);
}
eventProperties.setPolarity(polarity);
// create the event object
Event event = new Event(jCas);
event.setConfidence(1.0f);
event.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
// create the event mention
EventMention eventMention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
eventMention.setConfidence(1.0f);
eventMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
// add the links between event, mention and properties
event.setProperties(eventProperties);
event.setMentions(new FSArray(jCas, 1));
event.setMentions(0, eventMention);
eventMention.setEvent(event);
// add the annotations to the indexes
eventProperties.addToIndexes();
event.addToIndexes();
eventMention.addToIndexes();
idAnnotationMap.put(annotation.id, eventMention);
} else if ("DOCTIME".equals(annotation.type)) {
TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
timeMention.setTimeClass(annotation.type);