Program: 19947
Project: 19947
Buggy source:
/** 
 * Loads the phone list, which possibly contains the sizes (number of states) of models.
 * @param path the path to a density file
 * @param name the name of the data
 * @param props the properties for this set of HMMs
 * @throws FileNotFoundException if a file cannot be found
 * @throws IOException if an error occurs while loading the data
 */
private void loadPhoneList(boolean useCDUnits,InputStream inputStream,String path,SphinxProperties props) throws FileNotFoundException, IOException {
  int token_type;
  int numState=0;
  int numStatePerHMM;
  int numContextIndependentTiedState;
  int numStreams=1;
  int numGaussiansPerState=1;
  String version;
  boolean sameSizedModels;
  boolean tmatSkip;
  ExtendedStreamTokenizer est=new ExtendedStreamTokenizer(inputStream,'#',false);
  meansPool=new Pool("String_Node_Str");
  variancePool=new Pool("String_Node_Str");
  mixtureWeightsPool=new Pool("String_Node_Str");
  matrixPool=new Pool("String_Node_Str");
  senonePool=new Pool("String_Node_Str");
  float distFloor=props.getFloat(AcousticModel.PROP_MC_FLOOR,AcousticModel.PROP_MC_FLOOR_DEFAULT);
  float mixtureWeightFloor=props.getFloat(AcousticModel.PROP_MW_FLOOR,AcousticModel.PROP_MW_FLOOR_DEFAULT);
  float transitionProbabilityFloor=props.getFloat(AcousticModel.PROP_TP_FLOOR,AcousticModel.PROP_TP_FLOOR_DEFAULT);
  float varianceFloor=props.getFloat(AcousticModel.PROP_VARIANCE_FLOOR,AcousticModel.PROP_VARIANCE_FLOOR_DEFAULT);
  logger.info("String_Node_Str");
  logger.info(path);
  version="String_Node_Str";
  est.expectString("String_Node_Str");
  est.expectString(version);
  est.expectString("String_Node_Str");
  sameSizedModels=est.getString().equals("String_Node_Str");
  if (sameSizedModels) {
    est.expectString("String_Node_Str");
    numState=est.getInt("String_Node_Str");
  }
  est.expectString("String_Node_Str");
  tmatSkip=est.getString().equals("String_Node_Str");
  int stateIndex;
  int unitCount;
  String attribute;
  for (stateIndex=0, unitCount=0; ; ) {
    String phone=est.getString();
    if (est.isEOF()) {
      break;
    }
    int size=numState;
    if (!sameSizedModels) {
      size=est.getInt("String_Node_Str");
    }
    phoneList.put(phone,new Integer(size));
    logger.fine("String_Node_Str" + phone + "String_Node_Str"+ size);
    int[] stid=new int[size];
    String position="String_Node_Str";
    for (int j=0; j < size; j++, stateIndex++) {
      stid[j]=stateIndex;
    }
    if (phone.equals(SILENCE_CIPHONE)) {
      attribute=FILLER;
    }
 else {
      attribute="String_Node_Str";
    }
    Unit unit=new Unit(phone,attribute.equals(FILLER));
    contextIndependentUnits.put(unit.getName(),unit);
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + unit + "String_Node_Str"+ size+ "String_Node_Str");
    }
    if (unit.isFiller() && unit.getName().equals(SILENCE_CIPHONE)) {
      unit=Unit.SILENCE;
    }
    addModelToDensityPool(meansPool,stid,numStreams,numGaussiansPerState);
    addModelToDensityPool(variancePool,stid,numStreams,numGaussiansPerState);
    addModelToMixtureWeightPool(mixtureWeightsPool,stid,numStreams,numGaussiansPerState,mixtureWeightFloor);
    addModelToTransitionMatricesPool(matrixPool,unitCount,stid.length,transitionProbabilityFloor,tmatSkip);
    addModelToSenonePool(senonePool,stid,distFloor);
    float[][] transitionMatrix=(float[][])matrixPool.get(unitCount);
    SenoneSequence ss=getSenoneSequence(stid);
    HMM hmm=new HMM(unit,ss,transitionMatrix,HMMPosition.lookup(position));
    hmmManager.put(hmm);
    unitCount++;
  }
  est.close();
}

