Program: 37837
Project: 37837
Buggy source:
public List<? extends EntryWithScore<Unit>> parseHeader(String hdr,ParseState hdrMatches,ParseState context,int debugLvl,short[][] forcedTags,UnitSpan forcedUnit,int k,Vector<UnitFeatures> featureList){
  if (debugLvl > 0)   System.out.println(hdr);
  if (isURL(hdr))   return null;
  hdrMatches=getTokensWithSpan(hdr,forcedUnit,hdrMatches);
  if (hdrMatches.tokens.size() == 0)   return null;
  if (featureList != null)   featureList.clear();
  List<String> hdrToks=hdrMatches.tokens;
  List<? extends HasWord> sentence=tokenScorer.cacheScores(hdrMatches,forcedTags,debugLvl,featureList != null,forcedUnit,context);
  if (parser.parse(sentence)) {
    TObjectFloatHashMap<UnitFeatures> units=new TObjectFloatHashMap<UnitFeatures>();
    List<ScoredObject<Tree>> trees=parser.getBestParses();
    if (k > 1) {
      double bestScore=(trees.size() > 0 ? trees.get(0).score() : Double.POSITIVE_INFINITY) - Double.MIN_VALUE;
      List<ScoredObject<Tree>> treesK=parser.getKBestParses(k);
      for (int r=0; r < treesK.size(); r++) {
        if (treesK.get(r).score() < bestScore && trees.size() < k) {
          trees.add(treesK.get(r));
        }
      }
    }
    for (    ScoredObject<Tree> stree : trees) {
      Tree tree=stree.object();
      Vector<Tree> unitNodes=new Vector<Tree>();
      tree.setSpans();
      getTopUnitNodes(tree,unitNodes);
      float treeScore=(float)parser.scoreBinarizedTree(tree,0,debugLvl - 1);
      if (debugLvl > 0)       System.out.println(tree + "String_Node_Str" + tree.score()+ "String_Node_Str"+ treeScore);
      FeatureVector treeFeatureVector=null;
      if (featureList != null) {
        treeFeatureVector=extractTreeFeatureVector(tree,0,tmpFVec.clear());
      }
      if (unitNodes.size() > 2)       throw new NotImplementedException();
      if (unitNodes.size() == 0)       continue;
      Tree unitTree=unitNodes.get(0);
      getUnit(unitTree,hdrToks,bestUnits,hdr);
      if (unitNodes.size() > 1)       getUnit(unitNodes.get(1),hdrToks,bestUnits2,hdr);
      int numUnits=unitNodes.size();
      if (bestUnits != null && bestUnits.size() > 0) {
        float baseScore=(float)bestUnits.get(0).getScore();
        for (int a=0; a < bestUnits.size(); a++) {
          Unit bestUnit=bestUnits.get(a).getKey();
          float val=(float)((float)bestUnits.get(a).getScore() + treeScore - baseScore);
          if (numUnits == 1 || bestUnits2.size() == 0) {
            units.adjustOrPutValue(bestUnits.get(a),val,val);
            if (treeFeatureVector != null)             addFeatureVector(featureList,bestUnits.get(a),null,treeFeatureVector,val,bestUnit);
          }
 else {
            float baseScore2=(float)bestUnits2.get(0).getScore();
            for (int a2=0; a2 < bestUnits2.size(); a2++) {
              Unit bestUnit2=bestUnits2.get(a2).getKey();
              float val2=(float)bestUnits2.get(a2).getScore() - baseScore2 + val;
              Unit newUnit=new UnitPair(bestUnit,bestUnit2,UnitPair.OpType.Alt,bestUnit.getParentQuantity());
              UnitFeatures newUnitF=addFeatureVector(featureList,bestUnits.get(a),bestUnits2.get(a2),treeFeatureVector,val2,newUnit);
              units.adjustOrPutValue(newUnitF,val2,val2);
            }
          }
        }
      }
    }
    if (units.size() > 0) {
      Vector<EntryWithScore<Unit>> possibleUnits=new Vector<EntryWithScore<Unit>>();
      double logNorm=0;
      for (TObjectFloatIterator<UnitFeatures> iter=units.iterator(); iter.hasNext(); ) {
        iter.advance();
        if (iter.value() > 0)         possibleUnits.add(new UnitSpan(iter.key().getKey(),iter.value(),iter.key().start(),iter.key().end()));
        logNorm=RobustMath.logSumExp(logNorm,iter.value());
      }
      Collections.sort(possibleUnits);
      if (possibleUnits.size() > k) {
        while (possibleUnits.size() > k) {
          possibleUnits.remove(possibleUnits.size() - 1);
        }
      }
      if (k > 1) {
      }
      if (featureList != null) {
        for (        UnitFeatures obj : featureList) {
          obj.checkCorrectness(params.weights);
        }
        Collections.sort(featureList);
        while (featureList.size() > k) {
          featureList.remove(featureList.size() - 1);
        }
        if (debugLvl > 0) {
          for (          UnitFeatures unitObj : featureList) {
            System.out.println(unitObj.getKey().getBaseName() + "String_Node_Str" + unitObj.getScore());
            unitObj.fvals.print(Params.FTypes.values());
          }
        }
      }
      return possibleUnits;
    }
  }
 else {
  }
  return null;
}

