Program: 168235
Project: 168235
Buggy source:
protected void runLDA(File dir,File seedFile,int numTopics,int noOfSamples,double alphaval,double betaval,double confidenceValue,String outputdir){
  File[] listOfFiles=dir.listFiles();
  List<File> inputFiles=new ArrayList<File>();
  for (  File f : listOfFiles)   inputFiles.add(f);
  if (inputFiles.size() == 0) {
    appendLog("String_Node_Str");
    return;
  }
  File[] listSeedFiles=seedFile.listFiles();
  File preSeedFile=listSeedFiles[0];
  System.out.println("String_Node_Str");
  appendLog("String_Node_Str");
  DTWC dtwc=new DTWC(inputFiles,preSeedFile);
  dtwc.computeDocumentVectors();
  int[][][] zlabels=dtwc.getTopicSeedsAsInt();
  int[][] docs=dtwc.getDocVectorsAsInt();
  int T=numTopics;
  int W=dtwc.getVocabSize();
  double[][] alpha=new double[1][T];
  for (int i=0; i < T; i++) {
    alpha[0][i]=alphaval;
  }
  double[][] beta=new double[T][W];
  for (int i=0; i < T; i++) {
    for (int j=0; j < W; j++) {
      beta[i][j]=betaval;
    }
  }
  ZlabelLDA zelda=new ZlabelLDA(docs,zlabels,confidenceValue,alpha,beta,noOfSamples);
  boolean retVal=zelda.zLDA();
  if (!retVal) {
    appendLog("String_Node_Str");
    return;
  }
  double[][] theta, phi;
  theta=zelda.getTheta();
  phi=zelda.getPhi();
  Map<String,Integer> dictionary=dtwc.getTermIndex();
  Map<Integer,String> revDict=dtwc.getIndexTerm();
  List<List<Map.Entry<String,Double>>> topicWords=new ArrayList<List<Map.Entry<String,Double>>>();
  for (int i=0; i < T; i++) {
    topicWords.add(new ArrayList<Map.Entry<String,Double>>());
  }
  for (int i=0; i < T; i++) {
    for (int j=0; j < W; j++) {
      if (phi[i][j] > 0.001) {
        topicWords.get(i).add(new AbstractMap.SimpleEntry<String,Double>(revDict.get(j),new Double(phi[i][j])));
      }
    }
  }
  try {
    FileWriter fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < T; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      Collections.sort(topicWords.get(i),new Comparator<Map.Entry<String,Double>>(){
        @Override public int compare(        Entry<String,Double> arg0,        Entry<String,Double> arg1){
          return -(arg0.getValue()).compareTo(arg1.getValue());
        }
      }
);
      for (int j=0; (j < topicWords.get(i).size() && j < 50); j++) {
        fw.write(topicWords.get(i).get(j).getKey() + "String_Node_Str" + topicWords.get(i).get(j).getValue()+ "String_Node_Str");
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
    fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < T; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      for (int j=0; j < phi[i].length; j++) {
        if (phi[i][j] > 0.001) {
          fw.write(phi[i][j] + "String_Node_Str");
        }
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
    fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < docs.length; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      for (int j=0; j < theta[i].length; j++) {
        fw.write(theta[i][j] + "String_Node_Str");
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
  }
 catch (  Exception e) {
    appendLog("String_Node_Str" + e);
  }
  appendLog("String_Node_Str");
}

Fixed version (ground truth):
protected void runLDA(File dir,File seedFile,int numTopics,int noOfSamples,double alphaval,double betaval,double confidenceValue,String outputdir){
  File[] listOfFiles=dir.listFiles();
  List<File> inputFiles=new ArrayList<File>();
  for (  File f : listOfFiles)   inputFiles.add(f);
  if (inputFiles.size() == 0) {
    appendLog("String_Node_Str");
    return;
  }
  File preSeedFile;
  if (seedFile.isDirectory()) {
    File[] listSeedFiles=seedFile.listFiles();
    preSeedFile=listSeedFiles[0];
  }
 else {
    preSeedFile=seedFile;
  }
  System.out.println("String_Node_Str");
  appendLog("String_Node_Str");
  DTWC dtwc=new DTWC(inputFiles,preSeedFile);
  dtwc.computeDocumentVectors();
  int[][][] zlabels=dtwc.getTopicSeedsAsInt();
  int[][] docs=dtwc.getDocVectorsAsInt();
  int T=numTopics;
  int W=dtwc.getVocabSize();
  double[][] alpha=new double[1][T];
  for (int i=0; i < T; i++) {
    alpha[0][i]=alphaval;
  }
  double[][] beta=new double[T][W];
  for (int i=0; i < T; i++) {
    for (int j=0; j < W; j++) {
      beta[i][j]=betaval;
    }
  }
  ZlabelLDA zelda=new ZlabelLDA(docs,zlabels,confidenceValue,alpha,beta,noOfSamples);
  boolean retVal=zelda.zLDA();
  if (!retVal) {
    appendLog("String_Node_Str");
    return;
  }
  double[][] theta, phi;
  theta=zelda.getTheta();
  phi=zelda.getPhi();
  Map<String,Integer> dictionary=dtwc.getTermIndex();
  Map<Integer,String> revDict=dtwc.getIndexTerm();
  List<List<Map.Entry<String,Double>>> topicWords=new ArrayList<List<Map.Entry<String,Double>>>();
  for (int i=0; i < T; i++) {
    topicWords.add(new ArrayList<Map.Entry<String,Double>>());
  }
  for (int i=0; i < T; i++) {
    for (int j=0; j < W; j++) {
      if (phi[i][j] > 0.001) {
        topicWords.get(i).add(new AbstractMap.SimpleEntry<String,Double>(revDict.get(j),new Double(phi[i][j])));
      }
    }
  }
  appendLog("String_Node_Str" + outputdir + "String_Node_Str");
  try {
    FileWriter fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < T; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      Collections.sort(topicWords.get(i),new Comparator<Map.Entry<String,Double>>(){
        @Override public int compare(        Entry<String,Double> arg0,        Entry<String,Double> arg1){
          return -(arg0.getValue()).compareTo(arg1.getValue());
        }
      }
);
      for (int j=0; (j < topicWords.get(i).size() && j < 50); j++) {
        fw.write(topicWords.get(i).get(j).getKey() + "String_Node_Str" + topicWords.get(i).get(j).getValue()+ "String_Node_Str");
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
    appendLog("String_Node_Str" + outputdir + "String_Node_Str");
    fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < T; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      for (int j=0; j < phi[i].length; j++) {
        if (phi[i][j] > 0.001) {
          fw.write(phi[i][j] + "String_Node_Str");
        }
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
    appendLog("String_Node_Str" + outputdir + "String_Node_Str");
    fw=new FileWriter(new File(outputdir + "String_Node_Str"));
    for (int i=0; i < docs.length; i++) {
      fw.write("String_Node_Str" + i + "String_Node_Str");
      for (int j=0; j < theta[i].length; j++) {
        fw.write(theta[i][j] + "String_Node_Str");
      }
      fw.write("String_Node_Str");
      fw.flush();
    }
    fw.flush();
    fw.close();
  }
 catch (  Exception e) {
    appendLog("String_Node_Str" + e);
  }
  appendLog("String_Node_Str");
}