Fixed version (ground truth):
/** 
 * Loads the phone list, which possibly contains the sizes (number of states) of models.
 * @param useCDUnits if true, uses context dependent units
 * @param inputStream the open input stream to use
 * @param path the path to a density file
 * @param props the properties for this set of HMMs
 * @throws FileNotFoundException if a file cannot be found
 * @throws IOException if an error occurs while loading the data
 */
private void loadPhoneList(boolean useCDUnits,InputStream inputStream,String path,SphinxProperties props) throws FileNotFoundException, IOException {
  int token_type;
  int numState=0;
  int numStatePerHMM;
  int numContextIndependentTiedState;
  int numStreams=1;
  int numGaussiansPerState=1;
  String version;
  boolean sameSizedModels;
  boolean tmatSkip;
  ExtendedStreamTokenizer est=new ExtendedStreamTokenizer(inputStream,'#',false);
  meansPool=new Pool("String_Node_Str");
  variancePool=new Pool("String_Node_Str");
  mixtureWeightsPool=new Pool("String_Node_Str");
  matrixPool=new Pool("String_Node_Str");
  senonePool=new Pool("String_Node_Str");
  float distFloor=props.getFloat(AcousticModel.PROP_MC_FLOOR,AcousticModel.PROP_MC_FLOOR_DEFAULT);
  float mixtureWeightFloor=props.getFloat(AcousticModel.PROP_MW_FLOOR,AcousticModel.PROP_MW_FLOOR_DEFAULT);
  float transitionProbabilityFloor=props.getFloat(AcousticModel.PROP_TP_FLOOR,AcousticModel.PROP_TP_FLOOR_DEFAULT);
  float varianceFloor=props.getFloat(AcousticModel.PROP_VARIANCE_FLOOR,AcousticModel.PROP_VARIANCE_FLOOR_DEFAULT);
  logger.info("String_Node_Str");
  logger.info(path);
  version="String_Node_Str";
  est.expectString("String_Node_Str");
  est.expectString(version);
  est.expectString("String_Node_Str");
  sameSizedModels=est.getString().equals("String_Node_Str");
  if (sameSizedModels) {
    est.expectString("String_Node_Str");
    numState=est.getInt("String_Node_Str");
  }
  est.expectString("String_Node_Str");
  tmatSkip=est.getString().equals("String_Node_Str");
  int stateIndex;
  int unitCount;
  String attribute;
  for (stateIndex=0, unitCount=0; ; ) {
    String phone=est.getString();
    if (est.isEOF()) {
      break;
    }
    int size=numState;
    if (!sameSizedModels) {
      size=est.getInt("String_Node_Str");
    }
    phoneList.put(phone,new Integer(size));
    logger.fine("String_Node_Str" + phone + "String_Node_Str"+ size);
    int[] stid=new int[size];
    String position="String_Node_Str";
    for (int j=0; j < size; j++, stateIndex++) {
      stid[j]=stateIndex;
    }
    if (phone.equals(SILENCE_CIPHONE)) {
      attribute=FILLER;
    }
 else {
      attribute="String_Node_Str";
    }
    Unit unit=new Unit(phone,attribute.equals(FILLER));
    contextIndependentUnits.put(unit.getName(),unit);
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + unit + "String_Node_Str"+ size+ "String_Node_Str");
    }
    if (unit.isFiller() && unit.getName().equals(SILENCE_CIPHONE)) {
      unit=Unit.SILENCE;
    }
    addModelToDensityPool(meansPool,stid,numStreams,numGaussiansPerState);
    addModelToDensityPool(variancePool,stid,numStreams,numGaussiansPerState);
    addModelToMixtureWeightPool(mixtureWeightsPool,stid,numStreams,numGaussiansPerState,mixtureWeightFloor);
    addModelToTransitionMatricesPool(matrixPool,unitCount,stid.length,transitionProbabilityFloor,tmatSkip);
    addModelToSenonePool(senonePool,stid,distFloor);
    float[][] transitionMatrix=(float[][])matrixPool.get(unitCount);
    SenoneSequence ss=getSenoneSequence(stid);
    HMM hmm=new HMM(unit,ss,transitionMatrix,HMMPosition.lookup(position));
    hmmManager.put(hmm);
    unitCount++;
  }
  est.close();
}