nus-yam/ex-repair huggingface dataset:
Program: 131592
Project: 131592
Buggy source:
/** 
 * Creates a message and stores it in the "pending message" slot for this edge.
 * @param edge The directed edge for which the message should be created.
 * @param iter The iteration number.
 */
private void createMessage(FgEdge edge,int iter){
  int edgeId=edge.getId();
  Var var=edge.getVar();
  Factor factor=edge.getFactor();
  if (!edge.isVarToFactor() && factor instanceof GlobalFactor) {
    GlobalFactor globalFac=(GlobalFactor)factor;
    globalFac.createMessages(edge.getParent(),msgs,prm.logDomain,iter);
    return;
  }
  DenseFactor msg=msgs[edgeId].newMessage;
  msg.set(prm.logDomain ? 0.0 : 1.0);
  if (edge.isVarToFactor()) {
    getProductOfMessages(edge.getParent(),msg,edge.getChild());
  }
 else {
    DenseFactor prod=new DenseFactor(factor.getVars());
    prod.set((DenseFactor)factor);
    getProductOfMessages(edge.getParent(),prod,edge.getChild());
    if (prm.logDomain) {
      msg=prod.getLogMarginal(new VarSet(var),false);
    }
 else {
      msg=prod.getMarginal(new VarSet(var),false);
    }
  }
  assert(msg.getVars().equals(new VarSet(var)));
  if (prm.normalizeMessages) {
    if (prm.logDomain) {
      msg.logNormalize();
    }
 else {
      msg.normalize();
    }
  }
  msgs[edgeId].newMessage=msg;
}

Fixed version (ground truth):
/** 
 * Creates a message and stores it in the "pending message" slot for this edge.
 * @param edge The directed edge for which the message should be created.
 * @param iter The iteration number.
 */
private void createMessage(FgEdge edge,int iter){
  int edgeId=edge.getId();
  Var var=edge.getVar();
  Factor factor=edge.getFactor();
  if (!edge.isVarToFactor() && factor instanceof GlobalFactor) {
    log.trace("String_Node_Str");
    GlobalFactor globalFac=(GlobalFactor)factor;
    globalFac.createMessages(edge.getParent(),msgs,prm.logDomain,iter);
    return;
  }
  DenseFactor msg=msgs[edgeId].newMessage;
  msg.set(prm.logDomain ? 0.0 : 1.0);
  if (edge.isVarToFactor()) {
    getProductOfMessages(edge.getParent(),msg,edge.getChild());
  }
 else {
    DenseFactor prod=new DenseFactor(factor.getVars());
    prod.set((DenseFactor)factor);
    getProductOfMessages(edge.getParent(),prod,edge.getChild());
    if (prm.logDomain) {
      msg=prod.getLogMarginal(new VarSet(var),false);
    }
 else {
      msg=prod.getMarginal(new VarSet(var),false);
    }
  }
  assert(msg.getVars().equals(new VarSet(var)));
  if (prm.normalizeMessages) {
    if (prm.logDomain) {
      msg.logNormalize();
    }
 else {
      msg.normalize();
    }
  }
  msgs[edgeId].newMessage=msg;
}
Program: 131593
Project: 131593
Buggy source:
public FgInferencerFactory getInfFactory(boolean logDomain){
  BeliefPropagationPrm bpPrm=new BeliefPropagationPrm();
  bpPrm.logDomain=logDomain;
  bpPrm.schedule=BpScheduleType.TREE_LIKE;
  bpPrm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  bpPrm.normalizeMessages=false;
  return bpPrm;
}

Fixed version (ground truth):
public FgInferencerFactory getInfFactory(boolean logDomain){
  BeliefPropagationPrm bpPrm=new BeliefPropagationPrm();
  bpPrm.logDomain=logDomain;
  bpPrm.schedule=BpScheduleType.TREE_LIKE;
  bpPrm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  bpPrm.normalizeMessages=false;
  bpPrm.maxIterations=1;
  return bpPrm;
}
Program: 131595
Project: 131595
Buggy source:
/** 
 * Constructor.
 * @param n The length of the sentence.
 */
