nus-yam/ex-repair huggingface dataset:
Program: 131473
Project: 131473
Buggy source:
public SentFeatureExtractor(SentFeatureExtractorPrm prm,SimpleAnnoSentence sent,CorpusStatistics cs){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.sig=cs.sig;
  if (!prm.biasOnly) {
    this.parents=getParents(sent);
    if (prm.useZhaoFeats || prm.useDepPathFeats || prm.useBjorkelundFeats) {
      this.featuredSentence=createZhaoSentence();
      this.featuredHeadDefault=new FeatureObject(-1,parents,sent);
      this.featuredTailDefault=new FeatureObject(sent.size(),parents,sent);
    }
    if (prm.useAllTemplates) {
      this.prm.useTemplates=true;
      this.prm.formFeats=true;
      this.prm.lemmaFeats=true;
      this.prm.tagFeats=true;
      this.prm.morphFeats=true;
      this.prm.deprelFeats=true;
      this.prm.childrenFeats=true;
      this.prm.pathFeats=true;
      this.prm.syntacticConnectionFeats=true;
    }
  }
 else {
    this.parents=null;
  }
}

Fixed version (ground truth):
public SentFeatureExtractor(SentFeatureExtractorPrm prm,SimpleAnnoSentence sent,CorpusStatistics cs){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.sig=cs.sig;
  if (!prm.biasOnly) {
    this.parents=getParents(sent);
    if (prm.useZhaoFeats || prm.useDepPathFeats || prm.useBjorkelundFeats) {
      this.featuredSentence=createZhaoSentence();
      this.featuredHeadDefault=new FeatureObject(-1,parents,sent);
      this.featuredTailDefault=new FeatureObject(sent.size(),parents,sent);
    }
    if (prm.useAllTemplates) {
      this.prm.formFeats=true;
      this.prm.lemmaFeats=true;
      this.prm.tagFeats=true;
      this.prm.morphFeats=true;
      this.prm.deprelFeats=true;
      this.prm.childrenFeats=true;
      this.prm.pathFeats=true;
      this.prm.syntacticConnectionFeats=true;
    }
  }
 else {
    this.parents=null;
  }
}
Program: 131474
Project: 131474
Buggy source:
@Override public int compareTo(Var other){
  int c;
  c=this.numStates - other.numStates;
  if (c != 0) {
    return c;
  }
  c=this.type.compareTo(other.type);
  if (c != 0) {
    return c;
  }
  c=this.name.compareTo(other.name);
  if (c != 0) {
    return c;
  }
  c=this.stateNames.size() - other.stateNames.size();
  if (c != 0) {
    return c;
  }
  for (int i=0; i < this.stateNames.size(); i++) {
    c=this.stateNames.get(i).compareTo(other.stateNames.get(i));
    if (c != 0) {
      return c;
    }
  }
  return c;
}

Fixed version (ground truth):
@Override public int compareTo(Var other){
  int c;
  c=this.numStates - other.numStates;
  if (c != 0) {
    return c;
  }
  c=this.type.compareTo(other.type);
  if (c != 0) {
    return c;
  }
  c=this.name.compareTo(other.name);
  if (c != 0) {
    return c;
  }
  if (this.stateNames == null && other.stateNames != null) {
    return -1;
  }
 else   if (this.stateNames != null && other.stateNames == null) {
    return 1;
  }
 else   if (this.stateNames != null && other.stateNames != null) {
    c=this.stateNames.size() - other.stateNames.size();
    if (c != 0) {
      return c;
    }
    for (int i=0; i < this.stateNames.size(); i++) {
      c=this.stateNames.get(i).compareTo(other.stateNames.get(i));
      if (c != 0) {
        return c;
      }
    }
  }
  return c;
}
Program: 131475
Project: 131475
Buggy source:
/** 
 * @param type  The type of variable.
 * @param numStates  The number of states that this variable can take on.
 * @param name The unique name of this variable. 
 * @param stateNames The state names, where the i'th entry gives the state names of the i'th state.
 */
public Var(VarType type,int numStates,String name,List<String> stateNames){
  this.type=type;
  this.numStates=numStates;
  this.name=name.intern();
  if (stateNames != null) {
    assert(numStates == stateNames.size());
    this.stateNames=Lists.getInternedList(stateNames);
  }
}

Fixed version (ground truth):
/** 
 * @param type  The type of variable.
 * @param numStates  The number of states that this variable can take on.
 * @param name The unique name of this variable. 
 * @param stateNames The state names, where the i'th entry gives the state names of the i'th state.
 */
public Var(VarType type,int numStates,String name,List<String> stateNames){
  this.type=type;
  this.numStates=numStates;
  this.name=name.intern();
}
Program: 131476
Project: 131476
Buggy source:
public BfsBpSchedule(FactorGraph fg){
  order=new ArrayList<FgEdge>();
  for (  FgNode root : fg.getConnectedComponents()) {
    if (!fg.isUndirectedTree(root)) {
      throw new IllegalStateException("String_Node_Str" + root);
    }
    int numGlobalFactors=0;
    FgNode lastGlobalFactor=null;
    for (    FgNode node : fg.preOrderTraversal(root)) {
      if (node.isFactor() && node.getFactor() instanceof GlobalFactor) {
        lastGlobalFactor=node;
        numGlobalFactors++;
      }
    }
    if (numGlobalFactors > 1) {
      throw new RuntimeException("String_Node_Str");
    }
 else     if (numGlobalFactors == 1) {
      root=lastGlobalFactor;
    }
    addEdgesFromRoot(root,order,fg);
  }
}

Fixed version (ground truth):
public BfsBpSchedule(FactorGraph fg){
  order=new ArrayList<FgEdge>();
  for (  FgNode root : fg.getConnectedComponents()) {
    if (!fg.isUndirectedTree(root)) {
      System.out.println("String_Node_Str" + fg);
      throw new IllegalStateException("String_Node_Str" + root);
    }
    int numGlobalFactors=0;
    FgNode lastGlobalFactor=null;
    for (    FgNode node : fg.preOrderTraversal(root)) {
      if (node.isFactor() && node.getFactor() instanceof GlobalFactor) {
        lastGlobalFactor=node;
        numGlobalFactors++;
      }
    }
    if (numGlobalFactors > 1) {
      System.out.println("String_Node_Str" + fg);
      throw new RuntimeException("String_Node_Str");
    }
 else     if (numGlobalFactors == 1) {
      root=lastGlobalFactor;
    }
    addEdgesFromRoot(root,order,fg);
  }
}
Program: 131477
Project: 131477
Buggy source:
/** 
 * Gets the average marginal conditional log-likelihood computed on a batch.
 * @inheritDoc
 */
