Program: 19974
Project: 19974
Buggy source:
/** 
 * Loads the language model from the given location. 
 * @param location the location of the language model
 */
private void loadBinary(String location) throws IOException {
  FileInputStream fis=new FileInputStream(location);
  DataInputStream stream=new DataInputStream(new BufferedInputStream(fis));
  int headerLength=readInt(stream,bigEndian);
  if (headerLength != (DARPA_LM_HEADER.length() + 1)) {
    headerLength=Utilities.swapInteger(headerLength);
    if (headerLength == (DARPA_LM_HEADER.length() + 1)) {
      bigEndian=false;
      System.out.println("String_Node_Str");
    }
 else {
      throw new Error("String_Node_Str" + headerLength + "String_Node_Str");
    }
  }
 else {
    System.out.println("String_Node_Str");
  }
  String header=readString(stream,headerLength - 1);
  readByte(stream);
  if (!header.equals(DARPA_LM_HEADER)) {
    throw new Error("String_Node_Str" + header);
  }
  int fileNameLength=readInt(stream,bigEndian);
  for (int i=0; i < fileNameLength; i++) {
    readByte(stream);
  }
  numberUnigrams=0;
  logBigramSegmentSize=LOG2_BIGRAM_SEGMENT_SIZE_DEFAULT;
  int version=readInt(stream,bigEndian);
  System.out.println("String_Node_Str" + version);
  if (version <= 0) {
    readInt(stream,bigEndian);
    int formatLength;
    for (; ; ) {
      if ((formatLength=readInt(stream,bigEndian)) == 0) {
        break;
      }
      for (int i=0; i < formatLength; i++) {
        readByte(stream);
      }
    }
    if (version <= -2) {
      logBigramSegmentSize=readInt(stream,bigEndian);
      if (logBigramSegmentSize < 1 || logBigramSegmentSize > 15) {
        throw new Error("String_Node_Str");
      }
    }
    numberUnigrams=readInt(stream,bigEndian);
  }
 else {
    numberUnigrams=version;
  }
  int bigramSegmentSize=1 << logBigramSegmentSize;
  if (numberUnigrams <= 0) {
    throw new Error("String_Node_Str" + numberUnigrams + "String_Node_Str");
  }
  System.out.println("String_Node_Str" + numberUnigrams);
  numberBigrams=readInt(stream,bigEndian);
  if (numberBigrams < 0) {
    throw new Error("String_Node_Str" + numberBigrams);
  }
  System.out.println("String_Node_Str" + numberBigrams);
  numberTrigrams=readInt(stream,bigEndian);
  if (numberTrigrams < 0) {
    throw new Error("String_Node_Str" + numberTrigrams);
  }
  System.out.println("String_Node_Str" + numberTrigrams);
  unigrams=readUnigrams(stream,numberUnigrams + 1,bigEndian);
  if (numberBigrams > 0) {
    bigramOffset=bytesRead;
    int bytesToSkip=(numberBigrams + 1) * LargeTrigramModel.BYTES_PER_BIGRAM;
    stream.skipBytes(bytesToSkip);
    bytesRead+=bytesToSkip;
  }
  if (numberTrigrams > 0) {
    trigramOffset=bytesRead;
    int bytesToSkip=numberTrigrams * LargeTrigramModel.BYTES_PER_TRIGRAM;
    stream.skipBytes(bytesToSkip);
    bytesRead+=bytesToSkip;
  }
  if (numberBigrams > 0) {
    this.bigramProbTable=readFloatTable(stream,bigEndian);
  }
  if (numberTrigrams > 0) {
    trigramBackoffTable=readFloatTable(stream,bigEndian);
    trigramProbTable=readFloatTable(stream,bigEndian);
    int trigramSegTableSize=((numberBigrams + 1) / bigramSegmentSize) + 1;
    trigramSegmentTable=readIntTable(stream,bigEndian,trigramSegTableSize);
  }
  int wordsStringLength=readInt(stream,bigEndian);
  if (wordsStringLength <= 0) {
    throw new Error("String_Node_Str" + wordsStringLength);
  }
  String wordsString=readString(stream,wordsStringLength).toLowerCase();
  int numberWords=0;
  for (int i=0; i < wordsStringLength; i++) {
    if (wordsString.charAt(i) == '\0') {
      numberWords++;
    }
  }
  if (numberWords != numberUnigrams) {
    throw new Error("String_Node_Str" + numberWords);
  }
  this.words=wordsString.split("String_Node_Str");
  applyUnigramWeight();
  applyLanguageWeightAndWip();
  fis.close();
  stream.close();
  is=new FileInputStream(location);
  fileChannel=is.getChannel();
}

