nus-yam/ex-repair huggingface dataset:
Program: 131204
Project: 131204
Buggy source:
@Test public void testReadSimple() throws IOException {
  FactorGraph fg=readSimpleFg();
  assertEquals(2,fg.getNumFactors());
  assertEquals(3,fg.getNumVars());
}

Fixed version (ground truth):
@Test public void testReadSimple() throws IOException {
  FactorGraph fg=readSimpleFg();
  assertEquals(2,fg.getNumFactors());
  assertEquals(3,fg.getNumVars());
  System.out.println(fg);
  for (  Factor f : fg.getFactors()) {
    VarTensor vt=BruteForceInferencer.safeNewVarTensor(RealAlgebra.REAL_ALGEBRA,f);
    System.out.println(vt);
  }
  VarTensor vt0=BruteForceInferencer.safeNewVarTensor(RealAlgebra.REAL_ALGEBRA,fg.getFactors().get(0));
  VarTensor vt1=BruteForceInferencer.safeNewVarTensor(RealAlgebra.REAL_ALGEBRA,fg.getFactors().get(1));
  assertEquals("String_Node_Str",vt0.getVars().get(0).getName());
  assertEquals("String_Node_Str",vt0.getVars().get(1).getName());
  assertEquals("String_Node_Str",vt0.getVars().get(2).getName());
  VarConfig vc0=new VarConfig();
  vc0.put(vt0.getVars().get(0),"String_Node_Str");
  vc0.put(vt0.getVars().get(1),"String_Node_Str");
  vc0.put(vt0.getVars().get(2),"String_Node_Str");
  assertEquals(0.8,vt0.getValue(vc0.getConfigIndex()),1e-13);
  VarConfig vc1=new VarConfig();
  vc1.put(vt1.getVars().get(0),"String_Node_Str");
  vc1.put(vt1.getVars().get(1),"String_Node_Str");
  assertEquals(0.6,vt1.getValue(vc1.getConfigIndex()),1e-13);
}
Program: 131205
Project: 131205
Buggy source:
@Test public void testOnSimpleProb() throws IOException {
  Algebra s=RealAlgebra.REAL_ALGEBRA;
  FactorGraph fg=readSimpleFg();
  BruteForceInferencer bf=new BruteForceInferencer(fg,s);
  testInfOnSimpleGraph(fg,bf);
}

Fixed version (ground truth):
/** 
 * VarTensor [ A     B     C  |  value YY   Yes   Yes  |  0.800000 YY   Yes    No  |  0.200000 YY    No   Yes  |  0.500000 YY    No    No  |  0.500000 NN   Yes   Yes  |  0.600000 NN   Yes    No  |  0.400000 NN    No   Yes  |  0.100000 NN    No    No  |  0.900000 ] VarTensor [ A     B  |  value YY   Yes  |  0.600000 YY    No  |  0.400000 NN   Yes  |  0.150000 NN    No  |  0.850000 ] Current  joint:  VarTensor [ A     B     C  |  value YY   Yes   Yes  |  0.480000 YY   Yes    No  |  0.120000 YY    No   Yes  |  0.200000 YY    No    No  |  0.200000 NN   Yes   Yes  |  0.0900000 NN   Yes    No  |  0.0600000 NN    No   Yes  |  0.0850000 NN    No    No  |  0.765000 ]
 * @throws IOException
 */
@Test public void testOnSimpleProb() throws IOException {
  Algebra s=RealAlgebra.REAL_ALGEBRA;
  FactorGraph fg=readSimpleFg();
  BruteForceInferencer bf=new BruteForceInferencer(fg,s);
  bf.run();
  System.out.println("String_Node_Str" + bf.getJointFactor());
  testInfOnSimpleGraph(fg,bf);
}
Program: 131206
Project: 131206
Buggy source:
public static void testInfOnLinearChainGraph(FactorGraph fg,FgInferencer bp){
  bp.run();
  VarTensor marg;
  double[] goldMarg;
  marg=bp.getMarginals(fg.getVar(0));
  goldMarg=new double[]{0.079,0.920};
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-2);
  marg=bp.getLogMarginals(fg.getVar(0));
  goldMarg=DoubleArrays.getLog(goldMarg);
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-2);
  marg=bp.getMarginals(fg.getFactor(3));
  goldMarg=new double[]{0.013146806000337095,0.1774818810045508,0.06607112759143771,0.7433001854036744};
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-4);
  marg=bp.getLogMarginals(fg.getFactor(3));
  goldMarg=DoubleArrays.getLog(goldMarg);
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-4);
  double goldPartition=0.5932;
  assertEquals(goldPartition,bp.getPartition(),1e-2);
  assertEquals(FastMath.log(goldPartition),bp.getLogPartition(),1e-2);
}

Fixed version (ground truth):
public static void testInfOnLinearChainGraph(FactorGraph fg,FgInferencer bp){
  bp.run();
  VarTensor marg;
  double[] goldMarg;
  marg=bp.getMarginals(fg.getVar(0));
  goldMarg=new double[]{0.079,0.920};
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-2);
  marg=bp.getLogMarginals(fg.getVar(0));
  goldMarg=DoubleArrays.getLog(goldMarg);
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-2);
  marg=bp.getMarginals(fg.getFactor(3));
  goldMarg=new double[]{0.013146806000337095,0.06607112759143771,0.1774818810045508,0.7433001854036744};
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-4);
  marg=bp.getLogMarginals(fg.getFactor(3));
  goldMarg=DoubleArrays.getLog(goldMarg);
  JUnitUtils.assertArrayEquals(goldMarg,marg.getValues(),1e-4);
  double goldPartition=0.5932;
  assertEquals(goldPartition,bp.getPartition(),1e-2);
  assertEquals(FastMath.log(goldPartition),bp.getLogPartition(),1e-2);
}
Program: 131208
Project: 131208
Buggy source:
/** 
 * Gets a simple linear chain CRF consisting of 3 words and 3 tags. 
 */