@Override public double getValue(int[] batch){
  boolean isFullDataset=batch.length == data.size();
  double ll=0.0;
  if (prm.numThreads == 1) {
    for (int i=0; i < batch.length; i++) {
      ll+=getMarginalLogLikelihoodForExample(batch[i]);
    }
  }
 else {
    ArrayList<Callable<Double>> tasks=new ArrayList<Callable<Double>>();
    for (int i=0; i < batch.length; i++) {
      tasks.add(new LogLikelihoodOfExample(batch[i]));
    }
    List<Double> results=Threads.getAllResults(pool,tasks);
    for (    Double r : results) {
      ll+=r;
    }
  }
  ll/=batch.length;
  if (isFullDataset) {
    log.info("String_Node_Str" + ll);
  }
  if (ll > MAX_LOG_LIKELIHOOD) {
    String name=isFullDataset ? "String_Node_Str" : "String_Node_Str";
    log.warn("String_Node_Str" + name + "String_Node_Str"+ ll);
  }
  return ll;
}

Fixed version (ground truth):
/** 
 * Gets the average marginal conditional log-likelihood computed on a batch.
 * @inheritDoc
 */
@Override public double getValue(int[] batch){
  boolean isFullDataset=batch.length == data.size();
  double ll=0.0;
  if (prm.numThreads == 1) {
    for (int i=0; i < batch.length; i++) {
      ll+=getMarginalLogLikelihoodForExample(batch[i]);
    }
  }
 else {
    TaskFactory<Double> factory=new TaskFactory<Double>(){
      public Callable<Double> getTask(      int i){
        return new LogLikelihoodOfExample(i);
      }
    }
;
    List<Double> results=Threads.safelyParallelizeBatch(pool,batch,factory);
    for (    Double r : results) {
      ll+=r;
    }
  }
  ll/=batch.length;
  if (isFullDataset) {
    log.info("String_Node_Str" + ll);
  }
  if (ll > MAX_LOG_LIKELIHOOD) {
    String name=isFullDataset ? "String_Node_Str" : "String_Node_Str";
    log.warn("String_Node_Str" + name + "String_Node_Str"+ ll);
  }
  return ll;
}
Program: 131478
Project: 131478
Buggy source:
/** 
 * Gets the gradient of the conditional log-likelihood on a batch of examples.
 * @inheritDoc
 */
@Override public void getGradient(int[] batch,double[] g){
  this.gradient.zero();
  if (prm.numThreads == 1) {
    for (int i=0; i < batch.length; i++) {
      log.trace("String_Node_Str" + batch[i]);
      addGradientForExample(batch[i],gradient);
    }
  }
 else {
    ArrayList<Callable<Object>> tasks=new ArrayList<Callable<Object>>();
    for (int i=0; i < batch.length; i++) {
      tasks.add(new AddGradientOfExample(gradient,batch[i]));
    }
    Threads.getAllResults(pool,tasks);
  }
  this.gradient.scale(1.0 / batch.length);
  gradient.updateDoublesFromModel(g);
}

Fixed version (ground truth):
/** 
 * Gets the gradient of the conditional log-likelihood on a batch of examples.
 * @inheritDoc
 */
@Override public void getGradient(int[] batch,double[] g){
  this.gradient.zero();
  if (prm.numThreads == 1) {
    for (int i=0; i < batch.length; i++) {
      log.trace("String_Node_Str" + batch[i]);
      addGradientForExample(batch[i],gradient);
    }
  }
 else {
    TaskFactory<Object> factory=new TaskFactory<Object>(){
      public Callable<Object> getTask(      int i){
        return new AddGradientOfExample(gradient,i);
      }
    }
;
    Threads.safelyParallelizeBatch(pool,batch,factory);
  }
  this.gradient.scale(1.0 / batch.length);
  gradient.updateDoublesFromModel(g);
}
Program: 131479
Project: 131479
Buggy source:
/** 
 * Updates the factor graph with the latest parameter vector. 
 * @param logDomain TODO
 */
private FactorGraph getUpdatedFactorGraph(FactorGraph fg,FgModel model,boolean logDomain){
  for (int a=0; a < fg.getNumFactors(); a++) {
    Factor f=fg.getFactor(a);
    if (f instanceof GlobalFactor) {
      continue;
    }
 else     if (f instanceof ExpFamFactor) {
      IntIter iter=null;
      if (fg == this.getFgLat()) {
        VarConfig predVc=this.getGoldConfigPred(a);
        iter=IndexForVc.getConfigIter(this.getFgLatPred().getFactor(a).getVars(),predVc);
      }
      DenseFactor factor=(DenseFactor)f;
      int numConfigs=factor.getVars().calcNumConfigs();
      for (int c=0; c < numConfigs; c++) {
        int config=(iter != null) ? iter.next() : c;
        IntDoubleVectorSlice params=model.getParams(model.getTemplates().getTemplateId(f),config);
        FeatureVector fv=getObservationFeatures(a);
        if (logDomain) {
          factor.setValue(c,fv.dot(params));
        }
 else {
          factor.setValue(c,FastMath.exp(fv.dot(params)));
        }
      }
    }
 else {
      throw new UnsupportedFactorTypeException(f);
    }
  }
  return fg;
}

Fixed version (ground truth):
/** 
 * Updates the factor graph with the latest parameter vector. 
 * @param logDomain TODO
 */
