nus-yam/ex-repair huggingface dataset:
Program: 131551
Project: 131551
Buggy source:
public FgModel train(FgModel model,FgExamples data){
  Function objective=new CrfObjective(model.getNumParams(),data,prm.infFactory);
  if (prm.regularizer != null) {
    prm.regularizer.setNumDimensions(model.getNumParams());
    objective=new AddFunctions(objective,prm.regularizer);
  }
  double[] initial=model.getParams();
  double[] params=prm.maximizer.maximize(objective,initial);
  model.setParams(params);
  return model;
}

Fixed version (ground truth):
public void train(FgModel model,FgExamples data){
  Function objective=new CrfObjective(model.getNumParams(),data,prm.infFactory);
  if (prm.regularizer != null) {
    prm.regularizer.setNumDimensions(model.getNumParams());
    objective=new AddFunctions(objective,prm.regularizer);
  }
  double[] initial=model.getParams();
  double[] params=prm.maximizer.maximize(objective,initial);
  model.setParams(params);
}
Program: 131552
Project: 131552
Buggy source:
private static FgModel train(FgModel model,FgExamples data){
  BeliefPropagationPrm bpPrm=new BeliefPropagationPrm();
  bpPrm.logDomain=true;
  bpPrm.schedule=BpScheduleType.TREE_LIKE;
  bpPrm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  bpPrm.normalizeMessages=false;
  CrfTrainerPrm prm=new CrfTrainerPrm();
  prm.infFactory=bpPrm;
  prm.regularizer=null;
  CrfTrainer trainer=new CrfTrainer(prm);
  return trainer.train(model,data);
}

Fixed version (ground truth):
private static FgModel train(FgModel model,FgExamples data){
  BeliefPropagationPrm bpPrm=new BeliefPropagationPrm();
  bpPrm.logDomain=true;
  bpPrm.schedule=BpScheduleType.TREE_LIKE;
  bpPrm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  bpPrm.normalizeMessages=false;
  CrfTrainerPrm prm=new CrfTrainerPrm();
  prm.infFactory=bpPrm;
  prm.regularizer=null;
  CrfTrainer trainer=new CrfTrainer(prm);
  trainer.train(model,data);
  return model;
}
Program: 131554
Project: 131554
Buggy source:
public Alphabet<Feature> preprocess(List<CoNLL09Sentence> sents){
  Alphabet<String> obsAlphabet=new Alphabet<String>();
  List<FeatureExtractor> featExts=new ArrayList<FeatureExtractor>();
  for (int i=0; i < sents.size(); i++) {
    CoNLL09Sentence sent=sents.get(i);
    if (i % 1000 == 0 && i > 0) {
      log.debug("String_Node_Str" + i + "String_Node_Str");
    }
    SrlGraph srlGraph=sent.getSrlGraph();
    Set<Integer> knownPreds=getKnownPreds(srlGraph);
    SrlFactorGraph sfg=new SrlFactorGraph(prm.fgPrm,sent.size(),knownPreds,cs.roleStateNames);
    VarConfig trainConfig=getTrainAssignment(sent,srlGraph,sfg);
    FgExample ex=new FgExample(sfg,trainConfig);
    SentFeatureExtractor sentFeatExt=new SentFeatureExtractor(prm.fePrm,sent,cs,obsAlphabet);
    FeatureExtractor featExtractor=new SrlFeatureExtractor(prm.srlFePrm,sfg,alphabet,sentFeatExt);
    featExts.add(featExtractor);
    ex.cacheLatFeats(sfg,trainConfig,featExtractor);
  }
  Integer count;
  Alphabet<Feature> newAlphabet=new Alphabet<Feature>();
  for (  Feature o : alphabet.getObjects()) {
    count=alphabet.lookupIndexIncrement(o);
    if (count > prm.fePrm.min || o.isBiasFeature()) {
      newAlphabet.lookupIndexIncrement(o);
    }
  }
  newAlphabet.stopGrowth();
  return newAlphabet;
}