public static FactorGraph getLinearChainGraph(){
  FactorGraph fg=new FactorGraph();
  Var t0=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  Var t1=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  Var t2=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  ExplicitFactor emit0=new ExplicitFactor(new VarSet(t0));
  ExplicitFactor emit1=new ExplicitFactor(new VarSet(t1));
  ExplicitFactor emit2=new ExplicitFactor(new VarSet(t2));
  emit0.setValue(0,0.1);
  emit0.setValue(1,0.9);
  emit1.setValue(0,0.3);
  emit1.setValue(1,0.7);
  emit2.setValue(0,0.5);
  emit2.setValue(1,0.5);
  ExplicitFactor tran0=new ExplicitFactor(new VarSet(t0,t1));
  ExplicitFactor tran1=new ExplicitFactor(new VarSet(t1,t2));
  tran0.fill(1);
  tran0.setValue(0,0.2);
  tran0.setValue(1,0.3);
  tran0.setValue(2,0.4);
  tran0.setValue(3,0.5);
  tran1.fill(1);
  tran1.setValue(0,1.2);
  tran1.setValue(1,1.3);
  tran1.setValue(2,1.4);
  tran1.setValue(3,1.5);
  fg.addFactor(emit0);
  fg.addFactor(emit1);
  fg.addFactor(emit2);
  fg.addFactor(tran0);
  fg.addFactor(tran1);
  for (  Factor f : fg.getFactors()) {
    ((ExplicitFactor)f).convertRealToLog();
  }
  return fg;
}

Fixed version (ground truth):
/** 
 * Gets a simple linear chain CRF consisting of 3 words and 3 tags. 
 */
public static FactorGraph getLinearChainGraph(){
  FactorGraph fg=new FactorGraph();
  Var t0=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  Var t1=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  Var t2=new Var(VarType.PREDICTED,2,"String_Node_Str",null);
  ExplicitFactor emit0=new ExplicitFactor(new VarSet(t0));
  ExplicitFactor emit1=new ExplicitFactor(new VarSet(t1));
  ExplicitFactor emit2=new ExplicitFactor(new VarSet(t2));
  emit0.setValue(0,0.1);
  emit0.setValue(1,0.9);
  emit1.setValue(0,0.3);
  emit1.setValue(1,0.7);
  emit2.setValue(0,0.5);
  emit2.setValue(1,0.5);
  ExplicitFactor tran0=new ExplicitFactor(new VarSet(t0,t1));
  ExplicitFactor tran1=new ExplicitFactor(new VarSet(t1,t2));
  tran0.fill(1);
  tran0.setValue(0,0.2);
  tran0.setValue(1,0.4);
  tran0.setValue(2,0.3);
  tran0.setValue(3,0.5);
  tran1.fill(1);
  tran1.setValue(0,1.2);
  tran1.setValue(1,1.4);
  tran1.setValue(2,1.3);
  tran1.setValue(3,1.5);
  fg.addFactor(emit0);
  fg.addFactor(emit1);
  fg.addFactor(emit2);
  fg.addFactor(tran0);
  fg.addFactor(tran1);
  for (  Factor f : fg.getFactors()) {
    ((ExplicitFactor)f).convertRealToLog();
  }
  return fg;
}
Program: 131210
Project: 131210
Buggy source:
@Test public void testGetState(){
  Var v0=getVar(0,2);
  Var v1=getVar(1,3);
  Var v2=getVar(2,5);
  VarSet vars1=new VarSet();
  vars1.add(v0);
  vars1.add(v1);
  vars1.add(v2);
  VarSet vars2=new VarSet();
  vars2.add(v1);
  vars2.add(v2);
  IndexFor iter=new IndexFor(vars1,vars2);
  while (iter.hasNext()) {
    System.out.println(Arrays.toString(iter.getState()));
    iter.next();
  }
}

Fixed version (ground truth):
@Test public void testGetState(){
  Var v0=getVar(0,2);
  Var v1=getVar(1,3);
  Var v2=getVar(2,5);
  Var v3=getVar(3,7);
  VarSet vars1=new VarSet();
  vars1.add(v0);
  vars1.add(v1);
  vars1.add(v2);
  vars1.add(v3);
  VarSet vars2=new VarSet();
  vars2.add(v1);
  vars2.add(v3);
  IndexFor iter=new IndexFor(vars1,vars2);
  while (iter.hasNext()) {
    System.out.println(Arrays.toString(iter.getState()));
    System.out.println(iter.next());
  }
  iter.reset();
  for (int b=0; b < 3; b++) {
    for (int d=0; d < 7; d++) {
      assertTrue(iter.hasNext());
      System.out.println(Arrays.toString(iter.getState()));
      Assert.assertArrayEquals(new int[]{b,d},iter.getState());
      int aa=0;
      int cc=0;
      assertEquals(aa * 3 * 5* 7 + b * 5 * 7 + cc * 7 + d,iter.next());
    }
  }
  assertFalse(iter.hasNext());
}
Program: 131211
Project: 131211
Buggy source:
/** 
 * this is the "no-allocation" version of the non-void method of the same name.
 */
public void getVarConfigAsArray(int configIndex,int[] putInto){
  if (putInto.length != this.size())   throw new IllegalArgumentException();
  int i=0;
  for (  Var var : this) {
    putInto[i++]=configIndex % var.getNumStates();
    configIndex/=var.getNumStates();
  }
}

Fixed version (ground truth):
/** 
 * this is the "no-allocation" version of the non-void method of the same name.
 */