private FactorGraph getUpdatedFactorGraph(FactorGraph fg,FgModel model,boolean logDomain){
  for (int a=0; a < fg.getNumFactors(); a++) {
    Factor f=fg.getFactor(a);
    if (f instanceof GlobalFactor) {
      continue;
    }
 else     if (f instanceof ExpFamFactor) {
      IntIter iter=null;
      if (fg == this.getFgLat()) {
        VarConfig predVc=this.getGoldConfigPred(a);
        iter=IndexForVc.getConfigIter(this.getFgLatPred().getFactor(a).getVars(),predVc);
      }
      DenseFactor factor=(DenseFactor)f;
      int numConfigs=factor.getVars().calcNumConfigs();
      for (int c=0; c < numConfigs; c++) {
        int config=(iter != null) ? iter.next() : c;
        FeatureVector fv=getObservationFeatures(a);
        double dot=model.dot(model.getTemplates().getTemplateId(f),config,fv);
        if (logDomain) {
          factor.setValue(c,dot);
        }
 else {
          factor.setValue(c,FastMath.exp(dot));
        }
      }
    }
 else {
      throw new UnsupportedFactorTypeException(f);
    }
  }
  return fg;
}
Program: 131482
Project: 131482
Buggy source:
public CrfObjective(FgModel model,FgExamples data,FgInferencerFactory infFactory){
  this.numParams=model.getNumParams();
  this.data=data;
  this.model=model;
  this.gradient=new FgModel(model);
  this.gradient.zero();
  log.debug("String_Node_Str");
  infLatList=new ArrayList<FgInferencer>(data.size());
  infLatPredList=new ArrayList<FgInferencer>(data.size());
  for (int i=0; i < data.size(); i++) {
    FgExample ex=data.get(i);
    infLatList.add(infFactory.getInferencer(ex.getFgLat()));
    infLatPredList.add(infFactory.getInferencer(ex.getFgLatPred()));
  }
}

Fixed version (ground truth):
public CrfObjective(FgModel model,FgExamples data,FgInferencerFactory infFactory){
  this.numParams=model.getNumParams();
  this.data=data;
  this.model=model;
  this.infFactory=infFactory;
  this.gradient=new FgModel(model);
  this.gradient.zero();
}
Program: 131483
Project: 131483
Buggy source:
/** 
 * Adds the gradient for a particular example to the gradient vector.
 * @param params The model parameters.
 * @param i The index of the data example.
 * @param gradient The gradient vector to which this example's contributionis added.
 */
private void addGradientForExample(int i,FgModel gradient){
  FgExample ex=data.get(i);
  FgInferencer infLat=infLatList.get(i);
  FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
  infLat.run();
  addExpectedFeatureCounts(fgLat,ex,infLat,data.getTemplates(),1.0,gradient);
  infLat.clear();
  FgInferencer infLatPred=infLatPredList.get(i);
  FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
  infLatPred.run();
  addExpectedFeatureCounts(fgLatPred,ex,infLatPred,data.getTemplates(),-1.0,gradient);
  infLatPred.clear();
}

Fixed version (ground truth):
/** 
 * Adds the gradient for a particular example to the gradient vector.
 * @param params The model parameters.
 * @param i The index of the data example.
 * @param gradient The gradient vector to which this example's contributionis added.
 */
private void addGradientForExample(int i,FgModel gradient){
  FgExample ex=data.get(i);
  FgInferencer infLat=getInfLat(ex);
  FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
  infLat.run();
  addExpectedFeatureCounts(fgLat,ex,infLat,data.getTemplates(),1.0,gradient);
  infLat.clear();
  FgInferencer infLatPred=getInfLatPred(ex);
  FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
  infLatPred.run();
  addExpectedFeatureCounts(fgLatPred,ex,infLatPred,data.getTemplates(),-1.0,gradient);
  infLatPred.clear();
}
Program: 131484
Project: 131484
Buggy source:
/** 
 * Gets the "expected" feature counts. 
 */
public FeatureVector getExpectedFeatureCounts(double[] params){
  model.updateModelFromDoubles(params);
  FgModel feats=new FgModel(model);
  feats.zero();
  for (int i=0; i < data.size(); i++) {
    FgExample ex=data.get(i);
    FgInferencer infLatPred=infLatPredList.get(i);
    FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
    infLatPred.run();
    addExpectedFeatureCounts(fgLatPred,ex,infLatPred,data.getTemplates(),1.0,feats);
  }
  double[] f=new double[numParams];
  feats.updateDoublesFromModel(f);
  return new FeatureVector(f);
}

Fixed version (ground truth):
/** 
 * Gets the "expected" feature counts. 
 */
public FeatureVector getExpectedFeatureCounts(double[] params){
  model.updateModelFromDoubles(params);
  FgModel feats=new FgModel(model);
  feats.zero();
  for (int i=0; i < data.size(); i++) {
    FgExample ex=data.get(i);
    FgInferencer infLatPred=getInfLatPred(ex);
    FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
    infLatPred.run();
    addExpectedFeatureCounts(fgLatPred,ex,infLatPred,data.getTemplates(),1.0,feats);
  }
  double[] f=new double[numParams];
  feats.updateDoublesFromModel(f);
  return new FeatureVector(f);
}
Program: 131485
Project: 131485
Buggy source:
/** 
 * Gets the "observed" feature counts. 
 */
public FeatureVector getObservedFeatureCounts(double[] params){
  model.updateModelFromDoubles(params);
  FgModel feats=new FgModel(model);
  feats.zero();
  for (int i=0; i < data.size(); i++) {
    FgExample ex=data.get(i);
    FgInferencer infLat=infLatList.get(i);
    FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
    infLat.run();
    addExpectedFeatureCounts(fgLat,ex,infLat,data.getTemplates(),1.0,feats);
  }
  double[] f=new double[numParams];
  feats.updateDoublesFromModel(f);
  return new FeatureVector(f);
}

Fixed version (ground truth):
/** 
 * Gets the "observed" feature counts. 
 */
public FeatureVector getObservedFeatureCounts(double[] params){
  model.updateModelFromDoubles(params);
  FgModel feats=new FgModel(model);
  feats.zero();
  for (int i=0; i < data.size(); i++) {
    FgExample ex=data.get(i);
    FgInferencer infLat=getInfLat(ex);
    FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
    infLat.run();
    addExpectedFeatureCounts(fgLat,ex,infLat,data.getTemplates(),1.0,feats);
  }
  double[] f=new double[numParams];
  feats.updateDoublesFromModel(f);
  return new FeatureVector(f);
}
Program: 131486
Project: 131486
Buggy source:
public FgExamples getInstance(FeatureTemplateList fts,FgExampleFactory factory){
  boolean doingFeatCutoff=(fts.isGrowing() && prm.featCountCutoff > 0);
  if (doingFeatCutoff) {
    cutoffFeatures(prm.featCountCutoff,fts,factory);
  }
  FgExamples data=new FgExampleFactoryWrapper(fts,factory);
  if (prm.cacheType == CacheType.CACHE) {
    data=new FgExamplesCache(fts,data,prm.maxEntriesInMemory);
    constructAndDiscardAll(data);
  }
 else   if (prm.cacheType == CacheType.MEMORY_STORE) {
    FgExamplesStore store=new FgExamplesMemoryStore(fts);
    constructAndStoreAll(data,store);
    data=store;
  }
 else   if (prm.cacheType == CacheType.DISK_STORE) {
    FgExamplesStore store=new FgExamplesDiskStore(fts,prm.cacheDir,prm.gzipped,prm.maxEntriesInMemory);
    constructAndStoreAll(data,store);
    data=store;
  }
 else   if (prm.cacheType == CacheType.NONE) {
  }
 else {
    throw new IllegalStateException("String_Node_Str" + prm.cacheType);
  }
  fts.stopGrowth();
  return data;
}

