Program: 53392
Project: 53392
Buggy source:
/** 
 * Output Conll2003 format.
 * @param kaf the kaf document
 * @return the annotated named entities in conll03 format
 */
public String annotateNEsToCoNLL2003(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 index=1;
    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=this.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");
            index++;
          }
        }
 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");
          if (previousIsEntity) {
            sb.append(BIO.BEGIN.toString());
          }
 else {
            sb.append(BIO.IN.toString());
          }
          sb.append("String_Node_Str");
          index++;
        }
        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");
        index++;
        previousIsEntity=false;
      }
    }
    sb.append("String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Output Conll2003 format.
 * @param kaf the kaf document
 * @return the annotated named entities in conll03 format
 */
public String annotateNEsToCoNLL2003(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 index=1;
    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=this.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");
            index++;
          }
        }
 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");
          if (previousIsEntity) {
            sb.append(BIO.BEGIN.toString());
          }
 else {
            sb.append(BIO.IN.toString());
          }
          sb.append(neType);
          sb.append("String_Node_Str");
          index++;
        }
        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");
        index++;
        previousIsEntity=false;
      }
    }
    sb.append("String_Node_Str");
  }
  return sb.toString();
}