public ProjDepTreeFactor(int n,VarType type){
  this.vars=createVarSet(n,type);
  this.n=n;
  rootVars=new LinkVar[n];
  childVars=new LinkVar[n][n];
  VarSet vars=this.getVars();
  for (  Var var : vars) {
    LinkVar link=(LinkVar)var;
    if (link.getParent() == -1) {
      rootVars[link.getChild()]=link;
    }
 else {
      childVars[link.getParent()][link.getChild()]=link;
    }
  }
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param n The length of the sentence.
 */
public ProjDepTreeFactor(int n,VarType type){
  super();
  this.vars=createVarSet(n,type);
  this.n=n;
  rootVars=new LinkVar[n];
  childVars=new LinkVar[n][n];
  VarSet vars=this.getVars();
  for (  Var var : vars) {
    LinkVar link=(LinkVar)var;
    if (link.getParent() == -1) {
      rootVars[link.getChild()]=link;
    }
 else {
      childVars[link.getParent()][link.getChild()]=link;
    }
  }
}
Program: 131600
Project: 131600
Buggy source:
public double evaluate(List<VarConfig> goldConfigs,List<VarConfig> predictedConfigs){
  int numCorrect=0;
  int numTotal=0;
  assert(goldConfigs.size() == predictedConfigs.size());
  for (int i=0; i < goldConfigs.size(); i++) {
    VarConfig gold=goldConfigs.get(i);
    VarConfig pred=predictedConfigs.get(i);
    assert(gold.getVars().equals(pred.getVars()));
    for (    Var v : gold.getVars()) {
      int goldState=gold.getState(v);
      int predState=pred.getState(v);
      if (goldState == predState) {
        numCorrect++;
      }
      numTotal++;
    }
  }
  return (double)numCorrect / numTotal;
}

Fixed version (ground truth):
/** 
 * Computes the accuracy on the PREDICTED variables. 
 */
public double evaluate(List<VarConfig> goldConfigs,List<VarConfig> predictedConfigs){
  int numCorrect=0;
  int numTotal=0;
  assert(goldConfigs.size() == predictedConfigs.size());
  for (int i=0; i < goldConfigs.size(); i++) {
    VarConfig gold=goldConfigs.get(i);
    VarConfig pred=predictedConfigs.get(i);
    for (    Var v : gold.getVars()) {
      if (v.getType() == VarType.PREDICTED) {
        int goldState=gold.getState(v);
        int predState=pred.getState(v);
        if (goldState == predState) {
          numCorrect++;
        }
        numTotal++;
      }
    }
  }
  return (double)numCorrect / numTotal;
}
Program: 131601
Project: 131601
Buggy source:
/** 
 * Gets the state (in this config) for a given variable. 
 */
public int getState(Var var){
  return config.get(var);
}

Fixed version (ground truth):
/** 
 * Gets the state (in this config) for a given variable. 
 */
public int getState(Var var){
  Integer state=config.get(var);
  if (state == null) {
    throw new RuntimeException("String_Node_Str" + var);
  }
  return state;
}
Program: 131603
Project: 131603
Buggy source:
public BrownClusterTagger(Alphabet<Label> alphabet,int maxTagLength){
  this.alphabet=alphabet;
  map=new HashMap<String,String>();
}

Fixed version (ground truth):
public BrownClusterTagger(Alphabet<Label> alphabet,int maxTagLength){
  this.alphabet=alphabet;
  this.maxTagLength=maxTagLength;
  map=new HashMap<String,String>();
}
Program: 131604
Project: 131604
Buggy source:
/** 
 * Gets a new chart of the appropriate size for the sentence, specific to this grammar, and with cells of the specified type.
 */
private static ChartCell[][] getNewChart(Sentence sentence,CnfGrammar grammar,ChartCellType cellType,ParseType parseType){
  ChartCell[][] chart=new ChartCell[sentence.size()][sentence.size() + 1];
  for (int i=0; i < chart.length; i++) {
    for (int j=i + 1; j < chart[i].length; j++) {
      if (parseType == ParseType.INSIDE && cellType != ChartCellType.FULL) {
        throw new RuntimeException("String_Node_Str" + cellType);
      }
switch (cellType) {
case SINGLE_HASH:
        chart[i][j]=new SingleHashChartCell(grammar);
      break;
case DOUBLE_HASH:
    chart[i][j]=new DoubleHashChartCell(grammar);
  break;
case FULL:
chart[i][j]=new FullChartCell(grammar,parseType);
break;
case FULL_BREAK_TIES:
chart[i][j]=new FullTieBreakerChartCell(grammar,true);
break;
case CONSTRAINED_FULL:
if (!(sentence instanceof ValidParentsSentence)) {
throw new IllegalStateException("String_Node_Str");
}
ChartCell cell=new FullChartCell(grammar,parseType);
chart[i][j]=new ConstrainedChartCell(i,j,(ValidParentsSentence)sentence,cell);
break;
default :
throw new RuntimeException("String_Node_Str" + cellType);
}
}
}
return chart;
}

Fixed version (ground truth):
/** 
 * Gets a new chart of the appropriate size for the sentence, specific to this grammar, and with cells of the specified type.
 */
private static ChartCell[][] getNewChart(Sentence sentence,CnfGrammar grammar,ChartCellType cellType,ParseType parseType){
  ChartCell[][] chart=new ChartCell[sentence.size()][sentence.size() + 1];
  for (int i=0; i < chart.length; i++) {
    for (int j=i + 1; j < chart[i].length; j++) {
      if (parseType == ParseType.INSIDE && cellType != ChartCellType.FULL) {
        throw new RuntimeException("String_Node_Str" + cellType);
      }
switch (cellType) {
case SINGLE_HASH:
        chart[i][j]=new SingleHashChartCell(grammar);
      break;
case DOUBLE_HASH:
    chart[i][j]=new DoubleHashChartCell(grammar);
  break;
case FULL:
chart[i][j]=new FullChartCell(grammar,parseType);
break;
case FULL_BREAK_TIES:
chart[i][j]=new FullTieBreakerChartCell(grammar,true);
break;
case CONSTRAINED_FULL:
if (!(sentence instanceof ValidParentsSentence)) {
throw new IllegalStateException("String_Node_Str");
}
ChartCell cell=new FullTieBreakerChartCell(grammar,true);
chart[i][j]=new ConstrainedChartCell(i,j,(ValidParentsSentence)sentence,cell);
break;
default :
throw new RuntimeException("String_Node_Str" + cellType);
}
}
}
return chart;
}
Program: 131605
Project: 131605
Buggy source:
@Test public void testTieBreakingOnUniformModel(){
  Prng.seed(System.currentTimeMillis());
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvModelFactory modelFactory=new UniformDmvModelFactory();
  DmvModel model=modelFactory.getInstance(sentences.getLabelAlphabet());
  int n=sentences.get(0).size();
  int m=model.root.length;
  double expectedParseWeight=Utilities.log(Math.pow(0.5,n * 2 + n - 1) * Math.pow(1. / m,n));
  System.out.println("String_Node_Str" + expectedParseWeight);
  int numRestarts=1000;
  Map<ParentsArray,Integer> counter=new HashMap<ParentsArray,Integer>();
  for (int i=0; i < numRestarts; i++) {
    DepTreebank dpTrees=getDpParses(model,sentences,expectedParseWeight);
    ParentsArray pa=new ParentsArray(dpTrees.get(0).getParents());
    System.out.println(Arrays.toString(pa.parents));
    Utilities.increment(counter,pa,1);
  }
  for (  ParentsArray pa : counter.keySet()) {
    System.out.printf("String_Node_Str",counter.get(pa),pa);
  }
}

Fixed version (ground truth):
@Test public void testTieBreakingOnUniformModel(){
  Prng.seed(System.currentTimeMillis());
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvModelFactory modelFactory=new UniformDmvModelFactory();
  DmvModel model=modelFactory.getInstance(sentences.getLabelAlphabet());
  int n=sentences.get(0).size();
  int m=model.root.length;
  double expectedParseWeight=Utilities.log(Math.pow(0.5,n * 2 + n - 1) * Math.pow(1. / m,n));
  System.out.println("String_Node_Str" + expectedParseWeight);
  int numRestarts=5000;
  Map<ParentsArray,Integer> counter=new HashMap<ParentsArray,Integer>();
  for (int i=0; i < numRestarts; i++) {
    DepTreebank dpTrees=getDpParses(model,sentences,expectedParseWeight);
    ParentsArray pa=new ParentsArray(dpTrees.get(0).getParents());
    System.out.println(Arrays.toString(pa.parents));
    Utilities.increment(counter,pa,1);
  }
  for (  ParentsArray pa : counter.keySet()) {
    System.out.printf("String_Node_Str",counter.get(pa),pa);
  }
}
Program: 131606
Project: 131606
Buggy source:
private static DmvCkyParserPrm getDmvCkyParserPrm(boolean usePredArgSupervision){
  CkyPcfgParserPrm ckyPrm=new CkyPcfgParserPrm();
  ckyPrm.loopOrder=LoopOrder.LEFT_CHILD;
  ckyPrm.parseType=ParseType.VITERBI;
  ckyPrm.cacheChart=true;
  if (usePredArgSupervision) {
    ckyPrm.cellType=ChartCellType.CONSTRAINED_FULL;
  }
 else {
    ckyPrm.cellType=ChartCellType.FULL;
  }
  DmvCkyParserPrm prm=new DmvCkyParserPrm();
  prm.objPrm=getDmvObjectivePrm();
  prm.ckyPrm=ckyPrm;
  return prm;
}

Fixed version (ground truth):
private static DmvCkyParserPrm getDmvCkyParserPrm(boolean usePredArgSupervision){
  CkyPcfgParserPrm ckyPrm=new CkyPcfgParserPrm();
  ckyPrm.loopOrder=LoopOrder.LEFT_CHILD;
  ckyPrm.parseType=ParseType.VITERBI;
  ckyPrm.cacheChart=true;
  if (usePredArgSupervision) {
    ckyPrm.cellType=ChartCellType.CONSTRAINED_FULL;
  }
 else {
    ckyPrm.cellType=ChartCellType.FULL_BREAK_TIES;
  }
  DmvCkyParserPrm prm=new DmvCkyParserPrm();
  prm.objPrm=getDmvObjectivePrm();
  prm.ckyPrm=ckyPrm;
  return prm;
}
Program: 131607
Project: 131607
Buggy source:
@Override public Collection<UnorderedPair> getRltRowsForLeq(int startFac1,int endFac1,int startFac2,int endFac2,RowType type){
  FactorList leqFactors=rlt.getLeqFactors();
  IntObjectHashMap<IntArrayList> varConsMap=getVarConsMap(leqFactors);
  Set<UnorderedPair> rltRows=new HashSet<UnorderedPair>();
  for (  UnorderedPair varIdPair : varIdPairs) {
    for (    int i : Utilities.safeGetList(varConsMap,varIdPair.get1()).elements()) {
      for (      int j : Utilities.safeGetList(varConsMap,varIdPair.get2()).elements()) {
        if ((startFac1 <= i && i < endFac1 && startFac2 <= j && j < endFac2) || (startFac2 <= i && i < endFac2 && startFac1 <= j && j < endFac1)) {
          rltRows.add(new UnorderedPair(i,j));
        }
      }
    }
  }
  return rltRows;
}

Fixed version (ground truth):
@Override public Collection<UnorderedPair> getRltRowsForLeq(int startFac1,int endFac1,int startFac2,int endFac2,RowType type){
  FactorList leqFactors=rlt.getLeqFactors();
  IntObjectHashMap<IntArrayList> varConsMap=getVarConsMap(leqFactors);
  Set<UnorderedPair> rltRows=new HashSet<UnorderedPair>();
  for (  UnorderedPair varIdPair : varIdPairs) {
    IntArrayList list1=Utilities.safeGetList(varConsMap,varIdPair.get1());
    IntArrayList list2=Utilities.safeGetList(varConsMap,varIdPair.get2());
    for (int i=0; i < list1.size(); i++) {
      int consId1=list1.getQuick(i);
      for (int j=0; j < list2.size(); j++) {
        int consId2=list2.getQuick(j);
        if ((startFac1 <= consId1 && consId1 < endFac1 && startFac2 <= consId2 && consId2 < endFac2) || (startFac2 <= consId1 && consId1 < endFac2 && startFac1 <= consId2 && consId2 < endFac1)) {
          rltRows.add(new UnorderedPair(consId1,consId2));
        }
      }
    }
  }
  return rltRows;
}
Program: 131608
Project: 131608
Buggy source:
/** 
 * Construct a multi-map of variable ids to factor indices. For each factor i containing a non-zero coefficient for variable k, add an entry for (k --> i).
 */
private IntObjectHashMap<IntArrayList> getVarConsMap(FactorList factors){
  IntObjectHashMap<IntArrayList> varConsMap=new IntObjectHashMap<IntArrayList>();
  for (int i=0; i < factors.size(); i++) {
    Factor factor=factors.get(i);
    if (boundsOnly && !(factor instanceof BoundFactor)) {
      continue;
    }
    for (    long lveIdx : factor.G.getIndices()) {
      int veIdx=SafeCast.safeLongToInt(lveIdx);
      if (inputVarIds.contains(veIdx)) {
        Utilities.addToList(varConsMap,veIdx,i);
      }
    }
  }
  return varConsMap;
}

Fixed version (ground truth):
/** 
 * Construct a multi-map of variable ids to factor indices. For each factor i containing a non-zero coefficient for variable k, add an entry for (k --> i).
 */
private IntObjectHashMap<IntArrayList> getVarConsMap(FactorList factors){
  IntObjectHashMap<IntArrayList> varConsMap=new IntObjectHashMap<IntArrayList>();
  for (int i=0; i < factors.size(); i++) {
    Factor factor=factors.get(i);
    if (boundsOnly && !(factor instanceof BoundFactor)) {
      continue;
    }
    for (    LongDoubleEntry ve : factor.G) {
      if (ve.get() != 0.0) {
        int veIdx=SafeCast.safeLongToInt(ve.index());
        if (inputVarIds.contains(veIdx)) {
          Utilities.addToList(varConsMap,veIdx,i);
        }
      }
    }
  }
  return varConsMap;
}
Program: 131609
Project: 131609
Buggy source:
/** 
 * Returns true if the input vector is equal to this one.
 */
public boolean equals(SortedIntDoubleVector other,double delta){
  if (other.size() != this.size()) {
    return false;
  }
  for (  IntDoubleEntry ve : this) {
    if (!Utilities.equals(ve.get(),other.get(ve.index()),delta)) {
      return false;
    }
  }
  for (  IntDoubleEntry ve : other) {
    if (!Utilities.equals(ve.get(),this.get(ve.index()),delta)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if the input vector is equal to this one.
 */
public boolean equals(SortedIntDoubleVector other,double delta){
  SortedIntDoubleVector v1=SortedIntDoubleVector.getWithNoZeroValues(this,delta);
  SortedIntDoubleVector v2=SortedIntDoubleVector.getWithNoZeroValues(other,delta);
  if (v2.size() != v1.size()) {
    return false;
  }
  for (  IntDoubleEntry ve : v1) {
    if (!Utilities.equals(ve.get(),v2.get(ve.index()),delta)) {
      return false;
    }
  }
  for (  IntDoubleEntry ve : v2) {
    if (!Utilities.equals(ve.get(),v1.get(ve.index()),delta)) {
      return false;
    }
  }
  return true;
}
Program: 131610
Project: 131610
Buggy source:
/** 
 * Returns true if the input vector is equal to this one.
 */
@Override public boolean equals(Object obj){
  if (obj instanceof SortedIntIntVector) {
    SortedIntIntVector other=(SortedIntIntVector)obj;
    if (other.size() != this.size()) {
      return false;
    }
    for (    IntIntEntry ve : this) {
      if (ve.get() != other.get(ve.index())) {
        return false;
      }
    }
    for (    IntIntEntry ve : other) {
      if (ve.get() != this.get(ve.index())) {
        return false;
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns true if the input vector is equal to this one.
 */
@Override public boolean equals(Object obj){
  if (obj instanceof SortedIntIntVector) {
    SortedIntIntVector other=(SortedIntIntVector)obj;
    SortedIntIntVector v1=SortedIntIntVector.getWithNoZeroValues(this);
    SortedIntIntVector v2=SortedIntIntVector.getWithNoZeroValues(other);
    if (v2.size() != v1.size()) {
      return false;
    }
    for (    IntIntEntry ve : v1) {
      if (ve.get() != v2.get(ve.index())) {
        return false;
      }
    }
    for (    IntIntEntry ve : v2) {
      if (ve.get() != v1.get(ve.index())) {
        return false;
      }
    }
    return true;
  }
  return false;
}
Program: 131611
Project: 131611
Buggy source:
/** 
 * Returns true if the input vector is equal to this one.
 */
@Override public boolean equals(Object obj){
  if (obj instanceof SortedIntLongVector) {
    SortedIntLongVector other=(SortedIntLongVector)obj;
    if (other.size() != this.size()) {
      return false;
    }
    for (    IntLongEntry ve : this) {
      if (ve.get() != other.get(ve.index())) {
        return false;
      }
    }
    for (    IntLongEntry ve : other) {
      if (ve.get() != this.get(ve.index())) {
        return false;
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns true if the input vector is equal to this one.
 */
@Override public boolean equals(Object obj){
  if (obj instanceof SortedIntLongVector) {
    SortedIntLongVector other=(SortedIntLongVector)obj;
    SortedIntLongVector v1=SortedIntLongVector.getWithNoZeroValues(this);
    SortedIntLongVector v2=SortedIntLongVector.getWithNoZeroValues(other);
    if (v2.size() != v1.size()) {
      return false;
    }
    for (    IntLongEntry ve : v1) {
      if (ve.get() != v2.get(ve.index())) {
        return false;
      }
    }
    for (    IntLongEntry ve : v2) {
      if (ve.get() != v1.get(ve.index())) {
        return false;
      }
    }
    return true;
  }
  return false;
}
Program: 131612
Project: 131612
Buggy source:
/** 
 * Returns true if the input vector is equal to this one.
 */
public boolean equals(SortedLongDoubleVector other,double delta){
  if (other.size() != this.size()) {
    return false;
  }
  for (  LongDoubleEntry ve : this) {
    if (!Utilities.equals(ve.get(),other.get(ve.index()),delta)) {
      return false;
    }
  }
  for (  LongDoubleEntry ve : other) {
    if (!Utilities.equals(ve.get(),this.get(ve.index()),delta)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if the input vector is equal to this one.
 */
public boolean equals(SortedLongDoubleVector other,double delta){
  SortedLongDoubleVector v1=SortedLongDoubleVector.getWithNoZeroValues(this,delta);
  SortedLongDoubleVector v2=SortedLongDoubleVector.getWithNoZeroValues(other,delta);
  if (v2.size() != v1.size()) {
    return false;
  }
  for (  LongDoubleEntry ve : v1) {
    if (!Utilities.equals(ve.get(),v2.get(ve.index()),delta)) {
      return false;
    }
  }
  for (  LongDoubleEntry ve : v2) {
    if (!Utilities.equals(ve.get(),v1.get(ve.index()),delta)) {
      return false;
    }
  }
  return true;
}
Program: 131613
Project: 131613
Buggy source:
public static void assertContainsRow(IloLPMatrix rltMat,double[] denseRow,double lb,double ub,double delta) throws IloException {
  int nCols=rltMat.getNcols();
  assertTrue(nCols == denseRow.length);
  int nRows=rltMat.getNrows();
  double[] lbs=new double[nRows];
  double[] ubs=new double[nRows];
  int[][] ind=new int[nRows][];
  double[][] val=new double[nRows][];
  rltMat.getRows(0,nRows,lbs,ubs,ind,val);
  SortedIntDoubleVector expectedRow=new SortedIntDoubleVector(denseRow);
  for (int m=0; m < nRows; m++) {
    SortedIntDoubleVector row=new SortedIntDoubleVector(ind[m],val[m]);
    if (row.equals(expectedRow,delta) && Utilities.equals(lb,lbs[m],delta) && Utilities.equals(ub,ubs[m],delta)) {
      return;
    }
  }
  Assert.fail("String_Node_Str" + Arrays.toString(denseRow));
}

Fixed version (ground truth):
public static void assertContainsRow(IloLPMatrix rltMat,double[] denseRow,double lb,double ub,double delta) throws IloException {
  int nCols=rltMat.getNcols();
  assertTrue(nCols == denseRow.length);
  int nRows=rltMat.getNrows();
  double[] lbs=new double[nRows];
  double[] ubs=new double[nRows];
  int[][] ind=new int[nRows][];
  double[][] val=new double[nRows][];
  rltMat.getRows(0,nRows,lbs,ubs,ind,val);
  SortedIntDoubleVector expectedRow=new SortedIntDoubleVector(denseRow);
  for (int m=0; m < nRows; m++) {
    Sort.sortIndexAsc(ind[m],val[m]);
    SortedIntDoubleVector row=new SortedIntDoubleVector(ind[m],val[m]);
    if (row.equals(expectedRow,delta) && Utilities.equals(lb,lbs[m],delta) && Utilities.equals(ub,ubs[m],delta)) {
      return;
    }
  }
  Assert.fail("String_Node_Str" + Arrays.toString(denseRow));
}
Program: 131614
Project: 131614
Buggy source:
public static void normalizeLogProps(double[] logProps){
  double logPropSum=Double.NEGATIVE_INFINITY;
  for (int d=0; d < logProps.length; d++) {
    logPropSum=Utilities.logAdd(logPropSum,logProps[d]);
  }
  for (int d=0; d < logProps.length; d++) {
    logProps[d]-=logPropSum;
    assert(!Double.isNaN(logProps[d]));
  }
}

Fixed version (ground truth):
public static void normalizeLogProps(double[] logProps){
  double logPropSum=Double.NEGATIVE_INFINITY;
  for (int d=0; d < logProps.length; d++) {
    logPropSum=Utilities.logAdd(logPropSum,logProps[d]);
  }
  if (logPropSum != Double.NEGATIVE_INFINITY) {
    for (int d=0; d < logProps.length; d++) {
      logProps[d]-=logPropSum;
      assert(!Double.isNaN(logProps[d]));
    }
  }
 else {
    double uniform=Utilities.log(1.0 / (double)logProps.length);
    for (int d=0; d < logProps.length; d++) {
      logProps[d]=uniform;
    }
  }
}
Program: 131615
Project: 131615
Buggy source:
private void getAsPennTreebankString(int indent,int numOnLine,StringBuilder sb){
  int numSpaces=indent - numOnLine;
  if (numSpaces <= 0 && indent != 0) {
  }
  for (int i=0; i < numSpaces; i++) {
    sb.append("String_Node_Str");
  }
  if (isLexical) {
    sb.append(getSymbolStr());
  }
 else {
    sb.append("String_Node_Str");
    sb.append(getSymbolStr());
    int numNewChars=1 + getSymbolStr().length();
    if (leftChild != null) {
      leftChild.getAsPennTreebankString(indent + numNewChars + 1,indent + numNewChars,sb);
    }
    if (rightChild != null) {
      sb.append("String_Node_Str");
      rightChild.getAsPennTreebankString(indent + numNewChars + 1,0,sb);
    }
    sb.append("String_Node_Str");
  }
}

Fixed version (ground truth):
private void getAsPennTreebankString(int indent,int numOnLine,StringBuilder sb){
  int numSpaces=indent - numOnLine;
  for (int i=0; i < numSpaces; i++) {
    sb.append("String_Node_Str");
  }
  if (isLexical) {
    sb.append(getSymbolStr());
  }
 else {
    sb.append("String_Node_Str");
    sb.append(getSymbolStr());
    int numNewChars=1 + getSymbolStr().length();
    if (leftChild != null) {
      leftChild.getAsPennTreebankString(indent + numNewChars + 1,indent + numNewChars,sb);
    }
    if (rightChild != null) {
      sb.append("String_Node_Str");
      rightChild.getAsPennTreebankString(indent + numNewChars + 1,0,sb);
    }
    sb.append("String_Node_Str");
  }
}
Program: 131616
Project: 131616
Buggy source:
public void runEvalb(File goldTrees,File testTrees,File logFile){
  String[] cmd=new String[]{evalbFile.getAbsolutePath(),"String_Node_Str",prmFile.getAbsolutePath(),goldTrees.getAbsolutePath(),testTrees.getAbsolutePath()};
  Command.runCommand(cmd,logFile,new File("String_Node_Str"));
}

Fixed version (ground truth):
public void runEvalb(File goldTrees,File testTrees,File logFile){
  String[] cmd=new String[]{evalbFile.getAbsolutePath(),"String_Node_Str",prmFile.getAbsolutePath(),goldTrees.getAbsolutePath(),testTrees.getAbsolutePath()};
  Command.runCommand(cmd,logFile,new File("String_Node_Str"));
  Files.cat(logFile);
}
Program: 131617
Project: 131617
Buggy source:
private void getAsPennTreebankString(int indent,int numOnLine,StringBuilder sb){
  int numSpaces=indent - numOnLine;
  if (numSpaces <= 0 && indent != 0) {
  }
  for (int i=0; i < numSpaces; i++) {
    sb.append("String_Node_Str");
  }
  if (isLexical) {
    sb.append(getSymbolStr());
  }
 else {
    sb.append("String_Node_Str");
    sb.append(getSymbolStr());
    int numNewChars=1 + getSymbolStr().length();
    for (int i=0; i < children.size(); i++) {
      NaryTree child=children.get(i);
      if (i == 0) {
        child.getAsPennTreebankString(indent + numNewChars + 1,indent + numNewChars,sb);
      }
 else {
        sb.append("String_Node_Str");
        child.getAsPennTreebankString(indent + numNewChars + 1,0,sb);
      }
    }
    sb.append("String_Node_Str");
  }
}

Fixed version (ground truth):
private void getAsPennTreebankString(int indent,int numOnLine,StringBuilder sb){
  int numSpaces=indent - numOnLine;
  for (int i=0; i < numSpaces; i++) {
    sb.append("String_Node_Str");
  }
  if (isLexical) {
    sb.append(getSymbolStr());
  }
 else {
    sb.append("String_Node_Str");
    sb.append(getSymbolStr());
    int numNewChars=1 + getSymbolStr().length();
    for (int i=0; i < children.size(); i++) {
      NaryTree child=children.get(i);
      if (i == 0) {
        child.getAsPennTreebankString(indent + numNewChars + 1,indent + numNewChars,sb);
      }
 else {
        sb.append("String_Node_Str");
        child.getAsPennTreebankString(indent + numNewChars + 1,0,sb);
      }
    }
    sb.append("String_Node_Str");
  }
}
Program: 131619
Project: 131619
Buggy source:
public void setRandom(){
  LambdaOneToOne<Double,Double> lambda=new LambdaOneToOne<Double,Double>(){
    @Override public Double call(    Double obj){
      return Prng.nextDouble();
    }
  }
;
  applyRoot(lambda);
  applyChild(lambda);
  applyStop(lambda);
}

Fixed version (ground truth):
public void setRandom(){
  LambdaOneToOne<Double,Double> lambda=new LambdaOneToOne<Double,Double>(){
    @Override public Double call(    Double obj){
      return Prng.nextDouble();
    }
  }
;
  applyOldOrder(lambda);
}
Program: 131620
Project: 131620
Buggy source:
public void logNormalize(){
  Multinomials.normalizeLogProps(root);
  for (int c=0; c < numTags; c++) {
    for (int dir=0; dir < 2; dir++) {
      for (int val=0; val < 2; val++) {
        for (int sc=0; sc < 2; sc++) {
          Multinomials.normalizeLogProps(decision[c][dir][val]);
        }
      }
    }
  }
  double[][] logSums=new double[numTags][2];
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        logSums[p][dir]=Utilities.logAdd(logSums[p][dir],child[c][p][dir]);
      }
    }
  }
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        child[c][p][dir]-=logSums[p][dir];
        assert(!Double.isNaN(child[c][p][dir]));
      }
    }
  }
}

Fixed version (ground truth):
public void logNormalize(){
  Multinomials.normalizeLogProps(root);
  for (int c=0; c < numTags; c++) {
    for (int dir=0; dir < 2; dir++) {
      for (int val=0; val < 2; val++) {
        for (int sc=0; sc < 2; sc++) {
          Multinomials.normalizeLogProps(decision[c][dir][val]);
        }
      }
    }
  }
  double[][] logSums=new double[numTags][2];
  for (int p=0; p < numTags; p++) {
    Arrays.fill(logSums[p],Double.NEGATIVE_INFINITY);
  }
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        logSums[p][dir]=Utilities.logAdd(logSums[p][dir],child[c][p][dir]);
      }
    }
  }
  double uniform=Utilities.log(1.0 / numTags);
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        if (logSums[p][dir] != Double.NEGATIVE_INFINITY) {
          child[c][p][dir]-=logSums[p][dir];
        }
 else {
          child[c][p][dir]=uniform;
        }
        assert(!Double.isNaN(child[c][p][dir]));
      }
    }
  }
}
Program: 131621
Project: 131621
Buggy source:
public void assertLogNormalized(double delta){
  Multinomials.assertLogNormalized(root,delta);
  for (int c=0; c < numTags; c++) {
    for (int dir=0; dir < 2; dir++) {
      for (int val=0; val < 2; val++) {
        for (int sc=0; sc < 2; sc++) {
          Multinomials.assertLogNormalized(decision[c][dir][val],delta);
        }
      }
    }
  }
  double[][] logSums=new double[numTags][2];
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        logSums[p][dir]=Utilities.logAdd(logSums[p][dir],child[c][p][dir]);
      }
    }
  }
  for (int p=0; p < numTags; p++) {
    for (int dir=0; dir < 2; dir++) {
      assert(Utilities.equals(0.0,logSums[p][dir],delta));
    }
  }
}

