setStrengthUnitElement(focusToken.getCoveredText(),
focusToken.getBegin(), focusToken.getEnd());
}
Iterator strengthTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, StrengthAnnotation.type, beginPos, endPos);
while (strengthTokenItr.hasNext()){
StrengthAnnotation focusToken = (StrengthAnnotation) strengthTokenItr.next();
String localStrength = null;
if ((localStrength = findStrengthElement(jcas, focusToken
.getBegin(), focusToken.getEnd())) == null) {
strength = new StrengthElement(focusToken.getCoveredText(),
focusToken.getBegin(), focusToken.getEnd());
} else {
if (strength != null) {
// check for range and compare
int spacePosition = strength.getStrengthMention()
.indexOf(" ");
int spacePos = localStrength
.indexOf(" ");
if (spacePosition > 0 && spacePos > 0
&& parseDoubleValue(strength
.getStrengthMention().substring(0,
spacePosition)) < parseDoubleValue(localStrength
.substring(0, localStrength
.indexOf(" ")))&& findMaxValue == true) {
setStrengthElement(localStrength, focusToken
.getBegin(), focusToken.getEnd());
} else {
String stringRange = strength.getStrengthMention();
int hyphPosition = 0;
if ((stringRange.length() > 0)
&& (stringRange.indexOf('-') > 0)) {
hyphPosition = stringRange.indexOf('-');
Double firstValue = new Double(
parseDoubleValue(stringRange
.subSequence(0, hyphPosition)));
Double secondValue = new Double(
parseDoubleValue(stringRange
.substring(hyphPosition + 2)));
if (firstValue.doubleValue() >= secondValue
.doubleValue() && findMaxValue == true) {
setStrengthElement(firstValue.toString(),
focusToken.getBegin(), focusToken
.getEnd());
} else {
setStrengthElement(firstValue.toString(),
focusToken.getBegin(), focusToken
.getEnd());
}
}
}
} else if ((localStrength.length() > 0)
&& (localStrength.indexOf('-') > 0)) {
int hyphPosition = 0;
hyphPosition = localStrength.indexOf('-');
Double firstValue = new Double(
parseDoubleValue(localStrength.subSequence(0,
hyphPosition)));
Double secondValue = new Double(
parseDoubleValue(localStrength
.substring(hyphPosition + 2)));
if (firstValue.doubleValue() >= secondValue
.doubleValue() && findMaxValue == true) {
setStrengthElement(firstValue.toString(),
focusToken.getBegin(), focusToken.getEnd());
} else {
setStrengthElement(firstValue.toString(),
focusToken.getBegin(), focusToken.getEnd());
}
setStrengthElement(localStrength,
focusToken.getBegin(), focusToken.getEnd());
} else {
setStrengthElement(localStrength,
focusToken.getBegin(), focusToken.getEnd());
}
}
}
Iterator formTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, FormAnnotation.type, beginPos, endPos);
while (formTokenItr.hasNext()){
FormAnnotation focusToken = (FormAnnotation) formTokenItr.next();
String localForm = null;
if ((localForm = findFormElement(jcas, focusToken.getBegin(),
focusToken.getEnd())) == null) {
form = new FormElement(focusToken.getCoveredText(),
focusToken.getBegin(), focusToken.getEnd());
} else {
setFormElement(localForm, focusToken.getBegin(), focusToken
.getEnd());
}
}
Iterator routeTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, RouteAnnotation.type, beginPos, endPos);
while (routeTokenItr.hasNext()){
RouteAnnotation focusToken = (RouteAnnotation) routeTokenItr.next();
String localRoute = null;
if ((localRoute = findRouteElement(jcas, focusToken.getBegin(),
focusToken.getEnd())) == null) {
route = new RouteElement(focusToken.getCoveredText(),
focusToken.getBegin(), focusToken.getEnd());
} else {
setRouteElement(localRoute, focusToken.getBegin(),
focusToken.getEnd());
}
}
Iterator durationTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, DurationAnnotation.type, beginPos, endPos);
while (durationTokenItr.hasNext()){
DurationAnnotation focusToken = (DurationAnnotation) durationTokenItr.next();
String localDuration = null;
if ((localDuration = findDurationElement(jcas, focusToken
.getBegin(), focusToken.getEnd())) == null) {
duration = new DurationElement(focusToken.getCoveredText(),
focusToken.getBegin(), focusToken.getEnd());
} else {
setDurationElement(localDuration, focusToken.getBegin(),
focusToken.getEnd());
}
}