public void getVarConfigAsArray(int configIndex,int[] putInto){
  if (putInto.length != this.size())   throw new IllegalArgumentException();
  int i=putInto.length - 1;
  for (int v=this.size() - 1; v >= 0; v--) {
    Var var=this.get(v);
    putInto[i--]=configIndex % var.getNumStates();
    configIndex/=var.getNumStates();
  }
}
Program: 131212
Project: 131212
Buggy source:
public NaryTree(String symbol,int start,int end,ArrayList<NaryTree> children,boolean isLexical){
  this.symbol=symbol;
  this.start=start;
  this.end=end;
  this.children=children;
  this.isLexical=isLexical;
  this.parent=null;
  for (  NaryTree child : children) {
    child.parent=this;
  }
}

Fixed version (ground truth):
public NaryTree(String symbol,int start,int end,ArrayList<NaryTree> children,boolean isLexical){
  this.symbol=symbol;
  this.start=start;
  this.end=end;
  this.children=children;
  this.isLexical=isLexical;
  this.parent=null;
  if (children != null) {
    for (    NaryTree child : children) {
      child.parent=this;
    }
  }
}
Program: 131213
Project: 131213
Buggy source:
/** 
 * Treats all the input modules as if they were concatenated into a long vector, and computes the size of that vector.
 */
public static int getOutputSize(List<? extends Module<? extends MVec>> mods){
  int totInDimension=0;
  for (  Module<?> mod : mods) {
    totInDimension+=mod.getOutput().size();
  }
  return totInDimension;
}

Fixed version (ground truth):
/** 
 * Treats all the input modules as if they were concatenated into a long vector, and computes the size of that vector.
 */
public static int getOutputSize(List<? extends Module<?>> mods){
  int totInDimension=0;
  for (  Module<?> mod : mods) {
    totInDimension+=mod.getOutput().size();
  }
  return totInDimension;
}
Program: 131214
Project: 131214
Buggy source:
/** 
 * Parses the command line arguments and sets any of public static fields annotated with @Opt that have been registered with this   {@link ArgParser} via {@link #registerClass(Class)}.
 */
public void parseArgs(String[] args) throws ParseException {
  CommandLine cmd=null;
  CommandLineParser parser=new PosixParser();
  cmd=parser.parse(options,args);
  fieldValueMap=new HashMap<>();
  try {
    for (    Option apacheOpt : optionFieldMap.keySet()) {
      Field field=optionFieldMap.get(apacheOpt);
      if (cmd.hasOption(apacheOpt.getLongOpt())) {
        String value=apacheOpt.hasArg() ? cmd.getOptionValue(apacheOpt.getLongOpt()) : "String_Node_Str";
        if (Modifier.isStatic(field.getModifiers())) {
          setStaticField(field,cmd.getOptionValue(apacheOpt.getLongOpt()));
        }
 else {
          fieldValueMap.put(field,value);
        }
      }
    }
  }
 catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Parses the command line arguments and sets any of public static fields annotated with @Opt that have been registered with this   {@link ArgParser} via {@link #registerClass(Class)}.
 */
public void parseArgs(String[] args) throws ParseException {
  CommandLine cmd=null;
  CommandLineParser parser=new PosixParser();
  cmd=parser.parse(options,args);
  fieldValueMap=new HashMap<>();
  try {
    for (    Option apacheOpt : optionFieldMap.keySet()) {
      Field field=optionFieldMap.get(apacheOpt);
      if (cmd.hasOption(apacheOpt.getLongOpt())) {
        String value=apacheOpt.hasArg() ? cmd.getOptionValue(apacheOpt.getLongOpt()) : "String_Node_Str";
        if (Modifier.isStatic(field.getModifiers())) {
          setStaticField(field,value);
        }
 else {
          fieldValueMap.put(field,value);
        }
      }
    }
  }
 catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}
Program: 131215
Project: 131215
Buggy source:
@Override public double evaluate(AnnoSentenceCollection predSents,AnnoSentenceCollection goldSents,String name){
  int numTot=0;
  int numIncorrect=0;
  for (int i=0; i < predSents.size(); i++) {
    AnnoSentence predSent=predSents.get(i);
    AnnoSentence goldSent=goldSents.get(i);
    for (int c=0; c < goldSent.size(); c++) {
      if (skipPunctuation && DepParseAccuracy.isPunctuation(goldSent.getWord(c))) {
        continue;
      }
      int p=goldSent.getParent(c);
      if (predSent.getDepEdgeMask().isPruned(p,c)) {
        numIncorrect++;
        break;
      }
    }
    numTot++;
  }
  int numCorrect=numTot - numIncorrect;
  log.info(String.format("String_Node_Str",name,numCorrect,numTot,(double)numCorrect / numTot));
  return numTot - numCorrect;
}

Fixed version (ground truth):
@Override public double evaluate(AnnoSentenceCollection predSents,AnnoSentenceCollection goldSents,String name){
  int numTot=0;
  int numIncorrect=0;
  for (int i=0; i < predSents.size(); i++) {
    AnnoSentence predSent=predSents.get(i);
    AnnoSentence goldSent=goldSents.get(i);
    for (int c=0; c < goldSent.size(); c++) {
      if (skipPunctuation && DepParseAccuracy.isPunctuation(goldSent.getWord(c))) {
        continue;
      }
      int p=goldSent.getParent(c);
      DepEdgeMask predMask=predSent.getDepEdgeMask();
      if (predMask != null && predMask.isPruned(p,c)) {
        numIncorrect++;
        break;
      }
    }
    numTot++;
  }
  int numCorrect=numTot - numIncorrect;
  log.info(String.format("String_Node_Str",name,numCorrect,numTot,(double)numCorrect / numTot));
  return numTot - numCorrect;
}
Program: 131216
Project: 131216
Buggy source:
@Override public Tensor forward(){
  Tensor mark=markIn.getOutput();
  Tensor left=leftIn.getOutput();
  Tensor right=rightIn.getOutput();
  Tensor.checkEqualSize(left,right);
  y=new Tensor(left);
  left.fill(s.zero());
  for (int c=0; c < y.size(); c++) {
    Tensor t=(mark.getValue(c) == s.zero()) ? left : right;
    y.setValue(c,t.getValue(c));
  }
  return y;
}

Fixed version (ground truth):
@Override public Tensor forward(){
  Tensor mark=markIn.getOutput();
  Tensor left=leftIn.getOutput();
  Tensor right=rightIn.getOutput();
  Tensor.checkEqualSize(left,right);
  y=new Tensor(left);
  y.fill(s.zero());
  for (int c=0; c < y.size(); c++) {
    Tensor t=(mark.getValue(c) == s.zero()) ? left : right;
    y.setValue(c,t.getValue(c));
  }
  return y;
}
Program: 131217
Project: 131217
Buggy source:
public double call(double v){
  assertEquals(y.get(),v,1e-13);
  y.decrement();
  return v;
}

Fixed version (ground truth):
public double call(double v){
  assertEquals(y.v,v,1e-13);
  y.v--;
  return v;
}
Program: 131218
Project: 131218
Buggy source:
@Test public void testUpdateDoublesAndModel(){
  int numParams=(3 * 2) * 2 + 2 * 1;
  FgModel model=new FgModel(numParams);
  final MutableInt x=new MutableInt(0);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      x.increment();
      return x.get();
    }
  }
);
  double[] params=new double[model.getNumParams()];
  model.updateDoublesFromModel(params);
  JUnitUtils.assertArrayEquals(new double[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14},params,1e-13);
  DoubleSort.sortDesc(params);
  model.updateModelFromDoubles(params);
  final MutableInt y=new MutableInt(14);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(y.get(),v,1e-13);
      y.decrement();
      return v;
    }
  }
);
}