Fixed version (ground truth):
public void assertLogNormalized(double delta){
  Multinomials.assertLogNormalized(root,delta);
  for (int c=0; c < numTags; c++) {
    for (int dir=0; dir < 2; dir++) {
      for (int val=0; val < 2; val++) {
        for (int sc=0; sc < 2; sc++) {
          Multinomials.assertLogNormalized(decision[c][dir][val],delta);
        }
      }
    }
  }
  double[][] logSums=new double[numTags][2];
  for (int p=0; p < numTags; p++) {
    Arrays.fill(logSums[p],Double.NEGATIVE_INFINITY);
  }
  for (int c=0; c < numTags; c++) {
    for (int p=0; p < numTags; p++) {
      for (int dir=0; dir < 2; dir++) {
        logSums[p][dir]=Utilities.logAdd(logSums[p][dir],child[c][p][dir]);
      }
    }
  }
  for (int p=0; p < numTags; p++) {
    for (int dir=0; dir < 2; dir++) {
      assert(Utilities.equals(0.0,logSums[p][dir],delta));
    }
  }
}
Program: 131622
Project: 131622
Buggy source:
private void addToQueue(LinkedList<NaryTree> queue,BinaryTree child,Alphabet<String> ntAlphabet){
  if (child == null) {
    return;
  }
  String parentStr=alphabet.lookupObject(child.getParent());
  if (GrammarConstants.isBinarized(parentStr)) {
    addToQueue(queue,child.leftChild,ntAlphabet);
    addToQueue(queue,child.rightChild,ntAlphabet);
  }
 else {
    queue.add(child.collapseToNary(ntAlphabet));
  }
}