Fixed version (ground truth):
public void preprocess(List<CoNLL09Sentence> sents){
  if (!(alphabet.isGrowing() && prm.featCountCutoff > 0)) {
    return;
  }
  CountingAlphabet<Feature> counter=new CountingAlphabet<Feature>();
  Alphabet<String> obsAlphabet=new Alphabet<String>();
  List<FeatureExtractor> featExts=new ArrayList<FeatureExtractor>();
  for (int i=0; i < sents.size(); i++) {
    CoNLL09Sentence sent=sents.get(i);
    if (i % 1000 == 0 && i > 0) {
      log.debug("String_Node_Str" + i + "String_Node_Str");
    }
    SrlGraph srlGraph=sent.getSrlGraph();
    Set<Integer> knownPreds=getKnownPreds(srlGraph);
    SrlFactorGraph sfg=new SrlFactorGraph(prm.fgPrm,sent.size(),knownPreds,cs.roleStateNames);
    VarConfig trainConfig=getTrainAssignment(sent,srlGraph,sfg);
    FgExample ex=new FgExample(sfg,trainConfig);
    SentFeatureExtractor sentFeatExt=new SentFeatureExtractor(prm.fePrm,sent,cs,obsAlphabet);
    FeatureExtractor featExtractor=new SrlFeatureExtractor(prm.srlFePrm,sfg,counter,sentFeatExt);
    featExts.add(featExtractor);
    ex.cacheLatFeats(sfg,trainConfig,featExtractor);
  }
  for (int i=0; i < counter.size(); i++) {
    int count=counter.lookupObjectCount(i);
    Feature feat=counter.lookupObject(i);
    if (count >= prm.featCountCutoff || feat.isBiasFeature()) {
      alphabet.lookupIndex(feat);
    }
  }
  alphabet.stopGrowth();
}
Program: 131556
Project: 131556
Buggy source:
@Test public void testPreprocess() throws Exception {
  Alphabet<Feature> alphabet=new Alphabet<Feature>();
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(1);
  CorpusStatistics.normalizeRoleNames(sents);
  CorpusStatisticsPrm csPrm=new CorpusStatisticsPrm();
  CorpusStatistics cs=new CorpusStatistics(csPrm);
  cs.init(sents);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fePrm=fePrm;
  prm.fgPrm.roleStructure=RoleStructure.PREDS_GIVEN;
  prm.fgPrm.alwaysIncludeLinkVars=true;
  SrlFgExamplesBuilder processer=new SrlFgExamplesBuilder(prm,alphabet,cs);
  Alphabet<Feature> processedAlphabet=processer.preprocess(sents);
  SrlFgExamplesBuilder builder=new SrlFgExamplesBuilder(prm,processedAlphabet,cs);
  builder.getData(sents);
  assertTrue(processedAlphabet.size() < alphabet.size());
  assertEquals(4,prm.fePrm.min);
}

Fixed version (ground truth):
@Test public void testPreprocess() throws Exception {
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(1);
  CorpusStatistics.normalizeRoleNames(sents);
  CorpusStatisticsPrm csPrm=new CorpusStatisticsPrm();
  CorpusStatistics cs=new CorpusStatistics(csPrm);
  cs.init(sents);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fePrm.useZhaoFeats=false;
  prm.fePrm.useSimpleFeats=false;
  prm.fePrm=fePrm;
  prm.fgPrm.roleStructure=RoleStructure.PREDS_GIVEN;
  prm.fgPrm.alwaysIncludeLinkVars=true;
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    prm.featCountCutoff=0;
    SrlFgExamplesBuilder builder=new SrlFgExamplesBuilder(prm,alphabet,cs);
    builder.getData(sents);
    assertEquals(24223,alphabet.size());
  }
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    prm.featCountCutoff=4;
    SrlFgExamplesBuilder builder=new SrlFgExamplesBuilder(prm,alphabet,cs);
    builder.getData(sents);
    assertEquals(5883,alphabet.size());
  }
{
    Alphabet<Feature> alphabet=new Alphabet<Feature>();
    prm.featCountCutoff=5;
    SrlFgExamplesBuilder builder=new SrlFgExamplesBuilder(prm,alphabet,cs);
    builder.getData(sents);
    assertEquals(4929,alphabet.size());
  }
}
Program: 131557
Project: 131557
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.fePrm.biasOnly=biasOnly;
  prm.fePrm.useSimpleFeats=useSimpleFeats;
  prm.fePrm.useNaradFeats=useNaradFeats;
  prm.fePrm.useZhaoFeats=useZhaoFeats;
  prm.fePrm.min=min;
  prm.srlFePrm.featureHashMod=featureHashMod;
  prm.includeUnsupportedFeatures=includeUnsupportedFeatures;
  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.fePrm.biasOnly=biasOnly;
  prm.fePrm.useSimpleFeats=useSimpleFeats;
  prm.fePrm.useNaradFeats=useNaradFeats;
  prm.fePrm.useZhaoFeats=useZhaoFeats;
  prm.featCountCutoff=featCountCutoff;
  prm.srlFePrm.featureHashMod=featureHashMod;
  prm.includeUnsupportedFeatures=includeUnsupportedFeatures;
  return prm;
}
Program: 131558
Project: 131558
Buggy source:
public Alphabet(Alphabet<T> other){
  isGrowing=true;
  idxObjMap=new ArrayList<T>(other.idxObjMap);
  objIdxMap=new HashMap<T,Integer>(other.objIdxMap);
  objIdxCountMap=new HashMap<T,MutableInt>(other.objIdxCountMap);
}

Fixed version (ground truth):
public Alphabet(Alphabet<T> other){
  isGrowing=true;
  idxObjMap=new ArrayList<T>(other.idxObjMap);
  objIdxMap=new HashMap<T,Integer>(other.objIdxMap);
}
Program: 131560
Project: 131560
Buggy source:
private void getThirdThirdSupArgFeats(ZhaoObject zhaoPred,ZhaoObject zhaoArg,ZhaoObject zhaoPredLast,ZhaoObject zhaoPredNext,ZhaoObject zhaoArgLast,ZhaoObject zhaoArgNext,ZhaoObject zhaoArgParent,ArrayList<CoNLL09Token> argChildrenTokens,BinaryStrFVBuilder feats){
  String feat;
  feats.add(sent.get(zhaoArg.getLowSupport()).getLemma());
  feats.add(zhaoArg.getLemma() + "String_Node_Str" + zhaoArgParent.getForm());
  feats.add(zhaoArg.getLemma() + "String_Node_Str" + sent.get(zhaoArg.getPhead()).getForm());
  feats.add(zhaoArgNext.getLemma());
  ArrayList<String> argChildrenDeprel=new ArrayList<String>();
  for (  CoNLL09Token child : argChildrenTokens) {
    argChildrenDeprel.add(child.getDeprel());
  }
  List<String> argChildrenDeprelBag=bag(argChildrenDeprel);
  feat=zhaoArg.getPos() + StringUtils.join(argChildrenDeprelBag,"String_Node_Str");
  feats.add(feat);
}

