List of usage examples for weka.core.converters XRFFSaver setInstances
@Override public void setInstances(Instances instances)
From source file:cn.ict.zyq.bestConf.util.DataIOFile.java
License:Open Source License
/** * Save @param data to the Xrff file at @param path */// w w w. ja v a 2s .c o m public static void saveDataToXrffFile(String path, Instances data) throws IOException { System.out.println("\nSaving to file " + path + "..."); XRFFSaver saver = new XRFFSaver(); saver.setInstances(data); saver.setFile(new File(path)); saver.writeBatch(); }
From source file:org.openscience.cdk.applications.taverna.io.XRFFFileWriterActivity.java
License:Open Source License
@Override public void work() throws Exception { // Get input/*from w ww. j av a 2 s.co m*/ List<Instances> datasets = this.getInputAsList(this.INPUT_PORTS[0], Instances.class); File targetFile = this.getInputAsFile(this.INPUT_PORTS[1]); String directory = Tools.getDirectory(targetFile); String name = Tools.getFileName(targetFile); String extension = (String) this.getConfiguration() .getAdditionalProperty(CDKTavernaConstants.PROPERTY_FILE_EXTENSION); // Do work List<String> resultFiles = new ArrayList<String>(); for (Instances instances : datasets) { File file = FileNameGenerator.getNewFile(directory, extension, name, this.iteration); try { XRFFSaver saver = new XRFFSaver(); saver.setFile(file); saver.setInstances(instances); saver.writeBatch(); } catch (Exception e) { ErrorLogger.getInstance().writeError(CDKTavernaException.WRITE_FILE_ERROR + file.getPath() + "!", this.getActivityName(), e); throw new CDKTavernaException(this.getActivityName(), CDKTavernaException.WRITE_FILE_ERROR + file.getPath() + "!"); } } // Set output this.setOutputAsStringList(resultFiles, this.OUTPUT_PORTS[0]); }