Fixed version (ground truth):
@Test public void testUpdateDoublesAndModel(){
  int numParams=(3 * 2) * 2 + 2 * 1;
  FgModel model=new FgModel(numParams);
  final MutableInt x=new MutableInt(0);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      x.v++;
      return x.v;
    }
  }
);
  double[] params=new double[model.getNumParams()];
  model.updateDoublesFromModel(params);
  JUnitUtils.assertArrayEquals(new double[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14},params,1e-13);
  DoubleSort.sortDesc(params);
  model.updateModelFromDoubles(params);
  final MutableInt y=new MutableInt(14);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(y.v,v,1e-13);
      y.v--;
      return v;
    }
  }
);
}
Program: 131219
Project: 131219
Buggy source:
@Test public void testApply(){
  int numParams=(3 * 2) * 2 + 2 * 1;
  FgModel model=new FgModel(numParams);
  assertEquals(numParams,model.getNumParams());
  final MutableInt x=new MutableInt(0);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(0.0,v,1e-13);
      x.increment();
      return 1.0;
    }
  }
);
  assertEquals(numParams,x.get());
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(1.0,v,1e-13);
      return 1.0;
    }
  }
);
}

Fixed version (ground truth):
@Test public void testApply(){
  int numParams=(3 * 2) * 2 + 2 * 1;
  FgModel model=new FgModel(numParams);
  assertEquals(numParams,model.getNumParams());
  final MutableInt x=new MutableInt(0);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(0.0,v,1e-13);
      x.v++;
      return 1.0;
    }
  }
);
  assertEquals(numParams,x.v);
  model.apply(new LambdaUnaryOpDouble(){
    public double call(    double v){
      assertEquals(1.0,v,1e-13);
      return 1.0;
    }
  }
);
}
Program: 131220
Project: 131220
Buggy source:
private static VarSet createVarSet(int n,VarType type){
  VarSet vars=new VarSet();
  for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        String name=LinkVar.getDefaultName(i,j);
        vars.add(new LinkVar(type,name,i,j));
      }
    }
  }
  for (int j=0; j < n; j++) {
    String name=String.format("String_Node_Str",WallDepTreeNode.WALL_POSITION,j);
    vars.add(new LinkVar(type,name,WallDepTreeNode.WALL_POSITION,j));
  }
  return vars;
}

Fixed version (ground truth):
private static VarSet createVarSet(int n,VarType type){
  VarSet vars=new VarSet();
  for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        String name=LinkVar.getDefaultName(i,j);
        vars.add(new LinkVar(type,name,i,j));
      }
    }
  }
  for (int j=0; j < n; j++) {
    String name=String.format("String_Node_Str",ParentsArray.WALL_POSITION,j);
    vars.add(new LinkVar(type,name,ParentsArray.WALL_POSITION,j));
  }
  return vars;
}
Program: 131221
Project: 131221
Buggy source:
@Override public double getLogUnormalizedScore(VarConfig vc){
  LogSemiring s=Algebras.LOG_SEMIRING;
  if (!hasOneParentPerToken(n,vc)) {
    log.trace("String_Node_Str");
    return s.zero();
  }
  int[] parents=getParents(n,vc);
  if (!DepTree.isDepTree(parents,true,InsideOutsideDepParse.singleRoot)) {
    log.trace("String_Node_Str");
    return s.zero();
  }
  return s.one();
}

Fixed version (ground truth):
@Override public double getLogUnormalizedScore(VarConfig vc){
  LogSemiring s=Algebras.LOG_SEMIRING;
  if (!hasOneParentPerToken(n,vc)) {
    log.trace("String_Node_Str");
    return s.zero();
  }
  int[] parents=getParents(n,vc);
  if (!ParentsArray.isDepTree(parents,true,InsideOutsideDepParse.singleRoot)) {
    log.trace("String_Node_Str");
    return s.zero();
  }
  return s.one();
}
Program: 131222
Project: 131222
Buggy source:
private static VarSet createVarSet(int n,VarType type){
  VarSet vars=new VarSet();
  for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        String name=LinkVar.getDefaultName(i,j);
        vars.add(new LinkVar(type,name,i,j));
      }
    }
  }
  for (int j=0; j < n; j++) {
    String name=String.format("String_Node_Str",WallDepTreeNode.WALL_POSITION,j);
    vars.add(new LinkVar(type,name,WallDepTreeNode.WALL_POSITION,j));
  }
  return vars;
}