Fixed version (ground truth):
/** 
 * Loads the language model from the given location. 
 * @param location the location of the language model
 */
private void loadBinary(String location) throws IOException {
  FileInputStream fis=new FileInputStream(location);
  DataInputStream stream=new DataInputStream(new BufferedInputStream(fis));
  int headerLength=readInt(stream,bigEndian);
  if (headerLength != (DARPA_LM_HEADER.length() + 1)) {
    headerLength=Utilities.swapInteger(headerLength);
    if (headerLength == (DARPA_LM_HEADER.length() + 1)) {
      bigEndian=false;
      System.out.println("String_Node_Str");
    }
 else {
      throw new Error("String_Node_Str" + headerLength + "String_Node_Str");
    }
  }
 else {
    System.out.println("String_Node_Str");
  }
  String header=readString(stream,headerLength - 1);
  readByte(stream);
  if (!header.equals(DARPA_LM_HEADER)) {
    throw new Error("String_Node_Str" + header);
  }
  int fileNameLength=readInt(stream,bigEndian);
  for (int i=0; i < fileNameLength; i++) {
    readByte(stream);
  }
  numberUnigrams=0;
  logBigramSegmentSize=LOG2_BIGRAM_SEGMENT_SIZE_DEFAULT;
  int version=readInt(stream,bigEndian);
  System.out.println("String_Node_Str" + version);
  if (version <= 0) {
    readInt(stream,bigEndian);
    int formatLength;
    for (; ; ) {
      if ((formatLength=readInt(stream,bigEndian)) == 0) {
        break;
      }
      for (int i=0; i < formatLength; i++) {
        readByte(stream);
      }
    }
    if (version <= -2) {
      logBigramSegmentSize=readInt(stream,bigEndian);
      if (logBigramSegmentSize < 1 || logBigramSegmentSize > 15) {
        throw new Error("String_Node_Str");
      }
    }
    numberUnigrams=readInt(stream,bigEndian);
  }
 else {
    numberUnigrams=version;
  }
  int bigramSegmentSize=1 << logBigramSegmentSize;
  if (numberUnigrams <= 0) {
    throw new Error("String_Node_Str" + numberUnigrams + "String_Node_Str");
  }
  System.out.println("String_Node_Str" + numberUnigrams);
  numberBigrams=readInt(stream,bigEndian);
  if (numberBigrams < 0) {
    throw new Error("String_Node_Str" + numberBigrams);
  }
  System.out.println("String_Node_Str" + numberBigrams);
  numberTrigrams=readInt(stream,bigEndian);
  if (numberTrigrams < 0) {
    throw new Error("String_Node_Str" + numberTrigrams);
  }
  System.out.println("String_Node_Str" + numberTrigrams);
  unigrams=readUnigrams(stream,numberUnigrams + 1,bigEndian);
  if (numberBigrams > 0) {
    bigramOffset=bytesRead;
    int bytesToSkip=(numberBigrams + 1) * LargeTrigramModel.BYTES_PER_BIGRAM;
    stream.skipBytes(bytesToSkip);
    bytesRead+=bytesToSkip;
  }
  if (numberTrigrams > 0) {
    trigramOffset=bytesRead;
    int bytesToSkip=numberTrigrams * LargeTrigramModel.BYTES_PER_TRIGRAM;
    stream.skipBytes(bytesToSkip);
    bytesRead+=bytesToSkip;
  }
  if (numberBigrams > 0) {
    this.bigramProbTable=readFloatTable(stream,bigEndian);
  }
  if (numberTrigrams > 0) {
    trigramBackoffTable=readFloatTable(stream,bigEndian);
    trigramProbTable=readFloatTable(stream,bigEndian);
    int trigramSegTableSize=((numberBigrams + 1) / bigramSegmentSize) + 1;
    trigramSegmentTable=readIntTable(stream,bigEndian,trigramSegTableSize);
  }
  int wordsStringLength=readInt(stream,bigEndian);
  if (wordsStringLength <= 0) {
    throw new Error("String_Node_Str" + wordsStringLength);
  }
  String wordsString=readString(stream,wordsStringLength).toLowerCase();
  int numberWords=0;
  for (int i=0; i < wordsStringLength; i++) {
    if (wordsString.charAt(i) == '\0') {
      numberWords++;
    }
  }
  if (numberWords != numberUnigrams) {
    throw new Error("String_Node_Str" + numberWords);
  }
  this.words=wordsString.split("String_Node_Str");
  applyUnigramWeight();
  if (applyLanguageWeightAndWip) {
    applyLanguageWeightAndWip();
  }
  fis.close();
  stream.close();
  is=new FileInputStream(location);
  fileChannel=is.getChannel();
}