Fixed version (ground truth):
private static void addToQueue(LinkedList<NaryTree> queue,BinaryTree child,Alphabet<String> ntAlphabet){
  if (child == null) {
    return;
  }
  String parentStr=child.alphabet.lookupObject(child.getParent());
  if (GrammarConstants.isBinarized(parentStr)) {
    addToQueue(queue,child.leftChild,ntAlphabet);
    addToQueue(queue,child.rightChild,ntAlphabet);
  }
 else {
    queue.add(child.collapseToNary(ntAlphabet));
  }
}
Program: 131623
Project: 131623
Buggy source:
@Override public DepTreebank getViterbiParse(SentenceCollection sentences,Model genericModel){
  DmvModel model=(DmvModel)genericModel;
  DepTreebank treebank=new DepTreebank(model.getTagAlphabet());
  parseWeight=0.0;
  for (  Sentence sentence : sentences) {
    Pair<DepTree,Double> pair=parse(sentence,model);
    DepTree tree=pair.get1();
    parseWeight+=pair.get2();
    treebank.add(tree);
  }
  return treebank;
}

Fixed version (ground truth):
@Override public DepTreebank getViterbiParse(SentenceCollection sentences,Model genericModel){
  DmvTrainCorpus corpus=new DmvTrainCorpus(sentences);
  return getViterbiParse(corpus,genericModel);
}
Program: 131624
Project: 131624
Buggy source:
public Pair<DepTree,Double> parse(Sentence sentence,DepSentenceDist sd){
  int numWords=sd.depInst.postags.length;
  int[] parents=new int[numWords];
  double parseWeight=CKYParser.parseSentence(sd,parents);
  for (int i=0; i < parents.length; i++) {
    parents[i]--;
  }
  DepTree tree=new DepTree(sentence,parents,true);
  return new Pair<DepTree,Double>(tree,parseWeight);
}

