Program: 19769
Project: 19769
Buggy source:
/** 
 * Computes confidences for a Result and returns a ConfidenceResult, a compact representation of all the hypothesis contained in the result together with their per-word and per-path confidences.
 * @param result the result to compute confidences for
 * @return a confidence result
 */
public ConfidenceResult score(Result result){
  Lattice lattice=new Lattice(result);
  LatticeOptimizer lop=new LatticeOptimizer(lattice);
  lop.optimize();
  lattice.computeNodePosteriors(languageWeight);
  SausageMaker sm=new SausageMaker(lattice);
  Sausage s=sm.makeSausage();
  ConfidenceResult sausage=(ConfidenceResult)s;
  WordResultPath mapPath=new WordResultPath();
  Token mapToken=result.getBestToken();
  int slot=sausage.size() - 1;
  while (mapToken != null) {
    while (!mapToken.isWord()) {
      mapToken=mapToken.getPredecessor();
    }
    if (mapToken != null) {
      String word=mapToken.getWord().getSpelling();
      ConfusionSet cs=sausage.getConfusionSet(slot);
      WordResult wr=null;
      while (slot >= 0 && (((wr=cs.getWordResult(word)) == null) && ((wr=cs.getWordResult("String_Node_Str")) != null))) {
        slot--;
        cs=sausage.getConfusionSet(slot);
      }
      if (wr != null) {
        mapPath.add(0,wr);
      }
 else {
        throw new Error("String_Node_Str" + slot + "String_Node_Str"+ word);
      }
      slot--;
      mapToken=mapToken.getPredecessor();
    }
 else {
      break;
    }
  }
  return (new MAPConfidenceResult(sausage,mapPath));
}

Fixed version (ground truth):
/** 
 * Computes confidences for a Result and returns a ConfidenceResult, a compact representation of all the hypothesis contained in the result together with their per-word and per-path confidences.
 * @param result the result to compute confidences for
 * @return a confidence result
 */
public ConfidenceResult score(Result result){
  Lattice lattice=new Lattice(result);
  LatticeOptimizer lop=new LatticeOptimizer(lattice);
  lop.optimize();
  lattice.computeNodePosteriors(languageWeight);
  SausageMaker sm=new SausageMaker(lattice);
  Sausage s=sm.makeSausage();
  if (dumpLattice) {
    lattice.dumpAISee("String_Node_Str","String_Node_Str");
  }
  if (dumpSausage) {
    s.dumpAISee("String_Node_Str","String_Node_Str");
  }
  ConfidenceResult sausage=(ConfidenceResult)s;
  WordResultPath mapPath=new WordResultPath();
  Token mapToken=result.getBestToken();
  int slot=sausage.size() - 1;
  while (mapToken != null) {
    while (!mapToken.isWord()) {
      mapToken=mapToken.getPredecessor();
    }
    if (mapToken != null) {
      String word=mapToken.getWord().getSpelling();
      ConfusionSet cs=sausage.getConfusionSet(slot);
      WordResult wr=null;
      while (slot >= 0 && (((wr=cs.getWordResult(word)) == null) && (((wr=cs.getWordResult("String_Node_Str")) != null) || ((wr=cs.getWordResult("String_Node_Str")) != null)))) {
        slot--;
        cs=sausage.getConfusionSet(slot);
      }
      if (wr != null) {
        mapPath.add(0,wr);
      }
 else {
        cs.dump("String_Node_Str" + slot);
        throw new Error("String_Node_Str" + slot + "String_Node_Str"+ word);
      }
      slot--;
      mapToken=mapToken.getPredecessor();
    }
 else {
      break;
    }
  }
  return (new MAPConfidenceResult(sausage,mapPath));
}