private List<PotentialSideEffect> getPotentialSideEffects(JCas jcas) {
List<IdentifiedAnnotation> l = getSideEffectNEs(jcas);
List<PotentialSideEffect> ll = new ArrayList<PotentialSideEffect>();
for(int i=0; i<l.size(); i++) {
IdentifiedAnnotation ne = (IdentifiedAnnotation) l.get(i);
int[] senSpan = SEUtil.getSentenceSpanContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd());
String sentence = SEUtil.getSentenceTextContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd()).trim();
boolean foundDrug = false;
//check the same sentence if it contains drug
Iterator neIter = FSUtil.getAnnotationsInSpanIterator(
jcas, IdentifiedAnnotation.type, senSpan[0], senSpan[1]+1);
while(neIter.hasNext()) {
IdentifiedAnnotation n = (IdentifiedAnnotation) neIter.next();
if(n.getTypeID()==1) { //drug
PotentialSideEffect pse = new PotentialSideEffect();
pse.ne = ne;
pse.sentence = sentence;
pse.senBegin = senSpan[0];
pse.senEnd = senSpan[1];
pse.drug = n;
ll.add(pse);
foundDrug = true;
}
}
// if drug is not found in the same sentence, check the previous sentence
if(!foundDrug && !ne.getSegmentID().equals("20105")) {
int num = SEUtil.getSentenceNumContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd());
num = (num>0) ? num-1 : num;
int [] previousSenSpan = SEUtil.getSentenceSpanOfGivenSentenceNum(jcas, num);
//only if they are in the same line
if(SEUtil.isSpanInSameLine(jcas, previousSenSpan[0], senSpan[1])) {
neIter = FSUtil.getAnnotationsInSpanIterator(jcas, IdentifiedAnnotation.type,
previousSenSpan[0], previousSenSpan[1]+1);
while(neIter.hasNext()) {
IdentifiedAnnotation n = (IdentifiedAnnotation) neIter.next();
if(n.getTypeID()==1) { //drug
PotentialSideEffect pse = new PotentialSideEffect();
pse.ne = ne;
pse.sentence = SEUtil.getSentenceTextContainingGivenSpan(
jcas, n.getBegin(), n.getEnd())
+ " " + sentence;
pse.senBegin = previousSenSpan[0];
pse.senEnd = senSpan[1];
pse.drug = n;
ll.add(pse);