in ctakes-drug-ner/src/main/java/org/apache/ctakes/drugner/ae/DrugMentionAnnotator.java [2830:2971]
private int findInPattern(JCas jcas, int begin, int end, int elementType, int[][] location) {
JFSIndexRepository indexes = jcas.getJFSIndexRepository();
Iterator neItr = indexes.getAnnotationIndex(elementType).iterator();
int [] lastLocation = {-1,-1};
int counter = 0;
if (elementType == StrengthUnitAnnotation.type) {
while (neItr.hasNext()) {
StrengthUnitAnnotation nea = (StrengthUnitAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
} else if (elementType == StrengthAnnotation.type) {
while (neItr.hasNext()) {
StrengthAnnotation nea = (StrengthAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
} else if (elementType == FrequencyAnnotation.type) {
while (neItr.hasNext()) {
FrequencyAnnotation nea = (FrequencyAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
} }
} else if (elementType == FrequencyUnitAnnotation.type) {
while (neItr.hasNext()) {
FrequencyUnitAnnotation nea = (FrequencyUnitAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
} else if (elementType == DosagesAnnotation.type) {
while (neItr.hasNext()) {
DosagesAnnotation nea = (DosagesAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
}else if (elementType == RouteAnnotation.type) {
while (neItr.hasNext()) {
RouteAnnotation nea = (RouteAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
} else if (elementType == FormAnnotation.type) {
while (neItr.hasNext()) {
FormAnnotation nea = (FormAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
}
else if (elementType == DurationAnnotation.type) {
while (neItr.hasNext()) {
DurationAnnotation nea = (DurationAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
}
else if (elementType == DrugChangeStatusAnnotation.type) {
while (neItr.hasNext()) {
DrugChangeStatusAnnotation nea = (DrugChangeStatusAnnotation) neItr.next();
lastLocation[0] = nea.getBegin();
lastLocation[1] = nea.getEnd();
if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
} else if (elementType == MedicationMention.type) {
while (neItr.hasNext()) {
MedicationMention nea = (MedicationMention) neItr.next();
if(nea.getTypeID()==1 || nea.getTypeID()==0) {
lastLocation[0]= nea.getBegin();
lastLocation[1] = nea.getEnd();
if ((counter == 0 || lastLocation[0] != location[counter-1][0]) && (nea.getBegin()>=begin && nea.getEnd() <= end)) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
}
} else if (elementType == PunctuationToken.type) {
while (neItr.hasNext()) {
boolean foundPair = false;
PunctuationToken nea = (PunctuationToken) neItr.next();
if (nea.getCoveredText().compareTo("(")==0)
lastLocation[0] = nea.getBegin();
else if (nea.getCoveredText().compareTo(")")==0) {
lastLocation[1] = nea.getEnd();
foundPair = true;
}
if (nea.getBegin()>=begin && nea.getEnd() <= end && foundPair && (counter == 0 || (counter> 0 && lastLocation[0] != location[counter - 1][0]))) {
location[counter][0]= lastLocation[0];
location[counter][1]= lastLocation[1];
counter++;
}
}
}
return counter;
}