Fixed version (ground truth):
private Pair<DepTree,Double> parse(Sentence sentence,DepSentenceDist sd){
  int numWords=sd.depInst.postags.length;
  int[] parents=new int[numWords];
  double parseWeight=CKYParser.parseSentence(sd,parents);
  for (int i=0; i < parents.length; i++) {
    parents[i]--;
  }
  DepTree tree=new DepTree(sentence,parents,true);
  return new Pair<DepTree,Double>(tree,parseWeight);
}
Program: 131625
Project: 131625
Buggy source:
@Override public IntDoubleEntry next(){
  return new IntDoubleEntryImpl(i);
}

Fixed version (ground truth):
@Override public IntDoubleEntry next(){
  entry.i++;
  return entry;
}
Program: 131626
Project: 131626
Buggy source:
@Override public boolean hasNext(){
  return i < used;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return entry.i + 1 < used;
}
Program: 131627
Project: 131627
Buggy source:
public void add(int idx,double val){
  double curVal=getWithDefault(idx,0.0);
  put(idx,curVal + val);
}

Fixed version (ground truth):
public void add(SortedIntDoubleVector other){
  for (  IntDoubleEntry ve : other) {
    add(ve.index(),ve.get());
  }
}
Program: 131628
Project: 131628
Buggy source:
@Override public IntIntEntry next(){
  return new IntIntEntryImpl(i);
}