Fixed version (ground truth):
private static VarSet createVarSet(int n,VarType type){
  VarSet vars=new VarSet();
  for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        String name=LinkVar.getDefaultName(i,j);
        vars.add(new LinkVar(type,name,i,j));
      }
    }
  }
  for (int j=0; j < n; j++) {
    String name=String.format("String_Node_Str",ParentsArray.WALL_POSITION,j);
    vars.add(new LinkVar(type,name,ParentsArray.WALL_POSITION,j));
  }
  return vars;
}
Program: 131223
Project: 131223
Buggy source:
@Override public double getLogUnormalizedScore(VarConfig vc){
  LogSemiring s=Algebras.LOG_SEMIRING;
  if (!hasOneParentPerToken(n,vc)) {
    log.warn("String_Node_Str");
    return s.zero();
  }
  int[] parents=getParents(n,vc);
  if (!DepTree.isDepTree(parents,true,InsideOutsideDepParse.singleRoot)) {
    log.warn("String_Node_Str");
    return s.zero();
  }
  return s.one();
}

Fixed version (ground truth):
@Override public double getLogUnormalizedScore(VarConfig vc){
  LogSemiring s=Algebras.LOG_SEMIRING;
  if (!hasOneParentPerToken(n,vc)) {
    log.warn("String_Node_Str");
    return s.zero();
  }
  int[] parents=getParents(n,vc);
  if (!ParentsArray.isDepTree(parents,true,InsideOutsideDepParse.singleRoot)) {
    log.warn("String_Node_Str");
    return s.zero();
  }
  return s.one();
}
Program: 131224
Project: 131224
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyOfArray(T[] orig){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      clone[v]=(T)orig[v].copy();
    }
  }
  return clone;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyOfArray(T[] orig){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      MVec copy=orig[v].copy();
      if (!copy.getClass().equals(orig[v].getClass())) {
        throw new RuntimeException(orig[v].getClass() + "String_Node_Str" + "String_Node_Str"+ copy.getClass());
      }
      clone[v]=(T)copy;
    }
  }
  return clone;
}
Program: 131225
Project: 131225
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyAndConvertAlgebraOfArray(T[] orig,Algebra newS){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      clone[v]=(T)orig[v].copyAndConvertAlgebra(newS);
    }
  }
  return clone;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyAndConvertAlgebraOfArray(T[] orig,Algebra newS){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      MVec copy=orig[v].copyAndConvertAlgebra(newS);
      if (!copy.getClass().equals(orig[v].getClass())) {
        throw new RuntimeException(orig[v].getClass() + "String_Node_Str" + "String_Node_Str"+ copy.getClass());
      }
      clone[v]=(T)copy;
    }
  }
  return clone;
}
Program: 131226
Project: 131226
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>void addArray(T[] b1,T[] addend){
}

Fixed version (ground truth):
public static <T extends MVec>void addArray(T[] b1,T[] addend){
}
Program: 131227
Project: 131227
Buggy source:
public VarTensor copyAndConvertAlgebra(Algebra newS){
  VarTensor t=new VarTensor(newS,this.vars);
  t.setFromDiffAlgebra(this);
  return t;
}

Fixed version (ground truth):
@Override public VarTensor copyAndConvertAlgebra(Algebra newS){
  VarTensor t=new VarTensor(newS,this.vars);
  t.setFromDiffAlgebra(this);
  return t;
}
Program: 131228
Project: 131228
Buggy source:
public double getTemperature(int curIter,int maxIter){
}

Fixed version (ground truth):
/** 
 * Computes the temperature using a linear annealing schedule. 
 */
public double getTemperature(int curIter,int maxIter){
}
Program: 131229
Project: 131229
Buggy source:
public static void checkForRequiredAnnotations(JointNlpEncoderPrm prm,AnnoSentenceCollection sents){
  try {
    AnnoSentence sent=sents.get(0);
    if (prm.fePrm.srlFePrm.fePrm.useTemplates) {
      if (prm.fgPrm.includeSrl) {
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.srlFePrm.fePrm.soloTemplates);
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.srlFePrm.fePrm.pairTemplates);
      }
    }
    if (prm.fgPrm.includeDp && !prm.fePrm.dpFePrm.onlyFast) {
      TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.dpFePrm.firstOrderTpls);
      if (prm.fgPrm.dpPrm.grandparentFactors || prm.fgPrm.dpPrm.arbitrarySiblingFactors) {
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.dpFePrm.secondOrderTpls);
      }
    }
  }
 catch (  IllegalStateException e) {
    log.error(e.getMessage());
    log.trace("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public static void checkForRequiredAnnotations(JointNlpEncoderPrm prm,AnnoSentenceCollection sents){
  try {
    if (sents.size() == 0) {
      return;
    }
    AnnoSentence sent=sents.get(0);
    if (prm.fePrm.srlFePrm.fePrm.useTemplates) {
      if (prm.fgPrm.includeSrl) {
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.srlFePrm.fePrm.soloTemplates);
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.srlFePrm.fePrm.pairTemplates);
      }
    }
    if (prm.fgPrm.includeDp && !prm.fePrm.dpFePrm.onlyFast) {
      TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.dpFePrm.firstOrderTpls);
      if (prm.fgPrm.dpPrm.grandparentFactors || prm.fgPrm.dpPrm.arbitrarySiblingFactors) {
        TemplateLanguage.assertRequiredAnnotationTypes(sent,prm.fePrm.dpFePrm.secondOrderTpls);
      }
    }
  }
 catch (  IllegalStateException e) {
    log.error(e.getMessage());
    log.trace("String_Node_Str",e);
  }
}
Program: 131231
Project: 131231
Buggy source:
public void preOrderTraversal(FnO1ToVoid<NaryTree> function){
  function.call(this);
  if (children != null) {
    for (    NaryTree child : children) {
      child.postOrderTraversal(function);
    }
  }
}

