use of org.apache.ctakes.typesystem.type.refsem.UmlsConcept in project tika by apache.
the class CTAKESUtils method getAnnotationProperty.
/**
* Returns the annotation value based on the given annotation type.
*
* @param annotation
* {@see IdentifiedAnnotation} object.
* @param property
* {@see CTAKESAnnotationProperty} enum used to identify the
* annotation type.
* @return the annotation value.
*/
public static String getAnnotationProperty(IdentifiedAnnotation annotation, CTAKESAnnotationProperty property) {
String value = null;
if (property == CTAKESAnnotationProperty.BEGIN) {
value = Integer.toString(annotation.getBegin());
} else if (property == CTAKESAnnotationProperty.END) {
value = Integer.toString(annotation.getEnd());
} else if (property == CTAKESAnnotationProperty.CONDITIONAL) {
value = Boolean.toString(annotation.getConditional());
} else if (property == CTAKESAnnotationProperty.CONFIDENCE) {
value = Float.toString(annotation.getConfidence());
} else if (property == CTAKESAnnotationProperty.DISCOVERY_TECNIQUE) {
value = Integer.toString(annotation.getDiscoveryTechnique());
} else if (property == CTAKESAnnotationProperty.GENERIC) {
value = Boolean.toString(annotation.getGeneric());
} else if (property == CTAKESAnnotationProperty.HISTORY_OF) {
value = Integer.toString(annotation.getHistoryOf());
} else if (property == CTAKESAnnotationProperty.ID) {
value = Integer.toString(annotation.getId());
} else if (property == CTAKESAnnotationProperty.ONTOLOGY_CONCEPT_ARR) {
FSArray mentions = annotation.getOntologyConceptArr();
StringBuilder sb = new StringBuilder();
if (mentions != null) {
for (int i = 0; i < mentions.size(); i++) {
if (mentions.get(i) instanceof UmlsConcept) {
UmlsConcept concept = (UmlsConcept) mentions.get(i);
sb.append(concept.getCui());
if (i < mentions.size() - 1) {
sb.append(",");
}
}
}
}
value = sb.toString();
} else if (property == CTAKESAnnotationProperty.POLARITY) {
value = Integer.toString(annotation.getPolarity());
}
return value;
}
Aggregations