Fixed version (ground truth):
@Override public IntIntEntry next(){
  entry.i++;
  return entry;
}
Program: 131629
Project: 131629
Buggy source:
@Override public boolean hasNext(){
  return i < used;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return entry.i + 1 < used;
}
Program: 131630
Project: 131630
Buggy source:
public void add(int idx,int val){
  int curVal=getWithDefault(idx,0);
  put(idx,curVal + val);
}

Fixed version (ground truth):
public void add(SortedIntIntVector other){
  for (  IntIntEntry ve : other) {
    add(ve.index(),ve.get());
  }
}
Program: 131631
Project: 131631
Buggy source:
@Override public IntLongEntry next(){
  return new IntLongEntryImpl(i);
}

Fixed version (ground truth):
@Override public IntLongEntry next(){
  entry.i++;
  return entry;
}
Program: 131632
Project: 131632
Buggy source:
@Override public boolean hasNext(){
  return i < used;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return entry.i + 1 < used;
}
Program: 131633
Project: 131633
Buggy source:
private void evalAndWrite(DmvModel model,DepTreebank trainTreebank,String datasetName) throws IOException {
  ViterbiParser parser=TrainerFactory.getEvalParser();
  log.info("String_Node_Str" + datasetName);
  Evaluator trainEval=new DependencyParserEvaluator(parser,trainTreebank,datasetName);
  trainEval.evaluate(model);
  trainEval.print();
  if (trainOut != null) {
    DepTreebank trainParses=trainEval.getParses();
    if (trainType == DatasetType.CONLL_X) {
      CoNLLXWriter cw=new CoNLLXWriter(trainOut);
      for (int i=0; i < trainParses.size(); i++) {
        DepTree parse=trainParses.get(i);
        DepTree goldTree=trainTreebank.get(i);
        CoNLLXSentence sent=((CoNLLXDepTree)goldTree).getCoNLLXSentence();
        sent=new CoNLLXSentence(sent);
        sent.setHeadsFromParents(parse.getParents());
        cw.write(sent);
      }
      cw.close();
    }
 else     if (trainType == DatasetType.CONLL_2009) {
      CoNLL09Writer cw=new CoNLL09Writer(trainOut);
      for (int i=0; i < trainParses.size(); i++) {
        DepTree parse=trainParses.get(i);
        DepTree goldTree=trainTreebank.get(i);
        CoNLL09Sentence sent=((CoNLL09DepTree)goldTree).getCoNLL09Sentence();
        sent=new CoNLL09Sentence(sent);
        sent.setPheadsFromParents(parse.getParents());
        cw.write(sent);
      }
      cw.close();
    }
 else {
      throw new RuntimeException("String_Node_Str" + trainType);
    }
  }
}