Fixed version (ground truth):
public void preOrderTraversal(FnO1ToVoid<NaryTree> function){
  function.call(this);
  if (children != null) {
    for (    NaryTree child : children) {
      child.preOrderTraversal(function);
    }
  }
}
Program: 131232
Project: 131232
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyOfArray(T[] orig){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      clone[v]=(T)orig[v].copy();
    }
  }
  return clone;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyOfArray(T[] orig){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      MVec copy=orig[v].copy();
      if (!copy.getClass().equals(orig[v].getClass())) {
        throw new RuntimeException(orig[v].getClass() + "String_Node_Str" + "String_Node_Str"+ copy.getClass());
      }
      clone[v]=(T)copy;
    }
  }
  return clone;
}
Program: 131233
Project: 131233
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyAndConvertAlgebraOfArray(T[] orig,Algebra newS){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      clone[v]=(T)orig[v].copyAndConvertAlgebra(newS);
    }
  }
  return clone;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static <T extends MVec>T[] copyAndConvertAlgebraOfArray(T[] orig,Algebra newS){
  if (orig == null) {
    return null;
  }
  T[] clone=Arrays.copyOf(orig,orig.length);
  for (int v=0; v < clone.length; v++) {
    if (orig[v] != null) {
      MVec copy=orig[v].copyAndConvertAlgebra(newS);
      if (!copy.getClass().equals(orig[v].getClass())) {
        throw new RuntimeException(orig[v].getClass() + "String_Node_Str" + "String_Node_Str"+ copy.getClass());
      }
      clone[v]=(T)copy;
    }
  }
  return clone;
}
Program: 131234
Project: 131234
Buggy source:
@SuppressWarnings("String_Node_Str") public static <T extends MVec>void addArray(T[] b1,T[] addend){
}

Fixed version (ground truth):
public static <T extends MVec>void addArray(T[] b1,T[] addend){
}
Program: 131235
Project: 131235
Buggy source:
public VarTensor copyAndConvertAlgebra(Algebra newS){
  VarTensor t=new VarTensor(newS,this.vars);
  t.setFromDiffAlgebra(this);
  return t;
}

Fixed version (ground truth):
@Override public VarTensor copyAndConvertAlgebra(Algebra newS){
  VarTensor t=new VarTensor(newS,this.vars);
  t.setFromDiffAlgebra(this);
  return t;
}
Program: 131236
Project: 131236
Buggy source:
public static void initDefaultPool(int numThreads){
  Threads.defaultPool=Executors.newFixedThreadPool(numThreads);
  Threads.numThreads=numThreads;
}

Fixed version (ground truth):
public static void initDefaultPool(int numThreads){
  if (numThreads == 1) {
    Threads.defaultPool=MoreExecutors.newDirectExecutorService();
    Threads.numThreads=1;
  }
 else {
    log.info("String_Node_Str",numThreads);
    Threads.defaultPool=Executors.newFixedThreadPool(numThreads);
    Threads.numThreads=numThreads;
  }
}
Program: 131237
Project: 131237
Buggy source:
/** 
 * @param srlIsSyntax If true, we put SRL annotations in as dependency parses. Dependency edges from root (gov=-1) represent predicates, with the edge type giving the predicate sense. Arguments are dependents of their predicate token, with the dependency label capturing the argument label (e.g. "ARG0" and "ARG1"). Otherwise, we create a SituationMention for every predicate, which have proper Arguments, each of which includes an EntityMention that is added to its own EntityMentionSet (all EntityMentions created by this tool in a document are unioned before making an EntityMentionSet).
 */
public ConcreteWriter(ConcreteWriterPrm prm){
  this.timestamp=System.currentTimeMillis();
  this.prm=prm;
}

Fixed version (ground truth):
public ConcreteWriter(ConcreteWriterPrm prm){
  this.timestamp=System.currentTimeMillis();
  this.prm=prm;
}
Program: 131238
Project: 131238
Buggy source:
/** 
 * Sets the include flag for each annotation type to true, or warns if it's not supported. 
 */
public void addAnnoTypes(Collection<AT> ats){
  for (  AT at : ats) {
switch (at) {
case DEP_TREE:
      this.addDepParse=true;
    break;
case SRL:
  this.addSrl=true;
break;
case NER:
this.addNerMentions=true;
break;
case RELATIONS:
this.addRelations=true;
break;
default :
log.warn("String_Node_Str",at);
}
}
}

Fixed version (ground truth):
/** 
 * Sets the include flag for each annotation type to true, or warns if it's not supported. 
 */
public void addAnnoTypes(Collection<AT> ats){
  this.addDepParse=ats.contains(AT.DEP_TREE);
  this.addSrl=ats.contains(AT.SRL);
  this.addNerMentions=ats.contains(AT.NER);
  this.addRelations=ats.contains(AT.RELATIONS);
  EnumSet<AT> others=EnumSet.complementOf(EnumSet.of(AT.DEP_TREE,AT.SRL,AT.NER,AT.RELATIONS));
  for (  AT at : ats) {
    if (others.contains(at)) {
      log.warn("String_Node_Str",at);
    }
  }
}
Program: 131239
Project: 131239
Buggy source:
public static UFgExample get2ndOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new FastDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=true;
  fgPrm.siblingFactors=true;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}

Fixed version (ground truth):
public static UFgExample get2ndOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new BitshiftDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=true;
  fgPrm.siblingFactors=true;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}
Program: 131240
Project: 131240
Buggy source:
public static UFgExample get2ndOrderGraOnlyFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new FastDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.grandparentFactors=false;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}