Fixed version (ground truth):
private void getThirdThirdSupArgFeats(ZhaoObject zhaoPred,ZhaoObject zhaoArg,ZhaoObject zhaoPredLast,ZhaoObject zhaoPredNext,ZhaoObject zhaoArgLast,ZhaoObject zhaoArgNext,ZhaoObject zhaoArgParent,ArrayList<CoNLL09Token> argChildrenTokens,BinaryStrFVBuilder feats){
  String feat;
  if (zhaoArg.getLowSupport() < 0) {
    feats.add("String_Node_Str");
  }
 else {
    feats.add(sent.get(zhaoArg.getLowSupport()).getLemma());
  }
  feats.add(zhaoArg.getLemma() + "String_Node_Str" + zhaoArgParent.getForm());
  feats.add(zhaoArg.getLemma() + "String_Node_Str" + sent.get(zhaoArg.getPhead()).getForm());
  feats.add(zhaoArgNext.getLemma());
  ArrayList<String> argChildrenDeprel=new ArrayList<String>();
  for (  CoNLL09Token child : argChildrenTokens) {
    argChildrenDeprel.add(child.getDeprel());
  }
  List<String> argChildrenDeprelBag=bag(argChildrenDeprel);
  feat=zhaoArg.getPos() + StringUtils.join(argChildrenDeprelBag,"String_Node_Str");
  feats.add(feat);
}
Program: 131561
Project: 131561
Buggy source:
private void addZhaoSupervisedPredFeats(ZhaoObject zhaoPred,ZhaoObject zhaoArg,ZhaoObject zhaoPredLast,ZhaoObject zhaoPredNext,BinaryStrFVBuilder feats){
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoPred.getLemma());
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoPred.getPos());
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoArg.getPos());
  if (zhaoPredLast.getFeat() == null) {
    feats.add(zhaoPredLast.getForm());
  }
 else {
    feats.add(zhaoPredLast.getFeat().get(0));
  }
  feats.add(zhaoPred.getFeat().get(1));
  if (zhaoPredNext.getFeat() == null) {
    feats.add(zhaoPredNext.getForm());
  }
 else {
    feats.add(zhaoPredNext.getFeat().get(2));
  }
  feats.add(sent.get(zhaoPred.getFarRightChild()).getDeprel());
  feats.add(sent.get(zhaoPred.getFarLeftChild()).getDeprel());
  ArrayList<String> depPredChildren=new ArrayList<String>();
  for (  Integer child : zhaoPred.getChildren()) {
    depPredChildren.add(sent.get(child).getDeprel());
  }
  String bagDepPredChildren=StringUtils.join(bag(depPredChildren),"String_Node_Str");
  feats.add(zhaoPred.getForm() + "String_Node_Str" + bagDepPredChildren);
  feats.add(zhaoPredLast.getLemma());
  feats.add(zhaoPred.getLemma());
  feats.add(zhaoPred.getLemma() + "String_Node_Str" + zhaoPredNext.getLemma());
  feats.add(zhaoPred.getPos() + "String_Node_Str" + bagDepPredChildren);
}

Fixed version (ground truth):
private void addZhaoSupervisedPredFeats(ZhaoObject zhaoPred,ZhaoObject zhaoArg,ZhaoObject zhaoPredLast,ZhaoObject zhaoPredNext,BinaryStrFVBuilder feats){
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoPred.getLemma());
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoPred.getPos());
  feats.add(zhaoPred.getPred() + "String_Node_Str" + zhaoArg.getPos());
  if (zhaoPredLast.getFeat() == null) {
    feats.add(zhaoPredLast.getForm());
  }
 else {
    feats.add(zhaoPredLast.getFeat().get(0));
  }
  feats.add(zhaoPred.getFeat().get(1));
  if (zhaoPredNext.getFeat() == null) {
    feats.add(zhaoPredNext.getForm());
  }
 else {
    feats.add(zhaoPredNext.getFeat().get(2));
  }
  if (zhaoPred.getFarRightChild() < 0) {
    feats.add("String_Node_Str");
  }
 else {
    feats.add(sent.get(zhaoPred.getFarRightChild()).getDeprel());
  }
  if (zhaoPred.getFarLeftChild() < 0) {
    feats.add("String_Node_Str");
  }
 else {
    feats.add(sent.get(zhaoPred.getFarLeftChild()).getDeprel());
  }
  ArrayList<String> depPredChildren=new ArrayList<String>();
  for (  Integer child : zhaoPred.getChildren()) {
    depPredChildren.add(sent.get(child).getDeprel());
  }
  String bagDepPredChildren=StringUtils.join(bag(depPredChildren),"String_Node_Str");
  feats.add(zhaoPred.getForm() + "String_Node_Str" + bagDepPredChildren);
  feats.add(zhaoPredLast.getLemma());
  feats.add(zhaoPred.getLemma());
  feats.add(zhaoPred.getLemma() + "String_Node_Str" + zhaoPredNext.getLemma());
  feats.add(zhaoPred.getPos() + "String_Node_Str" + bagDepPredChildren);
}
Program: 131562
Project: 131562
Buggy source:
public ZhaoObject(String input){
  super(-1,input,input,input,input,input,null,null,-2,-2,input,input,false,input,null);
  setFeat(-1);
}