Fixed version (ground truth):
private void evalAndWrite(DmvModel model,DepTreebank trainTreebank,String datasetName,File trainOut,DatasetType trainType) throws IOException {
  ViterbiParser parser=TrainerFactory.getEvalParser();
  log.info("String_Node_Str" + datasetName);
  Evaluator trainEval=new DependencyParserEvaluator(parser,trainTreebank,datasetName);
  trainEval.evaluate(model);
  trainEval.print();
  if (trainOut != null) {
    DepTreebank trainParses=trainEval.getParses();
    if (trainType == DatasetType.CONLL_X) {
      CoNLLXWriter cw=new CoNLLXWriter(trainOut);
      for (int i=0; i < trainParses.size(); i++) {
        DepTree parse=trainParses.get(i);
        DepTree goldTree=trainTreebank.get(i);
        CoNLLXSentence sent=((CoNLLXDepTree)goldTree).getCoNLLXSentence();
        sent=new CoNLLXSentence(sent);
        sent.setHeadsFromParents(parse.getParents());
        cw.write(sent);
      }
      cw.close();
    }
 else     if (trainType == DatasetType.CONLL_2009) {
      CoNLL09Writer cw=new CoNLL09Writer(trainOut);
      for (int i=0; i < trainParses.size(); i++) {
        DepTree parse=trainParses.get(i);
        DepTree goldTree=trainTreebank.get(i);
        CoNLL09Sentence sent=((CoNLL09DepTree)goldTree).getCoNLL09Sentence();
        sent=new CoNLL09Sentence(sent);
        sent.setPheadsFromParents(parse.getParents());
        cw.write(sent);
      }
      cw.close();
    }
 else {
      throw new RuntimeException("String_Node_Str" + trainType);
    }
  }
}
Program: 131635
Project: 131635
Buggy source:
public static Chart parseSentence(int[] sent,CnfGrammar grammar){
  Chart chart=new Chart(sent,grammar);
  for (int i=0; i <= sent.length - 1; i++) {
    for (    Rule r : grammar.getLexicalRulesWithChild(sent[i])) {
      double score=r.getScore();
      chart.updateCell(i,i + 1,r,score);
    }
  }
  for (int width=1; width <= sent.length; width++) {
    for (int start=0; start <= sent.length - width; start++) {
      int end=start + width;
      for (int mid=start + 1; mid <= end - 1; mid++) {
        for (        final int leftChildNt : chart.getNonTerminals(start,mid)) {
          for (          final int rightChildNt : chart.getNonTerminals(mid,end)) {
            for (            final Rule r : grammar.getBinaryRulesWithChildren(leftChildNt,rightChildNt)) {
              double score=r.getScore() + chart.getMaxScore(start,mid,r.getLeftChild()) + chart.getMaxScore(mid,end,r.getRightChild());
              chart.updateCell(start,mid,end,r,score);
            }
          }
        }
      }
      for (      final int parentNt : chart.getNonTerminals(start,end)) {
        for (        Rule r : grammar.getUnaryRulesWithChild(parentNt)) {
          double score=r.getScore();
          chart.updateCell(start,end,r,score);
        }
      }
    }
  }
  return chart;
}