Fixed version (ground truth):
public FgExamples getInstance(FeatureTemplateList fts,FgExampleFactory factory){
  boolean doingFeatCutoff=(fts.isGrowing() && prm.featCountCutoff > 0);
  if (doingFeatCutoff) {
    log.info("String_Node_Str" + prm.featCountCutoff);
    cutoffFeatures(prm.featCountCutoff,fts,factory);
  }
  FgExamples data=new FgExampleFactoryWrapper(fts,factory);
  if (prm.cacheType == CacheType.CACHE) {
    data=new FgExamplesCache(fts,data,prm.maxEntriesInMemory);
    constructAndDiscardAll(data);
  }
 else   if (prm.cacheType == CacheType.MEMORY_STORE) {
    FgExamplesStore store=new FgExamplesMemoryStore(fts);
    constructAndStoreAll(data,store);
    data=store;
  }
 else   if (prm.cacheType == CacheType.DISK_STORE) {
    FgExamplesStore store=new FgExamplesDiskStore(fts,prm.cacheDir,prm.gzipped,prm.maxEntriesInMemory);
    constructAndStoreAll(data,store);
    data=store;
  }
 else   if (prm.cacheType == CacheType.NONE) {
  }
 else {
    throw new IllegalStateException("String_Node_Str" + prm.cacheType);
  }
  fts.stopGrowth();
  return data;
}
Program: 131487
Project: 131487
Buggy source:
private void eval(FgExamples data,String name,List<VarConfig> predictions){
  AccuracyEvaluator accEval=new AccuracyEvaluator();
  double accuracy=accEval.evaluate(data.getGoldConfigs(),predictions);
  log.info(String.format("String_Node_Str",name,accuracy));
}

Fixed version (ground truth):
private void eval(String name,VarConfigPair pair){
  AccuracyEvaluator accEval=new AccuracyEvaluator();
  double accuracy=accEval.evaluate(pair.gold,pair.pred);
  log.info(String.format("String_Node_Str",name,accuracy));
}
Program: 131489
Project: 131489
Buggy source:
private List<VarConfig> decode(FgModel model,FgExamples data,File predOut,String name) throws IOException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  List<VarConfig> predictions=new ArrayList<VarConfig>();
  HashMap<Var,Double> varMargMap=new HashMap<Var,Double>();
  for (int i=0; i < data.size(); i++) {
    MbrDecoder decoder=getDecoder();
    decoder.decode(model,data.get(i));
    predictions.add(decoder.getMbrVarConfig());
    varMargMap.putAll(decoder.getVarMargMap());
  }
  if (predOut != null) {
    ErmaWriter ew=new ErmaWriter();
    ew.writePredictions(predOut,predictions,varMargMap);
  }
  return predictions;
}

Fixed version (ground truth):
private VarConfigPair decode(FgModel model,FgExamples data,File predOut,String name) throws IOException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  List<VarConfig> predVcs=new ArrayList<VarConfig>();
  List<VarConfig> goldVcs=new ArrayList<VarConfig>();
  HashMap<Var,Double> varMargMap=new HashMap<Var,Double>();
  for (int i=0; i < data.size(); i++) {
    MbrDecoder decoder=getDecoder();
    FgExample ex=data.get(i);
    decoder.decode(model,ex);
    predVcs.add(decoder.getMbrVarConfig());
    varMargMap.putAll(decoder.getVarMargMap());
    goldVcs.add(ex.getGoldConfig());
  }
  if (predOut != null) {
    ErmaWriter ew=new ErmaWriter();
    ew.writePredictions(predOut,predVcs,varMargMap);
  }
  return new VarConfigPair(goldVcs,predVcs);
}
Program: 131490
Project: 131490
Buggy source:
/** 
 * Decodes the example using the given model.
 * @param model The model.
 * @param ex The example to decode.
 * @param sent The sentence corresponding to the example.
 */