Fixed version (ground truth):
public List<? extends EntryWithScore<Unit>> parseHeader(String hdr,ParseState hdrMatches,ParseState context,int debugLvl,short[][] forcedTags,UnitSpan forcedUnit,int k,Vector<UnitFeatures> featureList){
  if (debugLvl > 0)   System.out.println(hdr);
  if (isURL(hdr))   return null;
  hdrMatches=getTokensWithSpan(hdr,forcedUnit,hdrMatches);
  if (hdrMatches.tokens.size() == 0)   return null;
  if (featureList != null)   featureList.clear();
  List<String> hdrToks=hdrMatches.tokens;
  List<? extends HasWord> sentence=tokenScorer.cacheScores(hdrMatches,forcedTags,debugLvl,featureList != null,forcedUnit,context);
  if (parser.parse(sentence)) {
    TObjectFloatHashMap<UnitFeatures> units=new TObjectFloatHashMap<UnitFeatures>();
    List<ScoredObject<Tree>> trees=parser.getBestParses();
    if (trees.size() < k) {
      double bestScore=(trees.size() > 0 ? trees.get(0).score() : Double.POSITIVE_INFINITY) - Double.MIN_VALUE;
      List<ScoredObject<Tree>> treesK=parser.getKBestParses(k);
      for (int r=0; r < treesK.size(); r++) {
        if (treesK.get(r).score() < bestScore && trees.size() < k) {
          trees.add(treesK.get(r));
        }
      }
    }
    for (    ScoredObject<Tree> stree : trees) {
      Tree tree=stree.object();
      Vector<Tree> unitNodes=new Vector<Tree>();
      tree.setSpans();
      getTopUnitNodes(tree,unitNodes);
      float treeScore=(float)parser.scoreBinarizedTree(tree,0,debugLvl - 1);
      if (debugLvl > 0)       System.out.println(tree + "String_Node_Str" + tree.score()+ "String_Node_Str"+ treeScore);
      FeatureVector treeFeatureVector=null;
      if (featureList != null) {
        treeFeatureVector=extractTreeFeatureVector(tree,0,tmpFVec.clear());
      }
      if (unitNodes.size() > 2)       throw new NotImplementedException();
      if (unitNodes.size() == 0)       continue;
      Tree unitTree=unitNodes.get(0);
      getUnit(unitTree,hdrToks,bestUnits,hdr);
      if (unitNodes.size() > 1)       getUnit(unitNodes.get(1),hdrToks,bestUnits2,hdr);
      int numUnits=unitNodes.size();
      if (bestUnits != null && bestUnits.size() > 0) {
        float baseScore=(float)bestUnits.get(0).getScore();
        for (int a=0; a < bestUnits.size(); a++) {
          Unit bestUnit=bestUnits.get(a).getKey();
          float val=(float)((float)bestUnits.get(a).getScore() + treeScore - baseScore);
          if (numUnits == 1 || bestUnits2.size() == 0) {
            units.adjustOrPutValue(bestUnits.get(a),val,val);
            if (treeFeatureVector != null)             addFeatureVector(featureList,bestUnits.get(a),null,treeFeatureVector,val,bestUnit);
          }
 else {
            float baseScore2=(float)bestUnits2.get(0).getScore();
            for (int a2=0; a2 < bestUnits2.size(); a2++) {
              Unit bestUnit2=bestUnits2.get(a2).getKey();
              float val2=(float)bestUnits2.get(a2).getScore() - baseScore2 + val;
              Unit newUnit=new UnitPair(bestUnit,bestUnit2,UnitPair.OpType.Alt,bestUnit.getParentQuantity());
              UnitFeatures newUnitF=addFeatureVector(featureList,bestUnits.get(a),bestUnits2.get(a2),treeFeatureVector,val2,newUnit);
              units.adjustOrPutValue(newUnitF,val2,val2);
            }
          }
        }
      }
    }
    if (units.size() > 0) {
      Vector<EntryWithScore<Unit>> possibleUnits=new Vector<EntryWithScore<Unit>>();
      double logNorm=0;
      for (TObjectFloatIterator<UnitFeatures> iter=units.iterator(); iter.hasNext(); ) {
        iter.advance();
        if (iter.value() > 0)         possibleUnits.add(new UnitSpan(iter.key().getKey(),iter.value(),iter.key().start(),iter.key().end()));
        logNorm=RobustMath.logSumExp(logNorm,iter.value());
      }
      Collections.sort(possibleUnits);
      if (possibleUnits.size() > k) {
        while (possibleUnits.size() > k) {
          possibleUnits.remove(possibleUnits.size() - 1);
        }
      }
      if (k > 1) {
      }
      if (featureList != null) {
        for (        UnitFeatures obj : featureList) {
          obj.checkCorrectness(params.weights);
        }
        Collections.sort(featureList);
        while (featureList.size() > k) {
          featureList.remove(featureList.size() - 1);
        }
        if (debugLvl > 0) {
          for (          UnitFeatures unitObj : featureList) {
            System.out.println(unitObj.getKey().getBaseName() + "String_Node_Str" + unitObj.getScore());
            unitObj.fvals.print(Params.FTypes.values(),params.weights);
          }
        }
      }
      return possibleUnits;
    }
  }
 else {
  }
  return null;
}