package de.ugoe.cs.cpdp.loader; import java.io.File; import java.io.IOException; import java.util.ArrayList; import weka.core.Attribute; import weka.core.DenseInstance; import weka.core.Instances; import de.ugoe.cs.cpdp.loader.AbstractFolderLoader.SingleVersionLoader; import de.ugoe.cs.util.FileTools; /** * Loads the instances for a software version from a CSV file of the // TODO dataset citation * data set. * @author Steffen Herbold */ class CSVDataLoader implements SingleVersionLoader { /** * Loads the instances. * @param file handle to the file of the instances * @return the instances */ @Override public Instances load(File file) { final String[] lines; try { lines = FileTools.getLinesFromFile(file.getAbsolutePath()); } catch (IOException e) { throw new RuntimeException(e); } // configure Instances final ArrayList atts = new ArrayList(); String[] lineSplit = lines[0].split(","); for( int j=0 ; j classAttVals = new ArrayList(); classAttVals.add("0"); classAttVals.add("1"); final Attribute classAtt = new Attribute("bug", classAttVals); atts.add(classAtt); final Instances data = new Instances(file.getName(), atts, 0); data.setClass(classAtt); // fetch data for( int i=1 ; i