Program: 19794
Project: 19794
Buggy source:
/** 
 * Compiles the grammar into a sentence hmm. A GrammarJob is created for the initial grammar node and added to the GrammarJob queue. While there are jobs left on the grammar job queue, a job is removed from the queue and the associated grammar node is expanded and attached to the tails. GrammarJobs for the successors are added to the grammar job queue.
 */
protected Collection compileGrammar(){
  List gstateList=new ArrayList();
  Timer.start("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=grammar.getGrammarNodes().iterator(); i.hasNext(); ) {
    GState gstate=createGState((GrammarNode)i.next());
    gstateList.add(gstate);
  }
  Timer.stop("String_Node_Str");
  addStartingPath();
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.collectContexts();
  }
  Timer.stop("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.expand();
  }
  Timer.stop("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.connect();
  }
  Timer.stop("String_Node_Str");
  SentenceHMMState initialState=findStartingState();
  if (addOutOfGrammarBranch) {
    CIPhoneLoop phoneLoop=new CIPhoneLoop(acousticModel,logPhoneInsertionProbability);
    SentenceHMMState firstBranchState=(SentenceHMMState)phoneLoop.getSearchGraph().getInitialState();
    initialState.connect(getArc(firstBranchState,logOne,logOne,logOutOfGrammarBranchProbability));
  }
  searchGraph=new FlatSearchGraph(initialState);
  Timer.stop("String_Node_Str");
  if (dumpGStates) {
    for (Iterator i=grammar.getGrammarNodes().iterator(); i.hasNext(); ) {
      GState gstate=getGState((GrammarNode)i.next());
      gstate.dumpInfo();
    }
  }
  return SentenceHMMState.collectStates(initialState);
}

Fixed version (ground truth):
/** 
 * Compiles the grammar into a sentence hmm. A GrammarJob is created for the initial grammar node and added to the GrammarJob queue. While there are jobs left on the grammar job queue, a job is removed from the queue and the associated grammar node is expanded and attached to the tails. GrammarJobs for the successors are added to the grammar job queue.
 */
protected Collection compileGrammar(){
  List gstateList=new ArrayList();
  Timer.start("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=grammar.getGrammarNodes().iterator(); i.hasNext(); ) {
    GState gstate=createGState((GrammarNode)i.next());
    gstateList.add(gstate);
  }
  Timer.stop("String_Node_Str");
  addStartingPath();
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.collectContexts();
  }
  Timer.stop("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.expand();
  }
  Timer.stop("String_Node_Str");
  Timer.start("String_Node_Str");
  for (Iterator i=gstateList.iterator(); i.hasNext(); ) {
    GState gstate=(GState)i.next();
    gstate.connect();
  }
  Timer.stop("String_Node_Str");
  SentenceHMMState initialState=findStartingState();
  if (addOutOfGrammarBranch) {
    CIPhoneLoop phoneLoop=new CIPhoneLoop(phoneLoopAcousticModel,logPhoneInsertionProbability);
    SentenceHMMState firstBranchState=(SentenceHMMState)phoneLoop.getSearchGraph().getInitialState();
    initialState.connect(getArc(firstBranchState,logOne,logOne,logOutOfGrammarBranchProbability));
  }
  searchGraph=new FlatSearchGraph(initialState);
  Timer.stop("String_Node_Str");
  if (dumpGStates) {
    for (Iterator i=grammar.getGrammarNodes().iterator(); i.hasNext(); ) {
      GState gstate=getGState((GrammarNode)i.next());
      gstate.dumpInfo();
    }
  }
  return SentenceHMMState.collectStates(initialState);
}