public void decode(FgModel model,FgExample ex){
  MbrDecoder mbrDecoder=new MbrDecoder(prm.mbrPrm);
  mbrDecoder.decode(model,ex);
  SrlFactorGraph srlFg=(SrlFactorGraph)ex.getOriginalFactorGraph();
  int n=srlFg.getSentenceLength();
  mbrVarConfig=mbrDecoder.getMbrVarConfig();
  srlGraph=getSrlGraphFromVarConfig(mbrVarConfig,n);
  parents=getParents(mbrDecoder.getVarMarginals(),ex.getFgLatPred().getVars(),n);
  if (parents != null) {
    for (int p=-1; p < n; p++) {
      for (int c=0; c < n; c++) {
        int state=(parents[c] == p) ? LinkVar.TRUE : LinkVar.FALSE;
        if (srlFg.getLinkVar(p,c) != null) {
          mbrVarConfig.put(srlFg.getLinkVar(p,c),state);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Decodes the example using the given model.
 * @param model The model.
 * @param ex The example to decode.
 */
public void decode(FgModel model,FgExample ex){
  MbrDecoder mbrDecoder=new MbrDecoder(prm.mbrPrm);
  mbrDecoder.decode(model,ex);
  SrlFactorGraph srlFg=(SrlFactorGraph)ex.getOriginalFactorGraph();
  int n=srlFg.getSentenceLength();
  mbrVarConfig=mbrDecoder.getMbrVarConfig();
  srlGraph=getSrlGraphFromVarConfig(mbrVarConfig,n);
  parents=getParents(mbrDecoder.getVarMarginals(),ex.getFgLatPred().getVars(),n);
  if (parents != null) {
    for (int p=-1; p < n; p++) {
      for (int c=0; c < n; c++) {
        int state=(parents[c] == p) ? LinkVar.TRUE : LinkVar.FALSE;
        if (srlFg.getLinkVar(p,c) != null) {
          mbrVarConfig.put(srlFg.getLinkVar(p,c),state);
        }
      }
    }
  }
}
Program: 131491
Project: 131491
Buggy source:
private static SrlFgExampleBuilderPrm getSrlFgExampleBuilderPrm(){
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fgPrm.linkVarType=linkVarType;
  prm.fgPrm.makeUnknownPredRolesLatent=makeUnknownPredRolesLatent;
  prm.fgPrm.roleStructure=roleStructure;
  prm.fgPrm.useProjDepTreeFactor=useProjDepTreeFactor;
  prm.fgPrm.allowPredArgSelfLoops=allowPredArgSelfLoops;
  prm.fgPrm.unaryFactors=unaryFactors;
  prm.fgPrm.alwaysIncludeLinkVars=alwaysIncludeLinkVars;
  prm.fgPrm.predictSense=predictSense;
  prm.fePrm.biasOnly=biasOnly;
  prm.fePrm.useSimpleFeats=useSimpleFeats;
  prm.fePrm.useNaradFeats=useNaradFeats;
  prm.fePrm.useZhaoFeats=useZhaoFeats;
  prm.fePrm.useBjorkelundFeats=useBjorkelundFeats;
  prm.fePrm.useDepPathFeats=useDepPathFeats;
  prm.exPrm.featCountCutoff=featCountCutoff;
  prm.exPrm.cacheType=cacheType;
  prm.exPrm.gzipped=true;
  prm.exPrm.maxEntriesInMemory=-1;
  prm.srlFePrm.featureHashMod=featureHashMod;
  return prm;
}

Fixed version (ground truth):
private static SrlFgExampleBuilderPrm getSrlFgExampleBuilderPrm(){
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fgPrm.linkVarType=linkVarType;
  prm.fgPrm.makeUnknownPredRolesLatent=makeUnknownPredRolesLatent;
  prm.fgPrm.roleStructure=roleStructure;
  prm.fgPrm.useProjDepTreeFactor=useProjDepTreeFactor;
  prm.fgPrm.allowPredArgSelfLoops=allowPredArgSelfLoops;
  prm.fgPrm.unaryFactors=unaryFactors;
  prm.fgPrm.alwaysIncludeLinkVars=alwaysIncludeLinkVars;
  prm.fgPrm.predictSense=predictSense;
  prm.fePrm.biasOnly=biasOnly;
  prm.fePrm.useSimpleFeats=useSimpleFeats;
  prm.fePrm.useNaradFeats=useNaradFeats;
  prm.fePrm.useZhaoFeats=useZhaoFeats;
  prm.fePrm.useBjorkelundFeats=useBjorkelundFeats;
  prm.fePrm.useDepPathFeats=useDepPathFeats;
  prm.exPrm.featCountCutoff=featCountCutoff;
  prm.exPrm.cacheType=cacheType;
  prm.exPrm.gzipped=true;
  prm.exPrm.maxEntriesInMemory=maxEntriesInMemory;
  prm.srlFePrm.featureHashMod=featureHashMod;
  return prm;
}
Program: 131493
Project: 131493
Buggy source:
private List<VarConfig> decode(FgModel model,FgExamples data,DatasetType dataType,File predOut,String name) throws IOException, ParseException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  SimpleAnnoSentenceCollection goldSents=(SimpleAnnoSentenceCollection)data.getSourceSentences();
  SimpleAnnoSentenceCollection predSents=new SimpleAnnoSentenceCollection();
  List<VarConfig> predictions=new ArrayList<VarConfig>();
  for (int i=0; i < goldSents.size(); i++) {
    SimpleAnnoSentence goldSent=goldSents.get(i);
    SimpleAnnoSentence predSent=new SimpleAnnoSentence(goldSent);
    SrlDecoder decoder=getDecoder();
    decoder.decode(model,data.get(i));
    SrlGraph srlGraph=decoder.getSrlGraph();
    predSent.setSrlGraph(srlGraph);
    int[] parents=decoder.getParents();
    if (parents != null) {
      predSent.setParents(parents);
    }
    VarConfig vc=decoder.getMbrVarConfig();
    predictions.add(vc);
    predSents.add(predSent);
  }
  if (predOut != null) {
    log.info("String_Node_Str" + name + "String_Node_Str"+ dataType+ "String_Node_Str"+ predOut);
    if (dataType == DatasetType.CONLL_2009) {
      CoNLL09Writer cw=new CoNLL09Writer(predOut);
      for (      SimpleAnnoSentence sent : predSents) {
        CoNLL09Sentence conllSent=CoNLL09Sentence.fromSimpleAnnoSentence(sent);
        cw.write(conllSent);
      }
      cw.close();
    }
 else {
      throw new ParseException("String_Node_Str" + dataType);
    }
  }
  return predictions;
}

Fixed version (ground truth):
private VarConfigPair decode(FgModel model,FgExamples data,DatasetType dataType,File predOut,String name) throws IOException, ParseException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  SimpleAnnoSentenceCollection goldSents=(SimpleAnnoSentenceCollection)data.getSourceSentences();
  SimpleAnnoSentenceCollection predSents=new SimpleAnnoSentenceCollection();
  List<VarConfig> predVcs=new ArrayList<VarConfig>();
  List<VarConfig> goldVcs=new ArrayList<VarConfig>();
  for (int i=0; i < goldSents.size(); i++) {
    FgExample ex=data.get(i);
    SimpleAnnoSentence goldSent=goldSents.get(i);
    SimpleAnnoSentence predSent=new SimpleAnnoSentence(goldSent);
    SrlDecoder decoder=getDecoder();
    decoder.decode(model,ex);
    VarConfig predVc=decoder.getMbrVarConfig();
    predVcs.add(predVc);
    SrlGraph srlGraph=decoder.getSrlGraph();
    predSent.setSrlGraph(srlGraph);
    int[] parents=decoder.getParents();
    if (parents != null) {
      predSent.setParents(parents);
    }
    predSents.add(predSent);
    goldVcs.add(ex.getGoldConfig());
  }
  if (predOut != null) {
    log.info("String_Node_Str" + name + "String_Node_Str"+ dataType+ "String_Node_Str"+ predOut);
    if (dataType == DatasetType.CONLL_2009) {
      CoNLL09Writer cw=new CoNLL09Writer(predOut);
      for (      SimpleAnnoSentence sent : predSents) {
        CoNLL09Sentence conllSent=CoNLL09Sentence.fromSimpleAnnoSentence(sent);
        cw.write(conllSent);
      }
      cw.close();
    }
 else {
      throw new ParseException("String_Node_Str" + dataType);
    }
  }
  return new VarConfigPair(goldVcs,predVcs);
}
Program: 131494
Project: 131494
Buggy source:
private void eval(FgExamples data,String name,List<VarConfig> predictions){
  AccuracyEvaluator accEval=new AccuracyEvaluator();
  double accuracy=accEval.evaluate(data.getGoldConfigs(),predictions);
  log.info(String.format("String_Node_Str",name,accuracy));
}

Fixed version (ground truth):
private void eval(String name,VarConfigPair pair){
  AccuracyEvaluator accEval=new AccuracyEvaluator();
  double accuracy=accEval.evaluate(pair.gold,pair.pred);
  log.info(String.format("String_Node_Str",name,accuracy));
}
Program: 131495
Project: 131495
Buggy source:
public void convertRealToLog(){
  apply(new LambdaOneToOne<Double,Double>(){
    public Double call(    Double value){
      return Utilities.log(value);
    }
  }
);
}

Fixed version (ground truth):
public void convertRealToLog(){
}
Program: 131496
Project: 131496
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 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));
    }
  }
}

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]);
        assert(!Double.isNaN(logSums[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: 131497
Project: 131497
Buggy source:
public static DmvModel getTieredModel(int numTiers,int numTags,RealParamGen gen){
  Alphabet<Label> alphabet=new Alphabet<Label>();
  IntIntHashMap idxTierMap=new IntIntHashMap(numTags,-1);
  Label[][] labels=new Label[numTiers][];
  int remain=numTags;
  int count=0;
  for (int tier=0; tier < numTiers; tier++) {
    int numTagsInTier;
    if (tier == numTiers - 1) {
      numTagsInTier=remain;
    }
 else {
      numTagsInTier=numTags / numTiers;
    }
    remain-=numTagsInTier;
    labels[tier]=new Label[numTagsInTier];
    for (int i=0; i < labels[tier].length; i++) {
      labels[tier][i]=new TaggedWord(Character.toString((char)(97 + i)) + tier,Character.toString((char)(65 + i)) + tier);
      count++;
      int idx=alphabet.lookupIndex(labels[tier][i]);
      idxTierMap.put(idx,tier);
    }
  }
  DmvModelFactory modelFactory=new RandomDmvModelFactory(1.0);
  DmvModel dmv=(DmvModel)modelFactory.getInstance(alphabet);
  dmv.fill(0.0);
  dmv.convertLogToReal();
  for (int c=0; c < numTags; c++) {
    int ctier=idxTierMap.get(c);
    dmv.root[c]=gen.getRoot(ctier,numTiers);
    for (int p=0; p < numTags; p++) {
      int ptier=idxTierMap.get(p);
      for (int dir=0; dir < 2; dir++) {
        dmv.child[c][p][dir]=gen.getChild(ptier,ctier,numTiers);
      }
    }
    for (int dir=0; dir < 2; dir++) {
      for (int val=0; val < 2; val++) {
        dmv.decision[c][dir][val][DmvModel.CONT]=gen.getCont(ctier,numTiers,val,dir);
        dmv.decision[c][dir][val][DmvModel.END]=1.0 - dmv.decision[c][dir][val][DmvModel.CONT];
      }
    }
  }
  dmv.normalize();
  dmv.convertRealToLog();
  dmv.assertLogNormalized(1e-13);
  return dmv;
}

Fixed version (ground truth):
public static DmvModel getTieredModel(int numTiers,int numTags,RealParamGen gen){
}
Program: 131498
Project: 131498
Buggy source:
@Test public void testTieredModelGeneration(){
  int numTiers=3;
  int numTags=9;
  DmvModel dmvModel=DmvModelGenerator.getTieredModel(numTiers,numTags,new StochasticRealParamGenerator());
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,System.currentTimeMillis());
  dmvModel.convertLogToReal();
  System.out.println(dmvModel);
  dmvModel.convertRealToLog();
  DepTreebank treebank=generator.getTreebank(400);
  System.out.println(treebank);
  int maxSentenceLength=-1;
  int sumSentLen=0;
  for (  DepTree tree : treebank) {
    sumSentLen+=tree.getNumTokens();
    if (tree.getNumTokens() > maxSentenceLength) {
      maxSentenceLength=tree.getNumTokens();
    }
  }
  System.out.println("String_Node_Str" + maxSentenceLength);
  System.out.println("String_Node_Str" + (double)sumSentLen / treebank.size());
}

Fixed version (ground truth):
@Test public void testTieredModelGeneration(){
  int numTiers=3;
  int numTags=7;
  DmvModel dmvModel=DmvModelGenerator.getTieredModel(numTiers,numTags,new StochasticRealParamGenerator(10.0));
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,System.currentTimeMillis());
  dmvModel.convertLogToReal();
  System.out.println(dmvModel);
  dmvModel.convertRealToLog();
  DepTreebank treebank=generator.getTreebank(400);
  System.out.println(treebank);
  int maxSentenceLength=-1;
  int sumSentLen=0;
  for (  DepTree tree : treebank) {
    sumSentLen+=tree.getNumTokens();
    if (tree.getNumTokens() > maxSentenceLength) {
      maxSentenceLength=tree.getNumTokens();
    }
  }
  System.out.println("String_Node_Str" + maxSentenceLength);
  System.out.println("String_Node_Str" + (double)sumSentLen / treebank.size());
}
Program: 131499
Project: 131499
Buggy source:
public static CoNLL09Sentence fromSimpleAnnoSentence(SimpleAnnoSentence sent){
  if (sent.getSourceSent() == null || !(sent.getSourceSent() instanceof CoNLL09Sentence)) {
    throw new RuntimeException("String_Node_Str");
  }
  CoNLL09Sentence updatedSentence=new CoNLL09Sentence((CoNLL09Sentence)sent.getSourceSent());
  for (int i=0; i < updatedSentence.size(); i++) {
    CoNLL09Token tok=updatedSentence.get(i);
    tok.setPlemma(sent.getLemma(i));
    tok.setPpos(sent.getPosTag(i));
    tok.setPfeat(sent.getFeats(i));
    tok.setPhead(sent.getParent(i) + 1);
    tok.setPdeprel(sent.getDeprel(i));
  }
  return updatedSentence;
}

Fixed version (ground truth):
/** 
 * Creates a new CoNLL09Sentence with both columns set for each field (i.e. PLEMMA and LEMMA are both set from the values on the SimpleAnnoSentence). The reason for setting both is that the CoNLL-2009 evaluation script uses the "gold" columns for evaluation, but we might want to utilize the predictions in some downstream task.
 */
public static CoNLL09Sentence fromSimpleAnnoSentence(SimpleAnnoSentence sent){
  List<CoNLL09Token> toks=new ArrayList<CoNLL09Token>();
  for (int i=0; i < sent.size(); i++) {
    CoNLL09Token tok=new CoNLL09Token();
    tok.setId(i + 1);
    tok.setForm(sent.getWord(i));
    tok.setPlemma(sent.getLemma(i));
    tok.setPpos(sent.getPosTag(i));
    tok.setPfeat(sent.getFeats(i));
    tok.setPhead(sent.getParent(i) + 1);
    tok.setPdeprel(sent.getDeprel(i));
    tok.setLemma(sent.getLemma(i));
    tok.setPos(sent.getPosTag(i));
    tok.setFeat(sent.getFeats(i));
    tok.setHead(sent.getParent(i) + 1);
    tok.setDeprel(sent.getDeprel(i));
    toks.add(tok);
  }
  CoNLL09Sentence updatedSentence=new CoNLL09Sentence(toks);
  updatedSentence.setColsFromSrlGraph(sent.getSrlGraph(),false,true);
  return updatedSentence;
}
Program: 131500
Project: 131500
Buggy source:
/** 
 * Deep copy constructor 
 */
public CoNLL09Token(CoNLL09Token other){
  this.id=other.id;
  this.form=other.form;
  this.lemma=other.lemma;
  this.plemma=other.plemma;
  this.pos=other.pos;
  this.ppos=other.ppos;
  this.feat=other.feat == null ? null : new ArrayList<String>(other.feat);
  this.pfeat=other.pfeat == null ? null : new ArrayList<String>(other.pfeat);
  this.head=other.head;
  this.phead=other.phead;
  this.deprel=other.deprel;
  this.pdeprel=other.pdeprel;
  this.fillpred=other.fillpred;
  this.pred=other.pred;
  this.apreds=other.apreds == null ? null : new ArrayList<String>(other.apreds);
}

Fixed version (ground truth):
/** 
 * Constructor which leaves all fields empty. 
 */
CoNLL09Token(){
  super();
  this.id=-1;
  this.head=-1;
  this.phead=-1;
}
Program: 131505
Project: 131505
Buggy source:
public SentFeatureExtractor(SentFeatureExtractorPrm prm,SimpleAnnoSentence sent,CorpusStatistics cs){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.sig=cs.sig;
  if (!prm.biasOnly) {
    this.parents=getParents(sent);
    if (prm.useZhaoFeats || prm.useDepPathFeats) {
      this.featuredSentence=createZhaoSentence();
      this.featuredHeadDefault=new FeatureObject(-1,parents,sent);
      this.featuredTailDefault=new FeatureObject(sent.size(),parents,sent);
    }
  }
 else {
    this.parents=null;
  }
}

Fixed version (ground truth):
public SentFeatureExtractor(SentFeatureExtractorPrm prm,SimpleAnnoSentence sent,CorpusStatistics cs){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.sig=cs.sig;
  if (!prm.biasOnly) {
    this.parents=getParents(sent);
    if (prm.useZhaoFeats || prm.useDepPathFeats || prm.useBjorkelundFeats) {
      this.featuredSentence=createZhaoSentence();
      this.featuredHeadDefault=new FeatureObject(-1,parents,sent);
      this.featuredTailDefault=new FeatureObject(sent.size(),parents,sent);
    }
  }
 else {
    this.parents=null;
  }
}
Program: 131506
Project: 131506
Buggy source:
private void maybeUpdateGradientAndValue(){
  if (!areGradientAndValueCached) {
    function.setPoint(params);
    value=function.getValue();
    function.getGradient(gradient);
    areGradientAndValueCached=true;
  }
}

Fixed version (ground truth):
private void maybeUpdateGradientAndValue(){
  if (!areGradientAndValueCached) {
    function.setPoint(params);
    value=function.getValue();
    Arrays.fill(gradient,0.0);
    function.getGradient(gradient);
    areGradientAndValueCached=true;
  }
}
Program: 131507
Project: 131507
Buggy source:
@Test public void testZhaoObjectFeat(){
  CoNLL09Sentence sent=getSpanishConll09Sentence2();
  CorpusStatisticsPrm csPrm=new CorpusStatisticsPrm();
  csPrm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(csPrm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  SentFeatureExtractor fe=new SentFeatureExtractor(fePrm,sent,cs);
  int[] parents=fe.getParents(sent);
  ZhaoObject zhaoPred=new ZhaoObject(3,parents,sent,cs);
  ZhaoObject zhaoArg=new ZhaoObject(4,parents,sent,cs);
  List<String> predFeat=zhaoPred.getFeat();
  List<String> argFeat=zhaoArg.getFeat();
  ArrayList<String> intendedPredFeats=new ArrayList<String>();
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  assertEquals(predFeat,intendedPredFeats);
  ArrayList<String> intendedArgFeats=new ArrayList<String>();
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  System.out.println(argFeat);
  assertEquals(argFeat,intendedArgFeats);
}

Fixed version (ground truth):
@Test public void testZhaoObjectFeat(){
  CoNLL09Sentence sent=getSpanishConll09Sentence2();
  CorpusStatisticsPrm csPrm=new CorpusStatisticsPrm();
  csPrm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(csPrm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  SentFeatureExtractor fe=new SentFeatureExtractor(fePrm,sent,cs);
  int[] parents=fe.getParents(sent);
  ZhaoObject zhaoPred=new ZhaoObject(3,parents,sent,cs);
  ZhaoObject zhaoArg=new ZhaoObject(4,parents,sent,cs);
  List<String> predFeat=zhaoPred.getPfeat();
  List<String> argFeat=zhaoArg.getPfeat();
  ArrayList<String> intendedPredFeats=new ArrayList<String>();
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  intendedPredFeats.add("String_Node_Str");
  assertEquals(predFeat,intendedPredFeats);
  ArrayList<String> intendedArgFeats=new ArrayList<String>();
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  intendedArgFeats.add("String_Node_Str");
  System.out.println(argFeat);
  assertEquals(argFeat,intendedArgFeats);
}
Program: 131508
Project: 131508
Buggy source:
public ZhaoObject(String input){
  super(-1,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,null,null,-2,-2,"String_Node_Str" + input,"String_Node_Str" + input,false,"String_Node_Str" + input,null);
  setFeat(-1);
  this.rootPath=new ArrayList<Pair<Integer,Dir>>();
  this.rootPath.add(new Pair<Integer,Dir>(-1,Dir.UP));
  this.parent=-1;
  this.children=new ArrayList<Integer>();
  this.children.add(-1);
  this.farLeftChild=-1;
  this.farRightChild=-1;
  this.nearLeftChild=-1;
  this.nearRightChild=-1;
  this.argLowSupport=-1;
  this.argHighSupport=-1;
  this.predLowSupport=-1;
  this.predHighSupport=-1;
  this.noFarChildren=new ArrayList<Integer>();
  setNoFarChildren();
}

Fixed version (ground truth):
public ZhaoObject(String input){
  super(-1,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,"String_Node_Str" + input,null,null,-2,-2,"String_Node_Str" + input,"String_Node_Str" + input,false,"String_Node_Str" + input,null);
  setPfeat(-1);
  this.rootPath=new ArrayList<Pair<Integer,Dir>>();
  this.rootPath.add(new Pair<Integer,Dir>(-1,Dir.UP));
  this.parent=-1;
  this.children=new ArrayList<Integer>();
  this.children.add(-1);
  this.farLeftChild=-1;
  this.farRightChild=-1;
  this.nearLeftChild=-1;
  this.nearRightChild=-1;
  this.argLowSupport=-1;
  this.argHighSupport=-1;
  this.predLowSupport=-1;
  this.predHighSupport=-1;
  this.noFarChildren=new ArrayList<Integer>();
  setNoFarChildren();
}
Program: 131509
Project: 131509
Buggy source:
public void setPfeat(Integer idx){
  feat=new ArrayList<String>(6);
  if (idx == -1) {
    for (int i=0; i < 6; i++) {
      feat.add(NO_MORPH);
    }
  }
 else {
    List<String> coNLLFeats=sent.get(idx).getPfeat();
    if (coNLLFeats == null) {
      for (int i=0; i < 6; i++) {
        feat.add(NO_MORPH);
      }
    }
 else {
      feat.addAll(coNLLFeats);
      for (int i=feat.size(); i < 6; i++) {
        feat.add(NO_MORPH);
      }
    }
  }
}

Fixed version (ground truth):
public void setPfeat(Integer idx){
  feat=new ArrayList<String>(6);
  if (idx == -1) {
    for (int i=0; i < 6; i++) {
      feat.add(NO_MORPH);
    }
  }
 else {
    List<String> coNLLFeats=word.getPfeat();
    if (coNLLFeats == null) {
      for (int i=0; i < 6; i++) {
        feat.add(NO_MORPH);
      }
    }
 else {
      feat.addAll(coNLLFeats);
      for (int i=feat.size(); i < 6; i++) {
        feat.add(NO_MORPH);
      }
    }
  }
}
Program: 131510
Project: 131510
Buggy source:
public SentFeatureExtractor(SentFeatureExtractorPrm prm,CoNLL09Sentence sent,CorpusStatistics cs,Alphabet<String> alphabet){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.alphabet=alphabet;
  this.sig=cs.sig;
  this.parents=getParents(sent);
  if (prm.useZhaoFeats) {
    this.zhaoSentence=createZhaoSentence();
    this.zhaoHeadDefault=new ZhaoObject("String_Node_Str");
    this.zhaoTailDefault=new ZhaoObject("String_Node_Str");
  }
}

Fixed version (ground truth):
public SentFeatureExtractor(SentFeatureExtractorPrm prm,CoNLL09Sentence sent,CorpusStatistics cs,Alphabet<String> alphabet){
  this.prm=prm;
  this.sent=sent;
  this.cs=cs;
  this.alphabet=alphabet;
  this.sig=cs.sig;
  this.parents=getParents(sent);
  if (prm.useZhaoFeats || prm.useDepPathFeats) {
    this.zhaoSentence=createZhaoSentence();
    this.zhaoHeadDefault=new ZhaoObject("String_Node_Str");
    this.zhaoTailDefault=new ZhaoObject("String_Node_Str");
  }
}
Program: 131512
Project: 131512
Buggy source:
public static FeatureTemplateList getFtl(){
  FeatureTemplateList fts=new FeatureTemplateList();
  Var v1=new Var(VarType.PREDICTED,2,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str"));
  Var v2=new Var(VarType.PREDICTED,3,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str","String_Node_Str"));
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    fts.add(new FeatureTemplate(new VarSet(v1),alphabet,"String_Node_Str"));
  }
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    fts.add(new FeatureTemplate(new VarSet(v1,v2),alphabet,"String_Node_Str"));
  }
  return fts;
}

Fixed version (ground truth):
public static FeatureTemplateList getFtl(boolean useLat){
  FeatureTemplateList fts=new FeatureTemplateList();
  Var v1=new Var(VarType.PREDICTED,2,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str"));
  Var v2=new Var(useLat ? VarType.LATENT : VarType.PREDICTED,3,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str","String_Node_Str"));
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    fts.add(new FeatureTemplate(new VarSet(v1),alphabet,"String_Node_Str"));
  }
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    alphabet.lookupIndex(new Feature("String_Node_Str"));
    fts.add(new FeatureTemplate(new VarSet(v1,v2),alphabet,"String_Node_Str"));
  }
  return fts;
}
Program: 131513
Project: 131513
Buggy source:
private FgExample getExForFts(String state1,String state2,FeatureTemplateList fts){
  Var v1=new Var(VarType.PREDICTED,2,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str"));
  Var v2=new Var(VarType.PREDICTED,3,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str","String_Node_Str"));
  FactorGraph fg=new FactorGraph();
  fg.addFactor(new ExpFamFactor(new VarSet(v1,v2),"String_Node_Str"));
  VarConfig vc=new VarConfig();
  vc.put(v1,state1);
  vc.put(v2,state2);
  return new FgExample(fg,vc,new MockFeatureExtractor(),fts);
}

Fixed version (ground truth):
private FgExample getExForFts(String state1,String state2,FeatureTemplateList fts,boolean useLat){
  Var v1=new Var(VarType.PREDICTED,2,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str"));
  Var v2=new Var(useLat ? VarType.LATENT : VarType.PREDICTED,3,"String_Node_Str",Utilities.getList("String_Node_Str","String_Node_Str","String_Node_Str"));
  FactorGraph fg=new FactorGraph();
  fg.addFactor(new ExpFamFactor(new VarSet(v1,v2),"String_Node_Str"));
  VarConfig vc=new VarConfig();
  vc.put(v1,state1);
  vc.put(v2,state2);
  return new FgExample(fg,vc,new MockFeatureExtractor(),fts);
}