Fixed version (ground truth):
public static UFgExample get2ndOrderGraOnlyFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new BitshiftDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.grandparentFactors=false;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}
Program: 131241
Project: 131241
Buggy source:
public static UFgExample get1stOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new FastDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=false;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}

Fixed version (ground truth):
public static UFgExample get1stOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new BitshiftDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=false;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}
Program: 131242
Project: 131242
Buggy source:
public static UFgExample get2ndOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new FastDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=true;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}

Fixed version (ground truth):
public static UFgExample get2ndOrderFg(AnnoSentence sent,CorpusStatistics cs,FeatureNames alphabet,int numParams,boolean onlyFast){
  FactorGraph fg=new FactorGraph();
  DepParseFeatureExtractorPrm fePrm=new DepParseFeatureExtractorPrm();
  fePrm.featureHashMod=numParams;
  fePrm.firstOrderTpls=TemplateSets.getFromResource(TemplateSets.mcdonaldDepFeatsResource);
  FeatureExtractor fe=onlyFast ? new BitshiftDepParseFeatureExtractor(sent,cs,numParams,alphabet) : new DepParseFeatureExtractor(fePrm,sent,cs,alphabet);
  DepParseFactorGraphBuilderPrm fgPrm=new DepParseFactorGraphBuilderPrm();
  fgPrm.useProjDepTreeFactor=true;
  fgPrm.grandparentFactors=true;
  fgPrm.siblingFactors=false;
  DepParseFactorGraphBuilder builder=new DepParseFactorGraphBuilder(fgPrm);
  builder.build(sent,fe,fg);
  UnlabeledFgExample ex=new UnlabeledFgExample(fg,new VarConfig());
  return ex;
}
Program: 131243
Project: 131243
Buggy source:
@Override public FeatureVector calcObsFeatureVector(ObsFeExpFamFactor factor){
  ObsFeTypedFactor f=(ObsFeTypedFactor)factor;
  FeatureNames alphabet=fts.getTemplate(f).getAlphabet();
  Enum<?> ft=f.getFactorType();
  VarSet vars=f.getVars();
  FeatureVector feats=new FeatureVector();
  if (ft == SrlFactorTemplate.ROLE_UNARY || ft == SrlFactorTemplate.SENSE_ROLE_BINARY) {
    Var var=vars.iterator().next();
    int parent=((RoleVar)var).getParent();
    int child=((RoleVar)var).getChild();
    FastDepParseFe.addArcFactoredMSTFeats(isent,parent,child,feats,false,false);
  }
 else   if (ft == SrlFactorTemplate.SENSE_UNARY) {
    SenseVar var=(SenseVar)vars.iterator().next();
    int parent=var.getParent();
    FastDepParseFe.addArcFactoredMSTFeats(isent,-1,parent,feats,false,false);
  }
 else {
    throw new RuntimeException("String_Node_Str" + ft);
  }
  int[] idxs=feats.getInternalIndices();
  int used=feats.getUsed();
  for (int i=0; i < used; i++) {
    idxs[i]=alphabet.lookupIndex(idxs[i]);
  }
  return feats;
}

Fixed version (ground truth):
@Override public FeatureVector calcObsFeatureVector(ObsFeExpFamFactor factor){
  ObsFeTypedFactor f=(ObsFeTypedFactor)factor;
  FeatureNames alphabet=fts.getTemplate(f).getAlphabet();
  Enum<?> ft=f.getFactorType();
  VarSet vars=f.getVars();
  FeatureVector feats=new FeatureVector();
  if (ft == SrlFactorTemplate.ROLE_UNARY || ft == SrlFactorTemplate.SENSE_ROLE_BINARY) {
    Var var=vars.iterator().next();
    int parent=((RoleVar)var).getParent();
    int child=((RoleVar)var).getChild();
    BitshiftDepParseFeatures.addArcFactoredMSTFeats(isent,parent,child,feats,false,false,featureHashMod);
  }
 else   if (ft == SrlFactorTemplate.SENSE_UNARY) {
    SenseVar var=(SenseVar)vars.iterator().next();
    int parent=var.getParent();
    BitshiftDepParseFeatures.addArcFactoredMSTFeats(isent,-1,parent,feats,false,false,featureHashMod);
  }
 else {
    throw new RuntimeException("String_Node_Str" + ft);
  }
  int[] idxs=feats.getInternalIndices();
  int used=feats.getUsed();
  for (int i=0; i < used; i++) {
    idxs[i]=alphabet.lookupIndex(idxs[i]);
  }
  return feats;
}
Program: 131244
Project: 131244
Buggy source:
public FastSrlFeatureExtractor(AnnoSentence sent,CorpusStatistics cs,int featureHashMod,FactorTemplateList fts){
  this.isent=new IntAnnoSentence(sent,cs.store);
  FastDepParseFeatureExtractor.featureHashMod=featureHashMod;
  this.fts=fts;
}

