Example usage for weka.core.converters XRFFLoader getDataSet

List of usage examples for weka.core.converters XRFFLoader getDataSet

Introduction

In this page you can find the example usage for weka.core.converters XRFFLoader getDataSet.

Prototype

public Instances getDataSet() throws IOException 

Source Link

Document

Return the full data set.

Usage

From source file:cn.ict.zyq.bestConf.util.DataIOFile.java

License:Open Source License

/**
 * Return the data set loaded from the Xrff file at @param path
 *//*from   w w  w . j ava2 s  .  c o  m*/
public static Instances loadDataFromXrffFile(String path) throws IOException {
    XRFFLoader loader = new XRFFLoader();
    loader.setSource(new File(path));
    Instances data = loader.getDataSet();

    System.out.println("\nHeader of dataset:\n");
    System.out.println(new Instances(data, 0));
    return data;
}

From source file:org.openscience.cdk.applications.taverna.io.XRFFFileReaderActivity.java

License:Open Source License

@Override
public void work() throws Exception {
    // Get input/*from   ww  w  .java  2 s  .  c o  m*/
    List<File> files = this.getInputAsFileList(this.INPUT_PORTS[0]);
    // Do work
    List<Instances> datasets = new LinkedList<Instances>();
    XRFFLoader loader = new XRFFLoader();
    for (File file : files) {
        try {
            loader.setSource(file);
            Instances instances = loader.getDataSet();
            datasets.add(instances);
        } catch (Exception e) {
            ErrorLogger.getInstance().writeError(CDKTavernaException.READ_FILE_ERROR + file,
                    this.getActivityName(), e);
        }
    }
    // Set output
    this.setOutputAsObjectList(datasets, this.OUTPUT_PORTS[0]);
}

From source file:org.openscience.cdk.applications.taverna.iterativeio.IterativeXRFFFileReaderActivity.java

License:Open Source License

@Override
public void work() throws Exception {
    // Get input/* w w w  .ja v a2  s .c om*/
    List<File> files = this.getInputAsFileList(this.INPUT_PORTS[0]);
    int readSize = this.getInputAsObject(this.INPUT_PORTS[1], Integer.class);
    // Do work
    List<T2Reference> outputList = new ArrayList<T2Reference>();
    int index = 0;
    List<Instances> datasets = new LinkedList<Instances>();
    XRFFLoader loader = new XRFFLoader();
    while (!files.isEmpty()) {
        File file = files.remove(0);
        try {
            loader.setSource(file);
            Instances instances = loader.getDataSet();
            datasets.add(instances);
        } catch (Exception e) {
            ErrorLogger.getInstance().writeError(CDKTavernaException.READ_FILE_ERROR + file,
                    this.getActivityName(), e);
        }
        if (files.isEmpty() || datasets.size() >= readSize) {
            T2Reference containerRef = this.setIterativeOutputAsList(datasets, this.OUTPUT_PORTS[0], index);
            outputList.add(index, containerRef);
            index++;
            datasets.clear();
        }
    }
    // Set output
    this.setIterativeReferenceList(outputList, this.OUTPUT_PORTS[0]);

}