Fixed version (ground truth):
public ZhaoObject(String input){
  super(-1,input,input,input,input,input,null,null,-2,-2,input,input,false,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.lowSupport=-1;
  this.highSupport=-1;
  this.noFarChildren=new ArrayList<Integer>();
  setNoFarChildren();
}
Program: 131566
Project: 131566
Buggy source:
@Test public void testAddNaradowskyFeatures(){
  CoNLL09Sentence sent=getSpanishConll09Sentence();
  Alphabet<String> alphabet=new Alphabet<String>();
  SentFeatureExtractorPrm prm=new SentFeatureExtractorPrm();
  prm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(prm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractor fe=new SentFeatureExtractor(prm,sent,cs,alphabet);
  BinaryStrFVBuilder feats;
  BinaryStrFVBuilder allFeats=new BinaryStrFVBuilder(alphabet);
  for (int i=0; i < sent.size(); i++) {
    for (int j=0; j < sent.size(); j++) {
      fe.addNaradowskyPairFeatures(i,j,allFeats);
    }
  }
  for (  String f : allFeats) {
    System.out.println(f);
  }
}

Fixed version (ground truth):
@Test public void testAddNaradowskyFeatures(){
  CoNLL09Sentence sent=getSpanishConll09Sentence1();
  Alphabet<String> alphabet=new Alphabet<String>();
  SentFeatureExtractorPrm prm=new SentFeatureExtractorPrm();
  prm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(prm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractor fe=new SentFeatureExtractor(prm,sent,cs,alphabet);
  BinaryStrFVBuilder allFeats=new BinaryStrFVBuilder(alphabet);
  for (int i=0; i < sent.size(); i++) {
    for (int j=0; j < sent.size(); j++) {
      fe.addNaradowskyPairFeatures(i,j,allFeats);
    }
  }
  for (  String f : allFeats) {
    System.out.println(f);
  }
}
Program: 131567
Project: 131567
Buggy source:
@Test public void testAddZhaoFeatures(){
  CoNLL09Sentence sent=getSpanishConll09Sentence();
  Alphabet<String> alphabet=new Alphabet<String>();
  SentFeatureExtractorPrm prm=new SentFeatureExtractorPrm();
  prm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(prm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractor fe=new SentFeatureExtractor(prm,sent,cs,alphabet);
  BinaryStrFVBuilder feats;
  BinaryStrFVBuilder allFeats=new BinaryStrFVBuilder(alphabet);
  for (int i=0; i < sent.size(); i++) {
    for (int j=0; j < sent.size(); j++) {
      fe.addZhaoPairFeatures(i,j,allFeats);
    }
  }
  for (  String f : allFeats) {
    System.out.println(f);
  }
}

Fixed version (ground truth):
@Test public void testAddZhaoFeatures(){
  CoNLL09Sentence sent=getSpanishConll09Sentence1();
  Alphabet<String> alphabet=new Alphabet<String>();
  SentFeatureExtractorPrm prm=new SentFeatureExtractorPrm();
  prm.useGoldSyntax=true;
  CorpusStatistics cs=new CorpusStatistics(prm);
  cs.init(Utilities.getList(sent));
  SentFeatureExtractor fe=new SentFeatureExtractor(prm,sent,cs,alphabet);
  BinaryStrFVBuilder feats;
  BinaryStrFVBuilder allFeats=new BinaryStrFVBuilder(alphabet);
  for (int i=0; i < sent.size(); i++) {
    for (int j=0; j < sent.size(); j++) {
      fe.addZhaoPairFeatures(i,j,allFeats);
    }
  }
  for (  String f : allFeats) {
    System.out.println(f);
  }
}
Program: 131568
Project: 131568
Buggy source:
private void setDpPathShare(int pidx,int aidx,ZhaoObject zhaoPred,ZhaoObject zhaoArg){
  List<Pair<Integer,Dir>> argRootPath=zhaoArg.getRootPath();
  List<Pair<Integer,Dir>> predRootPath=zhaoPred.getRootPath();
  int i=argRootPath.size() - 1;
  int j=predRootPath.size() - 1;
  Pair<Integer,DepTree.Dir> argP=argRootPath.get(i);
  Pair<Integer,DepTree.Dir> predP=predRootPath.get(j);
  while (argP.equals(predP) && i > -1 && j > -1) {
    this.dpPathShare.add(argP);
    argP=argRootPath.get(i);
    predP=predRootPath.get(j);
    i--;
    j--;
  }
  Collections.reverse(this.dpPathShare);
  int r=this.dpPathShare.get(0).get1();
  this.dpPathPred=DepTree.getDependencyPath(pidx,r,parents);
  this.dpPathArg=DepTree.getDependencyPath(aidx,r,parents);
}

Fixed version (ground truth):
private void setDpPathShare(int pidx,int aidx,ZhaoObject zhaoPred,ZhaoObject zhaoArg){
  List<Pair<Integer,Dir>> argRootPath=zhaoArg.getRootPath();
  List<Pair<Integer,Dir>> predRootPath=zhaoPred.getRootPath();
  int i=argRootPath.size() - 1;
  int j=predRootPath.size() - 1;
  Pair<Integer,DepTree.Dir> argP=argRootPath.get(i);
  Pair<Integer,DepTree.Dir> predP=predRootPath.get(j);
  while (argP.equals(predP) && i > -1 && j > -1) {
    this.dpPathShare.add(argP);
    argP=argRootPath.get(i);
    predP=predRootPath.get(j);
    i--;
    j--;
  }
  Collections.reverse(this.dpPathShare);
  int r;
  if (this.dpPathShare.isEmpty()) {
    r=-1;
    this.dpPathPred=new ArrayList<Pair<Integer,Dir>>();
    this.dpPathArg=new ArrayList<Pair<Integer,Dir>>();
  }
 else {
    r=this.dpPathShare.get(0).get1();
    this.dpPathPred=DepTree.getDependencyPath(pidx,r,parents);
    this.dpPathArg=DepTree.getDependencyPath(aidx,r,parents);
  }
}
Program: 131569
Project: 131569
Buggy source:
@Test public void testSetSrlGraph(){
  CoNLL09Sentence sent1=getSent();
  CoNLL09Sentence sent2=getEmptySent();
  assertFalse(sent1.equals(sent2));
  SrlGraph srlGraph=sent1.getSrlGraph();
  sent2.setColsFromSrlGraph(srlGraph);
  assertEquals(sent1,sent2);
}

Fixed version (ground truth):
@Test public void testSetSrlGraph(){
  CoNLL09Sentence sent1=getSent();
  CoNLL09Sentence sent2=getEmptySent();
  assertFalse(sent1.equals(sent2));
  SrlGraph srlGraph=sent1.getSrlGraph();
  sent2.setPredApredFromSrlGraph(srlGraph,true);
  assertEquals(sent1,sent2);
}
Program: 131570
Project: 131570
Buggy source:
public String normalizeRoleName(String input){
  String[] splitRole=dash.split(input);
  String role=splitRole[0].toLowerCase();
  return role;
}

Fixed version (ground truth):
public String normalizeRoleName(String role){
  if (prm.normalizeRoleNames) {
    String[] splitRole=dash.split(role);
    role=splitRole[0].toLowerCase();
  }
  return role;
}
Program: 131571
Project: 131571
Buggy source:
public CorpusStatistics(SentFeatureExtractorPrm prm){
  this.prm=prm;
  this.normalize=new Normalizer(prm.normalize);
}

Fixed version (ground truth):
public CorpusStatistics(SentFeatureExtractorPrm prm){
  this.prm=prm;
  this.normalize=new Normalizer(prm.normalizeWords);
}
Program: 131572
Project: 131572
Buggy source:
@Test public void testCreation() throws IOException {
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(2);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  fePrm.biasOnly=true;
  CorpusStatistics cs=new CorpusStatistics(fePrm);
  cs.init(sents);
  System.out.println(expectedCsToString);
  System.out.println();
  System.out.println(cs);
  assertEquals(expectedCsToString,cs.toString());
}

Fixed version (ground truth):
@Test public void testCreation() throws IOException {
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(2);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  fePrm.biasOnly=true;
  fePrm.normalizeRoleNames=true;
  CorpusStatistics cs=new CorpusStatistics(fePrm);
  cs.init(sents);
  System.out.println(expectedCsToString);
  System.out.println();
  System.out.println(cs);
  assertEquals(expectedCsToString,cs.toString());
}
Program: 131573
Project: 131573
Buggy source:
@Test public void testRoleTrainAssignment() throws Exception {
  Alphabet<Feature> alphabet=new Alphabet<Feature>();
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(1);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  fePrm.biasOnly=true;
  CorpusStatistics cs=new CorpusStatistics(fePrm);
  cs.init(sents);
  CoNLL09Sentence sent=sents.get(0);
  Alphabet<String> obsAlphabet=new Alphabet<String>();
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fePrm=fePrm;
  prm.fgPrm.roleStructure=RoleStructure.PREDS_GIVEN;
  SrlFgExampleBuilder builder=new SrlFgExampleBuilder(prm,alphabet,cs,obsAlphabet);
  FgExample ex=builder.getFGExample(sent);
  assertEquals(1,obsAlphabet.size());
  assertEquals(5 * 2 + 2 + 5,alphabet.size());
  VarConfig vc=ex.getGoldConfig();
  System.out.println(vc.toString().replace("String_Node_Str","String_Node_Str"));
  for (  Var v : vc.getVars()) {
    RoleVar role=(RoleVar)v;
    if (role.getParent() == 2 && role.getChild() == 0) {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
 else     if (role.getParent() == 2 && role.getChild() == 4) {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
 else {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
  }
  assertEquals(18,vc.size());
}

Fixed version (ground truth):
@Test public void testRoleTrainAssignment() throws Exception {
  Alphabet<Feature> alphabet=new Alphabet<Feature>();
  InputStream inputStream=this.getClass().getResourceAsStream(CoNLL09ReadWriteTest.conll2009Example);
  CoNLL09FileReader cr=new CoNLL09FileReader(inputStream);
  List<CoNLL09Sentence> sents=cr.readSents(1);
  SentFeatureExtractorPrm fePrm=new SentFeatureExtractorPrm();
  fePrm.biasOnly=true;
  fePrm.normalizeRoleNames=true;
  CorpusStatistics cs=new CorpusStatistics(fePrm);
  cs.init(sents);
  CoNLL09Sentence sent=sents.get(0);
  Alphabet<String> obsAlphabet=new Alphabet<String>();
  SrlFgExampleBuilderPrm prm=new SrlFgExampleBuilderPrm();
  prm.fePrm=fePrm;
  prm.fgPrm.roleStructure=RoleStructure.PREDS_GIVEN;
  SrlFgExampleBuilder builder=new SrlFgExampleBuilder(prm,alphabet,cs,obsAlphabet);
  FgExample ex=builder.getFGExample(sent);
  assertEquals(1,obsAlphabet.size());
  assertEquals(5 * 2 + 2 + 5,alphabet.size());
  VarConfig vc=ex.getGoldConfig();
  System.out.println(vc.toString().replace("String_Node_Str","String_Node_Str"));
  for (  Var v : vc.getVars()) {
    RoleVar role=(RoleVar)v;
    if (role.getParent() == 2 && role.getChild() == 0) {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
 else     if (role.getParent() == 2 && role.getChild() == 4) {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
 else {
      assertEquals("String_Node_Str",vc.getStateName(v));
    }
  }
  assertEquals(18,vc.size());
}
Program: 131574
Project: 131574
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.fePrm.cutoff=cutoff;
  prm.fePrm.language=language;
  prm.fePrm.useGoldPos=useGoldPos;
  prm.fePrm.biasOnly=biasOnly;
  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.fePrm.cutoff=cutoff;
  prm.fePrm.biasOnly=biasOnly;
  prm.fePrm.language=language;
  prm.fePrm.useGoldPos=useGoldPos;
  prm.fePrm.normalizeWords=normalizeWords;
  prm.fePrm.normalizeRoleNames=normalizeRoleNames;
  return prm;
}
Program: 131575
Project: 131575
Buggy source:
private List<VarConfig> decode(FgModel model,FgExamples data,DatasetType dataType,File predOut,String name) throws IOException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  MbrDecoder decoder=getDecoder();
  decoder.decode(model,data);
  List<VarConfig> predictions=decoder.getMbrVarConfigList();
  if (predOut != null) {
    log.info("String_Node_Str" + name + "String_Node_Str"+ dataType+ "String_Node_Str"+ predOut);
    if (dataType == DatasetType.CONLL_2009) {
      @SuppressWarnings("String_Node_Str") List<CoNLL09Sentence> sents=(List<CoNLL09Sentence>)data.getSourceSentences();
      for (int i=0; i < sents.size(); i++) {
        VarConfig vc=predictions.get(i);
        CoNLL09Sentence sent=sents.get(i);
        SrlGraph srlGraph=new SrlGraph(sent.size());
        for (        Var v : vc.getVars()) {
          if (v instanceof RoleVar && v.getType() != VarType.LATENT) {
            RoleVar role=(RoleVar)v;
            SrlPred pred=srlGraph.getPredAt(role.getParent());
            if (pred == null) {
              String sense="String_Node_Str";
              pred=new SrlPred(role.getParent(),sense);
            }
            SrlArg arg=srlGraph.getArgAt(role.getChild());
            if (arg == null) {
              arg=new SrlArg(role.getChild());
            }
            SrlEdge edge=new SrlEdge(pred,arg,vc.getStateName(role));
            srlGraph.addEdge(edge);
          }
        }
        sent.setColsFromSrlGraph(srlGraph);
      }
      CoNLL09Writer cw=new CoNLL09Writer(predOut);
      for (      CoNLL09Sentence sent : sents) {
        cw.write(sent);
      }
      cw.close();
    }
 else {
      ErmaWriter ew=new ErmaWriter();
      ew.writePredictions(predOut,predictions,decoder.getVarMargMap());
    }
  }
  return predictions;
}

Fixed version (ground truth):
private List<VarConfig> decode(FgModel model,FgExamples data,DatasetType dataType,File predOut,String name) throws IOException {
  log.info("String_Node_Str" + name + "String_Node_Str");
  MbrDecoder decoder=getDecoder();
  decoder.decode(model,data);
  List<VarConfig> predictions=decoder.getMbrVarConfigList();
  if (predOut != null) {
    log.info("String_Node_Str" + name + "String_Node_Str"+ dataType+ "String_Node_Str"+ predOut);
    if (dataType == DatasetType.CONLL_2009) {
      @SuppressWarnings("String_Node_Str") List<CoNLL09Sentence> sents=(List<CoNLL09Sentence>)data.getSourceSentences();
      for (int i=0; i < sents.size(); i++) {
        VarConfig vc=predictions.get(i);
        CoNLL09Sentence sent=sents.get(i);
        SrlGraph srlGraph=SrlDecoder.getSrlGraphFromVarConfig(vc,sent);
        sent.setPredApredFromSrlGraph(srlGraph,false);
      }
      CoNLL09Writer cw=new CoNLL09Writer(predOut);
      for (      CoNLL09Sentence sent : sents) {
        cw.write(sent);
      }
      cw.close();
    }
 else {
      ErmaWriter ew=new ErmaWriter();
      ew.writePredictions(predOut,predictions,decoder.getVarMargMap());
    }
  }
  return predictions;
}
Program: 131576
Project: 131576
Buggy source:
/** 
 * Sends the message that is currently "pending" for this edge. This just copies the message in the "pending slot" to the "message slot" for this edge.
 * @param edge The edge over which the message should be sent.
 */
private void sendMessage(FgEdge edge){
  int edgeId=edge.getId();
  Messages ec=msgs[edgeId];
  DenseFactor oldMessage=ec.message;
  ec.message=ec.newMessage;
  ec.newMessage=oldMessage;
}

Fixed version (ground truth):
/** 
 * Sends the message that is currently "pending" for this edge. This just copies the message in the "pending slot" to the "message slot" for this edge.
 * @param edge The edge over which the message should be sent.
 */
private void sendMessage(FgEdge edge){
  int edgeId=edge.getId();
  Messages ec=msgs[edgeId];
  DenseFactor oldMessage=ec.message;
  ec.message=ec.newMessage;
  ec.newMessage=oldMessage;
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str" + ec.message);
  }
}
Program: 131577
Project: 131577
Buggy source:
/** 
 * Gets the partition function for the connected component containing the given node.
 */
private double getPartitionFunctionAtVarNode(FgNode node){
  if (!node.isVar()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Var var=node.getVar();
  DenseFactor prod=new DenseFactor(new VarSet(var),prm.logDomain ? 0.0 : 1.0);
  getProductOfMessages(node,prod,null);
  if (prm.logDomain) {
    return prod.getLogSum();
  }
 else {
    return prod.getSum();
  }
}

Fixed version (ground truth):
/** 
 * Gets the partition function for the connected component containing the given node. Package private FOR TESTING ONLY.
 */
double getPartitionFunctionAtVarNode(FgNode node){
  if (!node.isVar()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Var var=node.getVar();
  DenseFactor prod=new DenseFactor(new VarSet(var),prm.logDomain ? 0.0 : 1.0);
  getProductOfMessages(node,prod,null);
  if (prm.logDomain) {
    return prod.getLogSum();
  }
 else {
    return prod.getSum();
  }
}
Program: 131578
Project: 131578
Buggy source:
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(fg.getEdge(i),prm);
  }
  for (int iter=0; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : fg.getEdges()) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : fg.getEdges()) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
  }
  timer.stop();
}

Fixed version (ground truth):
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(fg.getEdge(i),prm);
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  for (int iter=0; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : fg.getEdges()) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : fg.getEdges()) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
  }
  timer.stop();
}
Program: 131579
Project: 131579
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: 131580
Project: 131580
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: 131582
Project: 131582
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: 131584
Project: 131584
Buggy source:
private FgExamples getData(Alphabet<Feature> alphabet,DatasetType dataType,File dataFile,String name) throws ParseException, IOException {
  FgExamples data;
  if (dataType != DatasetType.ERMA) {
    ErmaReader er=new ErmaReader(true);
    data=er.read(featureFileIn,dataFile,alphabet);
  }
 else {
    throw new ParseException("String_Node_Str" + dataType);
  }
  log.info(String.format("String_Node_Str",name,data.size()));
  log.info(String.format("String_Node_Str",name,data.getNumFactors()));
  log.info(String.format("String_Node_Str",name,data.getNumVars()));
  log.info(String.format("String_Node_Str",data.getAlphabet().size()));
  return data;
}

Fixed version (ground truth):
private FgExamples getData(Alphabet<Feature> alphabet,DatasetType dataType,File dataFile,String name) throws ParseException, IOException {
  FgExamples data;
  if (dataType == DatasetType.ERMA) {
    ErmaReader er=new ErmaReader(true);
    data=er.read(featureFileIn,dataFile,alphabet);
  }
 else {
    throw new ParseException("String_Node_Str" + dataType);
  }
  log.info(String.format("String_Node_Str",name,data.size()));
  log.info(String.format("String_Node_Str",name,data.getNumFactors()));
  log.info(String.format("String_Node_Str",name,data.getNumVars()));
  log.info(String.format("String_Node_Str",data.getAlphabet().size()));
  return data;
}
Program: 131585
Project: 131585
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();
  DenseFactor msg=msgs[edgeId].newMessage;
  msg.set(prm.logDomain ? 0.0 : 1.0);
  if (edge.isVarToFactor()) {
    getProductOfMessages(edge.getParent(),msg,edge.getChild());
  }
 else {
    if (factor instanceof GlobalFactor) {
      GlobalFactor globalFac=(GlobalFactor)factor;
      globalFac.createMessages(edge.getParent(),msgs,prm.logDomain,iter);
    }
 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) {
    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: 131586
Project: 131586
Buggy source:
/** 
 * Gets the product of all the factors in the factor graph. If working in the log-domain, this will do factor addition.
 * @param logDomain Whether to work in the log-domain.
 * @return The product of all the factors.
 */
private static DenseFactor getProductOfAllFactors(FactorGraph fg,boolean logDomain){
  DenseFactor joint=new DenseFactor(new VarSet(),logDomain ? 0.0 : 1.0);
  for (int a=0; a < fg.getNumFactors(); a++) {
    if (fg.getFactor(a) instanceof GlobalFactor) {
      throw new RuntimeException("String_Node_Str");
    }
    DenseFactor factor=(DenseFactor)fg.getFactor(a);
    if (logDomain) {
      joint.add(factor);
    }
 else {
      joint.prod(factor);
    }
  }
  return joint;
}

Fixed version (ground truth):
/** 
 * Gets the product of all the factors in the factor graph. If working in the log-domain, this will do factor addition.
 * @param logDomain Whether to work in the log-domain.
 * @return The product of all the factors.
 */
private static DenseFactor getProductOfAllFactors(FactorGraph fg,boolean logDomain){
  DenseFactor joint=new DenseFactor(new VarSet(),logDomain ? 0.0 : 1.0);
  for (int a=0; a < fg.getNumFactors(); a++) {
    if (fg.getFactor(a) instanceof DenseFactor) {
      DenseFactor factor=(DenseFactor)fg.getFactor(a);
      if (logDomain) {
        joint.add(factor);
      }
 else {
        joint.prod(factor);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
  return joint;
}
Program: 131587
Project: 131587
Buggy source:
/** 
 * Constructor.
 * @param n The length of the sentence.
 */
public ProjDepTreeFactor(int n,VarType type){
  this.vars=createVarSet(n,type);
  this.n=n;
  LinkVar[] rootVars=new LinkVar[n];
  LinkVar[][] 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){
  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: 131589
Project: 131589
Buggy source:
/** 
 * Sends the message that is currently "pending" for this edge. This just copies the message in the "pending slot" to the "message slot" for this edge.
 * @param edge The edge over which the message should be sent.
 */
private void sendMessage(FgEdge edge){
  int edgeId=edge.getId();
  Messages ec=msgs[edgeId];
  DenseFactor oldMessage=ec.message;
  ec.message=ec.newMessage;
  ec.newMessage=oldMessage;
}

Fixed version (ground truth):
/** 
 * Sends the message that is currently "pending" for this edge. This just copies the message in the "pending slot" to the "message slot" for this edge.
 * @param edge The edge over which the message should be sent.
 */
private void sendMessage(FgEdge edge){
  int edgeId=edge.getId();
  Messages ec=msgs[edgeId];
  DenseFactor oldMessage=ec.message;
  ec.message=ec.newMessage;
  ec.newMessage=oldMessage;
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str" + ec.message);
  }
}
Program: 131590
Project: 131590
Buggy source:
/** 
 * Gets the partition function for the connected component containing the given node.
 */
private double getPartitionFunctionAtVarNode(FgNode node){
  if (!node.isVar()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Var var=node.getVar();
  DenseFactor prod=new DenseFactor(new VarSet(var),prm.logDomain ? 0.0 : 1.0);
  getProductOfMessages(node,prod,null);
  if (prm.logDomain) {
    return prod.getLogSum();
  }
 else {
    return prod.getSum();
  }
}

Fixed version (ground truth):
/** 
 * Gets the partition function for the connected component containing the given node. Package private FOR TESTING ONLY.
 */
double getPartitionFunctionAtVarNode(FgNode node){
  if (!node.isVar()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Var var=node.getVar();
  DenseFactor prod=new DenseFactor(new VarSet(var),prm.logDomain ? 0.0 : 1.0);
  getProductOfMessages(node,prod,null);
  if (prm.logDomain) {
    return prod.getLogSum();
  }
 else {
    return prod.getSum();
  }
}
Program: 131591
Project: 131591
Buggy source:
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(fg.getEdge(i),prm);
  }
  for (int iter=0; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : fg.getEdges()) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : fg.getEdges()) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
  }
  timer.stop();
}

Fixed version (ground truth):
/** 
 * @inheritDoc 
 */
@Override public void run(){
  Timer timer=new Timer();
  timer.start();
  for (int i=0; i < msgs.length; i++) {
    msgs[i]=new Messages(fg.getEdge(i),prm);
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  for (int iter=0; iter < prm.maxIterations; iter++) {
    if (timer.totSec() > prm.timeoutSeconds) {
      break;
    }
    if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
      for (      FgEdge edge : order) {
        createMessage(edge,iter);
        sendMessage(edge);
      }
    }
 else     if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
      for (      FgEdge edge : fg.getEdges()) {
        createMessage(edge,iter);
      }
      for (      FgEdge edge : fg.getEdges()) {
        sendMessage(edge);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str" + prm.updateOrder);
    }
  }
  timer.stop();
}