Program: 53373
Project: 53373
Buggy source:
/** 
 * Output Conll2002 format.
 * @param kaf the kaf document
 * @return the annotated named entities in conll03 format
 */
public String annotateNEsToCoNLL2002(KAFDocument kaf){
  List<Entity> namedEntityList=kaf.getEntities();
  Map<String,Integer> entityToSpanSize=new HashMap<String,Integer>();
  Map<String,String> entityToType=new HashMap<String,String>();
  for (  Entity ne : namedEntityList) {
    List<ixa.kaflib.Span<Term>> entitySpanList=ne.getSpans();
    for (    ixa.kaflib.Span<Term> spanTerm : entitySpanList) {
      Term neTerm=spanTerm.getFirstTarget();
      entityToSpanSize.put(neTerm.getId(),spanTerm.size());
      entityToType.put(neTerm.getId(),ne.getType());
    }
  }
  List<List<WF>> sentences=kaf.getSentences();
  StringBuilder sb=new StringBuilder();
  for (  List<WF> sentence : sentences) {
    int sentNumber=sentence.get(0).getSent();
    List<Term> sentenceTerms=kaf.getSentenceTerms(sentNumber);
    boolean previousIsEntity=false;
    for (int i=0; i < sentenceTerms.size(); i++) {
      Term thisTerm=sentenceTerms.get(i);
      if (entityToSpanSize.get(thisTerm.getId()) != null) {
        int neSpanSize=entityToSpanSize.get(thisTerm.getId());
        String neClass=entityToType.get(thisTerm.getId());
        String neType=convertToConLLTypes(neClass);
        if (neSpanSize > 1) {
          for (int j=0; j < neSpanSize; j++) {
            thisTerm=sentenceTerms.get(i + j);
            sb.append(thisTerm.getForm());
            sb.append("String_Node_Str");
            sb.append(thisTerm.getLemma());
            sb.append("String_Node_Str");
            sb.append(thisTerm.getMorphofeat());
            sb.append("String_Node_Str");
            if (j == 0 || previousIsEntity) {
              sb.append(BIO.BEGIN.toString());
            }
 else {
              sb.append(BIO.IN.toString());
            }
            sb.append(neType);
            sb.append("String_Node_Str");
          }
        }
 else {
          sb.append(thisTerm.getForm());
          sb.append("String_Node_Str");
          sb.append(thisTerm.getLemma());
          sb.append("String_Node_Str");
          sb.append(thisTerm.getMorphofeat());
          sb.append("String_Node_Str");
          sb.append(BIO.BEGIN.toString());
          sb.append(neType);
          sb.append("String_Node_Str");
        }
        previousIsEntity=true;
        i+=neSpanSize - 1;
      }
 else {
        sb.append(thisTerm.getForm());
        sb.append("String_Node_Str");
        sb.append(thisTerm.getLemma());
        sb.append("String_Node_Str");
        sb.append(thisTerm.getMorphofeat());
        sb.append("String_Node_Str");
        sb.append(BIO.OUT);
        sb.append("String_Node_Str");
        previousIsEntity=false;
      }
    }
    sb.append("String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Output Conll2002 format.
 * @param kaf the kaf document
 * @return the annotated named entities in conll03 format
 */
public String annotateNEsToCoNLL2002(KAFDocument kaf){
  List<Entity> namedEntityList=kaf.getEntities();
  Map<String,Integer> entityToSpanSize=new HashMap<String,Integer>();
  Map<String,String> entityToType=new HashMap<String,String>();
  for (  Entity ne : namedEntityList) {
    List<ixa.kaflib.Span<Term>> entitySpanList=ne.getSpans();
    for (    ixa.kaflib.Span<Term> spanTerm : entitySpanList) {
      Term neTerm=spanTerm.getFirstTarget();
      entityToSpanSize.put(neTerm.getId(),spanTerm.size());
      entityToType.put(neTerm.getId(),ne.getType());
    }
  }
  List<List<WF>> sentences=kaf.getSentences();
  StringBuilder sb=new StringBuilder();
  for (  List<WF> sentence : sentences) {
    int sentNumber=sentence.get(0).getSent();
    List<Term> sentenceTerms=kaf.getSentenceTerms(sentNumber);
    for (int i=0; i < sentenceTerms.size(); i++) {
      Term thisTerm=sentenceTerms.get(i);
      if (entityToSpanSize.get(thisTerm.getId()) != null) {
        int neSpanSize=entityToSpanSize.get(thisTerm.getId());
        String neClass=entityToType.get(thisTerm.getId());
        String neType=convertToConLLTypes(neClass);
        if (neSpanSize > 1) {
          for (int j=0; j < neSpanSize; j++) {
            thisTerm=sentenceTerms.get(i + j);
            sb.append(thisTerm.getForm());
            sb.append("String_Node_Str");
            sb.append(thisTerm.getLemma());
            sb.append("String_Node_Str");
            sb.append(thisTerm.getMorphofeat());
            sb.append("String_Node_Str");
            if (j == 0) {
              sb.append(BIO.BEGIN.toString());
            }
 else {
              sb.append(BIO.IN.toString());
            }
            sb.append(neType);
            sb.append("String_Node_Str");
          }
        }
 else {
          sb.append(thisTerm.getForm());
          sb.append("String_Node_Str");
          sb.append(thisTerm.getLemma());
          sb.append("String_Node_Str");
          sb.append(thisTerm.getMorphofeat());
          sb.append("String_Node_Str");
          sb.append(BIO.BEGIN.toString());
          sb.append(neType);
          sb.append("String_Node_Str");
        }
        i+=neSpanSize - 1;
      }
 else {
        sb.append(thisTerm.getForm());
        sb.append("String_Node_Str");
        sb.append(thisTerm.getLemma());
        sb.append("String_Node_Str");
        sb.append(thisTerm.getMorphofeat());
        sb.append("String_Node_Str");
        sb.append(BIO.OUT);
        sb.append("String_Node_Str");
      }
    }
    sb.append("String_Node_Str");
  }
  return sb.toString();
}