Program: 42504
Project: 42504
Buggy source:
/** 
 * Converts a jCas'   {@link Cooccurrence}s to  {@link org.itc.irst.tcc.sre.data.Sentence}s
 * @param < brClass >
 */
static <B extends Annotation>Pair<List<Cooccurrence>,List<SentenceExample>> getSvmSentences(JCas jCas,final Class<B> brClass){
  List<Cooccurrence> retCooc=newArrayList();
  List<SentenceExample> retSentences=newArrayList();
  String pmId=getHeaderDocId(jCas);
  int sentenceId=0;
  Map<Sentence,Collection<B>> brIdx=indexCovered(jCas,Sentence.class,brClass);
  Map<Sentence,Collection<Token>> tokenIdx=indexCovered(jCas,Sentence.class,Token.class);
  for (  Entry<Sentence,Collection<Cooccurrence>> uSentences : indexCovered(jCas,Sentence.class,Cooccurrence.class).entrySet()) {
    Sentence uSentence=uSentences.getKey();
    Collection<Token> tokens=tokenIdx.get(uSentence);
    for (    Cooccurrence c : uSentences.getValue()) {
      List<B> a=Lists.newArrayList(brIdx.get(uSentence));
      Collections.sort(a,new java.util.Comparator<B>(){
        @Override public int compare(        B br1,        B br2){
          return new Integer(br1.getBegin()).compareTo(br2.getBegin());
        }
      }
);
      Annotation[] allBrs=a.toArray(new Annotation[a.size()]);
      Annotation br1=c.getFirstEntity(), br2=c.getSecondEntity();
      boolean matchedBr1=false, matchedBr2=false;
      List<Word> words=newArrayList();
      int tokenId=0;
      Iterator<Token> tokenIt=tokens.iterator();
      while (tokenIt.hasNext()) {
        Token token=tokenIt.next();
        String[] feats=new String[7];
        Annotation coveringBr=null;
        for (int i=0; i < allBrs.length; i++) {
          if (allBrs[i] != null && token.getEnd() > allBrs[i].getBegin()) {
            coveringBr=allBrs[i];
            allBrs[i]=null;
          }
        }
        if (coveringBr != null) {
          boolean endOfBR=false;
          while (!endOfBR && tokenIt.hasNext()) {
            Token nextT=tokenIt.next();
            if (nextT.getEnd() >= coveringBr.getEnd())             endOfBR=true;
          }
        }
        if (coveringBr != null) {
          feats[FORM]=coveringBr.getCoveredText();
          feats[LEMMA]="String_Node_Str";
          feats[POS]=token.getPos();
          feats[ENTITY_TYPE]=BR_LABEL;
          boolean matched=false;
          if (coveringBr.equals(br1)) {
            matched=true;
            matchedBr1=true;
          }
 else           if (coveringBr.equals(br2)) {
            matched=true;
            matchedBr2=true;
          }
          if (matched) {
            feats[LABEL]=Word.TARGET_LABEL;
          }
 else {
            feats[LABEL]=Word.OTHER_LABEL;
          }
        }
 else {
          feats[FORM]=token.getCoveredText();
          feats[LEMMA]=token.getLemmaStr();
          feats[POS]=token.getPos();
          feats[ENTITY_TYPE]=Word.OTHER_LABEL;
          feats[LABEL]=Word.OTHER_LABEL;
        }
        feats[STEM]=PorterStemmer.getStemmer().stem(feats[FORM]);
        Word w=new Word(feats,tokenId++);
        words.add(w);
      }
      boolean parsedOk=true;
      if (!matchedBr1) {
        parsedOk=false;
        LOG.error("String_Node_Str" + To.string(br1));
      }
 else       if (!matchedBr2) {
        parsedOk=false;
        LOG.error("String_Node_Str" + To.string(br2));
      }
      for (int i=0; i < allBrs.length; i++) {
        if (allBrs[i] != null) {
          parsedOk=false;
          LOG.error("String_Node_Str" + To.string(allBrs[i]));
        }
      }
      if (parsedOk) {
        org.itc.irst.tcc.sre.data.Sentence sentence=new org.itc.irst.tcc.sre.data.Sentence(words);
        boolean label=c.getHasInteraction();
        int classz=label ? 2 : 0;
        String id=pmId + "String_Node_Str" + sentenceId++;
        retCooc.add(c);
        retSentences.add(new SentenceExample(sentence,classz,id));
      }
    }
  }
  return Pair.of(retCooc,retSentences);
}

