Program: 33170
Project: 33170
Buggy source:
/** 
 * Implemented as Wagner-Fischer algorithm (https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm)
 * @param nText the new text, e.g., received from an annotation system.
 * @param oText the original text, e.g., the text that was read from a gold standard dataset.
 * @return The result of the comparison including the Levenstein distance aswell as the changes that would have to be applied to the new text to become the original text.
 */
public static DocumentTextComparisonResult getLevensteinDistance(String nText,String oText){
  int nLength=nText.length();
  int oLength=oText.length();
  if (nLength == 0) {
    return DocumentTextComparisonResult.create(oLength,DocumentTextEdits.INSERT);
  }
  if (oLength == 0) {
    return DocumentTextComparisonResult.create(nLength,DocumentTextEdits.DELETE);
  }
  int expectedSteps=Math.max(nLength,oLength);
  DocumentTextComparisonResult matrix[][]=new DocumentTextComparisonResult[nLength + 1][oLength + 1];
  for (int i=0; i <= nLength; ++i) {
    matrix[i][0]=DocumentTextComparisonResult.create(i,DocumentTextEdits.DELETE,expectedSteps);
  }
  for (int i=0; i <= oLength; ++i) {
    matrix[0][i]=DocumentTextComparisonResult.create(i,DocumentTextEdits.INSERT,expectedSteps);
  }
  for (int i=1; i <= nLength; ++i) {
    for (int j=1; j <= oLength; ++j) {
      if (nText.charAt(i - 1) == oText.charAt(j - 1)) {
        matrix[i][j]=DocumentTextComparisonResult.create(matrix[i - 1][j - 1],DocumentTextEdits.NONE);
      }
 else {
        matrix[i][j]=determineOperation(matrix,i,j);
      }
    }
  }
  return matrix[nLength][oLength];
}

Fixed version (ground truth):
/** 
 * Implemented as Wagner-Fischer algorithm (https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm)
 * @param nText the new text, e.g., received from an annotation system.
 * @param oText the original text, e.g., the text that was read from a gold standard dataset.
 * @return The result of the comparison including the Levenstein distance aswell as the changes that would have to be applied to the new text to become the original text.
 */
public static DocumentTextComparisonResult getLevensteinDistance(String nText,String oText){
  int nLength=nText.length();
  int oLength=oText.length();
  if (nLength == 0) {
    return DocumentTextComparisonResult.create(oLength,DocumentTextEdits.INSERT);
  }
  if (oLength == 0) {
    return DocumentTextComparisonResult.create(nLength,DocumentTextEdits.DELETE);
  }
  int expectedSteps=Math.max(nLength,oLength);
  DocumentTextComparisonResult oldLine[]=new DocumentTextComparisonResult[oLength + 1];
  DocumentTextComparisonResult currentLine[]=new DocumentTextComparisonResult[oLength + 1];
  DocumentTextComparisonResult temp[];
  for (int i=0; i <= oLength; ++i) {
    oldLine[i]=DocumentTextComparisonResult.create(i,DocumentTextEdits.INSERT,expectedSteps);
  }
  for (int i=1; i <= nLength; ++i) {
    currentLine[0]=DocumentTextComparisonResult.create(i,DocumentTextEdits.DELETE,expectedSteps);
    for (int j=1; j <= oLength; ++j) {
      if (nText.charAt(i - 1) == oText.charAt(j - 1)) {
        currentLine[j]=DocumentTextComparisonResult.create(oldLine[j - 1],DocumentTextEdits.NONE);
      }
 else {
        currentLine[j]=determineOperation(currentLine,oldLine,i,j);
      }
    }
    temp=oldLine;
    oldLine=currentLine;
    currentLine=temp;
  }
  return oldLine[oLength];
}