Fixed version (ground truth):
public FastSrlFeatureExtractor(AnnoSentence sent,CorpusStatistics cs,int featureHashMod,FactorTemplateList fts){
  this.isent=new IntAnnoSentence(sent,cs.store);
  this.featureHashMod=featureHashMod;
  this.fts=fts;
}
Program: 131245
Project: 131245
Buggy source:
private Function getValidationFn(final AnnoSentenceCollection devInput,final AnnoSentenceCollection devGold){
  if (devInput == null || devGold == null) {
    return null;
  }
  final JointNlpAnnotator anno=this;
  final Evaluator eval;
  if (CorpusHandler.getPredAts().equals(Lists.getList(AT.DEP_TREE))) {
    eval=new DepParseAccuracy(prm.dpSkipPunctuation);
  }
 else   if (CorpusHandler.getPredAts().equals(Lists.getList(AT.SRL))) {
    SrlEvaluatorPrm evalPrm=new SrlEvaluatorPrm();
    evalPrm.evalSense=prm.buPrm.fgPrm.srlPrm.predictSense;
    evalPrm.evalPredicatePosition=prm.buPrm.fgPrm.srlPrm.predictPredPos;
    evalPrm.evalRoles=(prm.buPrm.fgPrm.srlPrm.roleStructure != RoleStructure.NO_ROLES);
    eval=new SrlEvaluator(evalPrm);
  }
 else   if (CorpusHandler.getPredAts().equals(Lists.getList(AT.REL_LABELS))) {
    eval=new RelationEvaluator();
  }
 else {
    log.warn("String_Node_Str");
    return null;
  }
  JointNlpFgExamplesBuilder builder=new JointNlpFgExamplesBuilder(prm.buPrm,model.getOfc(),model.getCs(),false);
  final FgExampleList devData=builder.getData(devInput,null);
  return new Function(){
    @Override public double getValue(    IntDoubleVector point){
      anno.annotate(devInput,devData);
      return eval.evaluate(devInput,devGold,"String_Node_Str");
    }
    @Override public int getNumDimensions(){
      return -1;
    }
  }
;
}

Fixed version (ground truth):
private Function getValidationFn(final AnnoSentenceCollection devInput,final AnnoSentenceCollection devGold){
  if (devInput == null || devGold == null) {
    return null;
  }
  final JointNlpAnnotator anno=this;
  final Evaluator eval;
  if (CorpusHandler.getPredAts().equals(Lists.getList(AT.DEP_TREE))) {
    eval=new DepParseAccuracy(prm.dpSkipPunctuation);
  }
 else   if (CorpusHandler.getPredAts().equals(Lists.getList(AT.SRL)) || CorpusHandler.getPredAts().equals(Lists.getList(AT.SRL_PRED_IDX,AT.SRL))) {
    SrlEvaluatorPrm evalPrm=new SrlEvaluatorPrm();
    evalPrm.evalSense=prm.buPrm.fgPrm.srlPrm.predictSense;
    evalPrm.evalPredicatePosition=prm.buPrm.fgPrm.srlPrm.predictPredPos;
    evalPrm.evalRoles=(prm.buPrm.fgPrm.srlPrm.roleStructure != RoleStructure.NO_ROLES);
    eval=new SrlEvaluator(evalPrm);
  }
 else   if (CorpusHandler.getPredAts().equals(Lists.getList(AT.REL_LABELS))) {
    eval=new RelationEvaluator();
  }
 else {
    log.warn("String_Node_Str");
    return null;
  }
  JointNlpFgExamplesBuilder builder=new JointNlpFgExamplesBuilder(prm.buPrm,model.getOfc(),model.getCs(),false);
  final FgExampleList devData=builder.getData(devInput,null);
  return new Function(){
    @Override public double getValue(    IntDoubleVector point){
      anno.annotate(devInput,devData);
      return eval.evaluate(devInput,devGold,"String_Node_Str");
    }
    @Override public int getNumDimensions(){
      return -1;
    }
  }
;
}
Program: 131246
Project: 131246
Buggy source:
private String getLabel(DepGraph dg,int p,int c){
  String label=dg.get(p,c);
  if (label == null) {
    return NO_LABEL;
  }
 else   if (!prm.labeled || (p == -1 && !prm.evalSense)) {
    return SOME_LABEL;
  }
 else {
    return label;
  }
}

Fixed version (ground truth):
private String getLabel(DepGraph dg,int p,int c){
  if (dg == null) {
    return null;
  }
  String label=dg.get(p,c);
  if (label == null) {
    return NO_LABEL;
  }
 else   if (!prm.labeled || (p == -1 && !prm.evalSense)) {
    return SOME_LABEL;
  }
 else {
    return label;
  }
}
Program: 131247
Project: 131247
Buggy source:
public static SrlGraph getSrlGraphFromVarConfig(VarConfig vc,int n){
  int srlVarCount=0;
  SrlGraph srlGraph=new SrlGraph(n);
  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);
      srlVarCount++;
    }
 else     if (v instanceof SenseVar && v.getType() == VarType.PREDICTED) {
      SenseVar sense=(SenseVar)v;
      String predLabel=vc.getStateName(sense);
      if ("String_Node_Str".equals(predLabel)) {
      }
 else {
        SrlPred pred=srlGraph.getPredAt(sense.getParent());
        if (pred == null) {
          pred=new SrlPred(sense.getParent(),predLabel);
          srlGraph.addPred(pred);
        }
 else {
          pred.setLabel(predLabel);
        }
      }
      srlVarCount++;
    }
  }
  if (srlVarCount > 0) {
    return srlGraph;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public static SrlGraph getSrlGraphFromVarConfig(VarConfig vc,int n){
  int srlVarCount=0;
  SrlGraph srlGraph=new SrlGraph(n);
  for (  Var v : vc.getVars()) {
    if (v instanceof RoleVar && v.getType() != VarType.LATENT) {
      RoleVar role=(RoleVar)v;
      String stateName=vc.getStateName(role);
      if (!"String_Node_Str".equals(stateName)) {
        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,stateName);
        srlGraph.addEdge(edge);
      }
      srlVarCount++;
    }
 else     if (v instanceof SenseVar && v.getType() == VarType.PREDICTED) {
      SenseVar sense=(SenseVar)v;
      String predLabel=vc.getStateName(sense);
      if ("String_Node_Str".equals(predLabel)) {
      }
 else {
        SrlPred pred=srlGraph.getPredAt(sense.getParent());
        if (pred == null) {
          pred=new SrlPred(sense.getParent(),predLabel);
          srlGraph.addPred(pred);
        }
 else {
          pred.setLabel(predLabel);
        }
      }
      srlVarCount++;
    }
  }
  if (srlVarCount > 0) {
    return srlGraph;
  }
 else {
    return null;
  }
}