Fixed version (ground truth):
public static Chart parseSentence(int[] sent,CnfGrammar grammar){
  Chart chart=new Chart(sent,grammar);
  for (int i=0; i <= sent.length - 1; i++) {
    for (    Rule r : grammar.getLexicalRulesWithChild(sent[i])) {
      double score=r.getScore();
      chart.updateCell(i,i + 1,r,score);
    }
  }
  for (int width=1; width <= sent.length; width++) {
    for (int start=0; start <= sent.length - width; start++) {
      int end=start + width;
      for (int mid=start + 1; mid <= end - 1; mid++) {
        for (        final int leftChildNt : chart.getNonTerminals(start,mid)) {
          for (          final int rightChildNt : chart.getNonTerminals(mid,end)) {
            for (            final Rule r : grammar.getBinaryRulesWithChildren(leftChildNt,rightChildNt)) {
              double score=r.getScore() + chart.getMaxScore(start,mid,r.getLeftChild()) + chart.getMaxScore(mid,end,r.getRightChild());
              chart.updateCell(start,mid,end,r,score);
            }
          }
        }
      }
      for (      final int parentNt : chart.getNonTerminals(start,end)) {
        for (        Rule r : grammar.getUnaryRulesWithChild(parentNt)) {
          double score=r.getScore() + chart.getMaxScore(start,end,r.getLeftChild());
          chart.updateCell(start,end,r,score);
        }
      }
    }
  }
  return chart;
}
Program: 131636
Project: 131636
Buggy source:
@Test public void testSimpleSentence2(){
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(CnfGrammarBuilderTest.timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  Pair<CfgTree,Double> pair=parseSentence("String_Node_Str",grammar);
  CfgTree tree=pair.get1();
  double logProb=pair.get2();
  System.out.println(logProb);
  System.out.println(tree);
  System.out.println(tree.getAsPennTreebankString());
  String treeStr=tree.getAsPennTreebankString().replaceAll("String_Node_Str","String_Node_Str");
  String goldTree="String_Node_Str";
  Assert.assertEquals(goldTree,treeStr);
  Assert.assertEquals(-11.0,logProb,1e-13);
}

Fixed version (ground truth):
@Test public void testSimpleSentence2() throws IOException {
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(CnfGrammarBuilderTest.timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  Pair<CfgTree,Double> pair=parseSentence("String_Node_Str",grammar);
  CfgTree tree=pair.get1();
  double logProb=pair.get2();
  System.out.println(logProb);
  System.out.println(tree);
  System.out.println(tree.getAsPennTreebankString());
  String treeStr=tree.getAsPennTreebankString().replaceAll("String_Node_Str","String_Node_Str");
  System.out.println(treeStr);
  String goldTree="String_Node_Str";
  Assert.assertEquals(goldTree,treeStr);
  Assert.assertEquals(-11.0,logProb,1e-13);
}
Program: 131637
Project: 131637
Buggy source:
@Test public void testSimpleSentence1(){
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(CnfGrammarBuilderTest.timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  Pair<CfgTree,Double> pair=parseSentence("String_Node_Str",grammar);
  CfgTree tree=pair.get1();
  double logProb=pair.get2();
  System.out.println(logProb);
  System.out.println(tree);
  System.out.println(tree.getAsPennTreebankString());
  String goldTree="String_Node_Str";
  String treeStr=tree.getAsPennTreebankString().replaceAll("String_Node_Str","String_Node_Str");
  Assert.assertEquals(goldTree,treeStr);
  Assert.assertEquals(-11.0,logProb,1e-13);
}

Fixed version (ground truth):
@Test public void testSimpleSentence1() throws IOException {
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(CnfGrammarBuilderTest.timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  Pair<CfgTree,Double> pair=parseSentence("String_Node_Str",grammar);
  CfgTree tree=pair.get1();
  double logProb=pair.get2();
  System.out.println(logProb);
  System.out.println(tree);
  System.out.println(tree.getAsPennTreebankString());
  String goldTree="String_Node_Str";
  String treeStr=tree.getAsPennTreebankString().replaceAll("String_Node_Str","String_Node_Str");
  Assert.assertEquals(goldTree,treeStr);
  Assert.assertEquals(-11.0,logProb,1e-13);
}
Program: 131639
Project: 131639
Buggy source:
public void loadFromResource(String resourceName){
  InputStream inputStream=this.getClass().getResourceAsStream(resourceName);
  if (inputStream == null) {
    throw new RuntimeException("String_Node_Str" + resourceName);
  }
  try {
    loadFromInputStream(inputStream);
    inputStream.close();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void loadFromResource(String resourceName) throws IOException {
  InputStream inputStream=this.getClass().getResourceAsStream(resourceName);
  if (inputStream == null) {
    throw new RuntimeException("String_Node_Str" + resourceName);
  }
  loadFromInputStream(inputStream);
  inputStream.close();
}
Program: 131640
Project: 131640
Buggy source:
@Test public void testLoadGrammarFromFile(){
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  System.out.println(grammar);
  assertEquals(5,grammar.getNumLexicalTypes());
  assertEquals(8,grammar.getNumNonTerminals());
  assertEquals(1,grammar.getBinaryRulesWithChildren(grammar.getNtAlphabet().lookupIndex("String_Node_Str"),grammar.getNtAlphabet().lookupIndex("String_Node_Str")).size());
}

Fixed version (ground truth):
@Test public void testLoadGrammarFromFile() throws IOException {
  CnfGrammarBuilder builder=new CnfGrammarBuilder();
  builder.loadFromResource(timeFliesGrammarResource);
  CnfGrammar grammar=builder.getGrammar();
  System.out.println(grammar);
  assertEquals(5,grammar.getNumLexicalTypes());
  assertEquals(8,grammar.getNumNonTerminals());
  assertEquals(1,grammar.getBinaryRulesWithChildren(grammar.getNtAlphabet().lookupIndex("String_Node_Str"),grammar.getNtAlphabet().lookupIndex("String_Node_Str")).size());
}
Program: 131641
Project: 131641
Buggy source:
@Override public WarmStart getWarmStart(){
  DmvProblemNode cur=this;
  while (cur != null) {
    if (cur.warmStart != null) {
      WarmStart ws=warmStart.get();
      if (ws != null) {
        return ws;
      }
    }
    cur=cur.parent;
  }
  return null;
}

Fixed version (ground truth):
private static WarmStart getWarmStart(DmvProblemNode cur){
  while (cur != null) {
    if (cur.warmStart != null) {
      WarmStart ws=cur.warmStart.get();
      if (ws != null) {
        return ws;
      }
    }
    cur=cur.parent;
  }
  return null;
}
Program: 131642
Project: 131642
Buggy source:
public void addConsToMatrix(DmvTreeProgram pp,IloLPMatrix mat) throws IloException {
  mat.addRows(pp.oneArcPerWall);
  CplexUtils.addRows(mat,pp.oneParent);
  CplexUtils.addRows(mat,pp.oneArcPerPair);
  mat.addRows(pp.rootFlowIsSentLength);
  CplexUtils.addRows(mat,pp.flowDiff);
  CplexUtils.addRows(mat,pp.flowBoundRoot);
  CplexUtils.addRows(mat,pp.flowBoundChild);
  CplexUtils.addRows(mat,pp.arcFlowBoundRoot);
  CplexUtils.addRows(mat,pp.arcFlowBoundChild);
  if (pp.projectiveRoot != null && pp.projectiveChild != null) {
    CplexUtils.addRows(mat,pp.projectiveRoot);
    CplexUtils.addRows(mat,pp.projectiveChild);
  }
  CplexUtils.addRows(mat,pp.numToSideCons);
  CplexUtils.addRows(mat,pp.genAdjCons);
  CplexUtils.addRows(mat,pp.numNonAdjCons);
  CplexUtils.addRows(mat,pp.stopAdjCons);
  if (pp.featCountCons != null) {
    CplexUtils.addRows(mat,pp.featCountCons);
  }
  if (pp.universalPostCons != null) {
    mat.addRow(pp.universalPostCons);
  }
}

Fixed version (ground truth):
public void addConsToMatrix(DmvTreeProgram pp,IloLPMatrix mat) throws IloException {
  CplexUtils.addRows(mat,pp.oneArcPerWall);
  CplexUtils.addRows(mat,pp.oneParent);
  CplexUtils.addRows(mat,pp.oneArcPerPair);
  CplexUtils.addRows(mat,pp.rootFlowIsSentLength);
  CplexUtils.addRows(mat,pp.flowDiff);
  CplexUtils.addRows(mat,pp.flowBoundRoot);
  CplexUtils.addRows(mat,pp.flowBoundChild);
  CplexUtils.addRows(mat,pp.arcFlowBoundRoot);
  CplexUtils.addRows(mat,pp.arcFlowBoundChild);
  if (pp.projectiveRoot != null && pp.projectiveChild != null) {
    CplexUtils.addRows(mat,pp.projectiveRoot);
    CplexUtils.addRows(mat,pp.projectiveChild);
  }
  CplexUtils.addRows(mat,pp.numToSideCons);
  CplexUtils.addRows(mat,pp.genAdjCons);
  CplexUtils.addRows(mat,pp.numNonAdjCons);
  CplexUtils.addRows(mat,pp.stopAdjCons);
  if (pp.featCountCons != null) {
    CplexUtils.addRows(mat,pp.featCountCons);
  }
  if (pp.universalPostCons != null) {
    CplexUtils.addRow(mat,pp.universalPostCons);
  }
}