Program: 117179
Project: 117179
Buggy source:
/** 
 * Splits a dataset. <pre> Usage: mltk.core.processor.InstancesSplitter -i	input dataset path -o	output directory path [-r]	attribute file path [-m]	splitting mode:parameter. Splitting mode can be split (s) and cross validation (c) (default: c:5) [-a]	attribute name to perform stratified sampling (default: null) [-s]	seed of the random number generator (default: 0) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(InstancesSplitter.class,opts);
  String[] data=null;
  try {
    parser.parse(args);
    data=opts.crossValidationMode.split("String_Node_Str");
    if (data.length < 2) {
      throw new IllegalArgumentException();
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Random.getInstance().setSeed(opts.seed);
  Instances instances=InstancesReader.read(opts.attPath,opts.inputPath);
  File attFile=new File(opts.attPath);
  String prefix=attFile.getName().split("String_Node_Str")[0];
  File dir=new File(opts.outputDirPath);
  if (!dir.exists()) {
    dir.mkdir();
  }
switch (data[0]) {
case "String_Node_Str":
    int k=Integer.parseInt(data[1]);
  if (data.length == 2) {
    Instances[][] folds=InstancesSplitter.createCrossValidationFolds(instances,opts.attToStrafity,k);
    for (int i=0; i < folds.length; i++) {
      String path=opts.outputDirPath + File.separator + "String_Node_Str"+ i;
      File directory=new File(path);
      if (!directory.exists()) {
        directory.mkdir();
      }
      InstancesWriter.write(folds[i][0],path + File.separator + prefix+ "String_Node_Str",path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][1],path + File.separator + prefix+ "String_Node_Str");
    }
  }
 else {
    double ratio=Double.parseDouble(data[2]);
    Instances[][] folds=InstancesSplitter.createCrossValidationFolds(instances,opts.attToStrafity,k,ratio);
    for (int i=0; i < folds.length; i++) {
      String path=opts.outputDirPath + File.separator + "String_Node_Str"+ i;
      File directory=new File(path);
      if (!directory.exists()) {
        directory.mkdir();
      }
      InstancesWriter.write(folds[i][0],path + File.separator + prefix+ "String_Node_Str",path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][1],path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][2],path + File.separator + prefix+ "String_Node_Str");
    }
  }
break;
case "String_Node_Str":
if (data.length == 2) {
double ratio=Double.parseDouble(data[1]);
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratio);
InstancesWriter.write(datasets[0],opts.outputDirPath + File.separator + prefix+ "String_Node_Str",opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[1],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
}
if (data.length == 3) {
double[] ratios=new double[data.length - 1];
for (int i=0; i < ratios.length; i++) {
ratios[i]=Double.parseDouble(data[i + 1]);
}
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratios);
InstancesWriter.write(datasets[0],opts.outputDirPath + File.separator + prefix+ "String_Node_Str",opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[1],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[2],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
}
 else {
double[] ratios=new double[data.length - 1];
for (int i=0; i < ratios.length; i++) {
ratios[i]=Double.parseDouble(data[i + 1]);
}
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratios);
for (int i=0; i < datasets.length; i++) {
InstancesWriter.write(datasets[i],opts.outputDirPath + File.separator + prefix+ "String_Node_Str"+ i);
}
}
break;
default :
break;
}
}

Fixed version (ground truth):
/** 
 * Splits a dataset. <pre> Usage: mltk.core.processor.InstancesSplitter -i	input dataset path -o	output directory path [-r]	attribute file path [-m]	splitting mode:parameter. Splitting mode can be split (s) and cross validation (c) (default: c:5) [-a]	attribute name to perform stratified sampling (default: null) [-s]	seed of the random number generator (default: 0) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(InstancesSplitter.class,opts);
  String[] data=null;
  try {
    parser.parse(args);
    data=opts.crossValidationMode.split("String_Node_Str");
    if (data.length < 2) {
      throw new IllegalArgumentException();
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Random.getInstance().setSeed(opts.seed);
  Instances instances=InstancesReader.read(opts.attPath,opts.inputPath);
  File attFile=new File(opts.attPath);
  String prefix=attFile.getName().split("String_Node_Str")[0];
  File dir=new File(opts.outputDirPath);
  if (!dir.exists()) {
    dir.mkdir();
  }
switch (data[0]) {
case "String_Node_Str":
    int k=Integer.parseInt(data[1]);
  if (data.length == 2) {
    Instances[][] folds=InstancesSplitter.createCrossValidationFolds(instances,opts.attToStrafity,k);
    for (int i=0; i < folds.length; i++) {
      String path=opts.outputDirPath + File.separator + "String_Node_Str"+ i;
      File directory=new File(path);
      if (!directory.exists()) {
        directory.mkdir();
      }
      InstancesWriter.write(folds[i][0],path + File.separator + prefix+ "String_Node_Str",path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][1],path + File.separator + prefix+ "String_Node_Str");
    }
  }
 else {
    double ratio=Double.parseDouble(data[2]);
    Instances[][] folds=InstancesSplitter.createCrossValidationFolds(instances,opts.attToStrafity,k,ratio);
    for (int i=0; i < folds.length; i++) {
      String path=opts.outputDirPath + File.separator + "String_Node_Str"+ i;
      File directory=new File(path);
      if (!directory.exists()) {
        directory.mkdir();
      }
      InstancesWriter.write(folds[i][0],path + File.separator + prefix+ "String_Node_Str",path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][1],path + File.separator + prefix+ "String_Node_Str");
      InstancesWriter.write(folds[i][2],path + File.separator + prefix+ "String_Node_Str");
    }
  }
break;
case "String_Node_Str":
if (data.length == 2) {
double ratio=Double.parseDouble(data[1]);
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratio);
InstancesWriter.write(datasets[0],opts.outputDirPath + File.separator + prefix+ "String_Node_Str",opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[1],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
}
 else if (data.length == 3) {
double[] ratios=new double[data.length - 1];
for (int i=0; i < ratios.length; i++) {
  ratios[i]=Double.parseDouble(data[i + 1]);
}
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratios);
InstancesWriter.write(datasets[0],opts.outputDirPath + File.separator + prefix+ "String_Node_Str",opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[1],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
InstancesWriter.write(datasets[2],opts.outputDirPath + File.separator + prefix+ "String_Node_Str");
}
 else {
double[] ratios=new double[data.length - 1];
for (int i=0; i < ratios.length; i++) {
  ratios[i]=Double.parseDouble(data[i + 1]);
}
Instances[] datasets=InstancesSplitter.split(instances,opts.attToStrafity,ratios);
for (int i=0; i < datasets.length; i++) {
  InstancesWriter.write(datasets[i],opts.outputDirPath + File.separator + prefix+ "String_Node_Str"+ i);
}
}
break;
default :
break;
}
}