Fixed version (ground truth):
/** 
 * Converts a jCas'   {@link Cooccurrence}s to  {@link org.itc.irst.tcc.sre.data.Sentence}s
 * @param < brClass >
 */
static <B extends Annotation>Pair<List<Cooccurrence>,List<SentenceExample>> getSvmSentences(JCas jCas,final Class<B> brClass){
  List<Cooccurrence> retCooc=newArrayList();
  List<SentenceExample> retSentences=newArrayList();
  String pmId=getHeaderDocId(jCas);
  int sentenceId=0;
  Map<Sentence,Collection<B>> brIdx=indexCovered(jCas,Sentence.class,brClass);
  Map<Sentence,Collection<Token>> tokenIdx=indexCovered(jCas,Sentence.class,Token.class);
  for (  Entry<Sentence,Collection<Cooccurrence>> uSentences : indexCovered(jCas,Sentence.class,Cooccurrence.class).entrySet()) {
    Sentence uSentence=uSentences.getKey();
    Collection<Token> tokens=tokenIdx.get(uSentence);
    for (    Cooccurrence c : uSentences.getValue()) {
      List<B> a=newArrayList(brIdx.get(uSentence));
      sort(a,new java.util.Comparator<B>(){
        @Override public int compare(        B br1,        B br2){
          return new Integer(br1.getBegin()).compareTo(br2.getBegin());
        }
      }
);
      Annotation[] allBrs=a.toArray(new Annotation[a.size()]);
      Annotation br1=c.getFirstEntity(), br2=c.getSecondEntity();
      boolean matchedBr1=false, matchedBr2=false;
      List<Word> words=newArrayList();
      int tokenId=0;
      Iterator<Token> tokenIt=tokens.iterator();
      while (tokenIt.hasNext()) {
        Token token=tokenIt.next();
        String[] feats=new String[7];
        Annotation coveringBr=null;
        for (int i=0; i < allBrs.length; i++) {
          if (allBrs[i] != null && token.getEnd() > allBrs[i].getBegin()) {
            coveringBr=allBrs[i];
            allBrs[i]=null;
          }
        }
        if (coveringBr != null) {
          boolean endOfBR=false;
          while (!endOfBR && tokenIt.hasNext()) {
            Token nextT=tokenIt.next();
            if (nextT.getEnd() >= coveringBr.getEnd())             endOfBR=true;
          }
        }
        if (coveringBr != null) {
          feats[FORM]=coveringBr.getCoveredText();
          feats[LEMMA]="String_Node_Str";
          feats[POS]=token.getPos();
          feats[ENTITY_TYPE]=BR_LABEL;
          boolean matched=false;
          if (coveringBr.equals(br1)) {
            matched=true;
            matchedBr1=true;
          }
 else           if (coveringBr.equals(br2)) {
            matched=true;
            matchedBr2=true;
          }
          if (matched) {
            feats[LABEL]=Word.TARGET_LABEL;
          }
 else {
            feats[LABEL]=Word.OTHER_LABEL;
          }
        }
 else {
          feats[FORM]=token.getCoveredText();
          feats[LEMMA]=token.getLemmaStr();
          feats[POS]=token.getPos();
          feats[ENTITY_TYPE]=Word.OTHER_LABEL;
          feats[LABEL]=Word.OTHER_LABEL;
        }
        feats[STEM]=PorterStemmer.getStemmer().stem(feats[FORM]);
        Word w=new Word(feats,tokenId++);
        words.add(w);
      }
      boolean parsedOk=true;
      if (!matchedBr1) {
        parsedOk=false;
        LOG.error("String_Node_Str" + To.string(br1) + "String_Node_Str",pmId,br1.getBegin());
      }
 else       if (!matchedBr2) {
        parsedOk=false;
        LOG.error("String_Node_Str" + To.string(br2) + "String_Node_Str",pmId,br2.getBegin());
      }
      for (int i=0; i < allBrs.length; i++) {
        if (allBrs[i] != null) {
          parsedOk=false;
          LOG.error("String_Node_Str" + To.string(allBrs[i]) + "String_Node_Str",pmId);
        }
      }
      if (parsedOk) {
        org.itc.irst.tcc.sre.data.Sentence sentence=new org.itc.irst.tcc.sre.data.Sentence(words);
        boolean label=c.getHasInteraction();
        int classz=label ? 2 : 0;
        String id=pmId + "String_Node_Str" + sentenceId++;
        retCooc.add(c);
        retSentences.add(new SentenceExample(sentence,classz,id));
      }
    }
  }
  return Pair.of(retCooc,retSentences);
}