All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weka.core.converters.JSONSaver Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.

There is a newer version: 3.8.6
Show newest version
/*
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see .
 */

/*
 * JSONSaver.java
 * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand
 *
 */

package weka.core.converters;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
import java.util.zip.GZIPOutputStream;

import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instances;
import weka.core.Option;
import weka.core.RevisionUtils;
import weka.core.SingleIndex;
import weka.core.Utils;
import weka.core.json.JSONInstances;
import weka.core.json.JSONNode;

/**
 *  Writes to a destination that is in JSON format.
* The data can be compressed with gzip, in order to save space.
*
* For more information, see JSON homepage:
* http://www.json.org/ *

* * * Valid options are: *

* *

 * -i <the input file>
 *  The input file
 * 
* *
 * -o <the output file>
 *  The output file
 * 
* *
 * -C <class index>
 *  The class index (first and last are valid as well).
 *  (default: last)
 * 
* *
 * -compress
 *  Compresses the data (uses '.json.gz' as extension instead of '.json')
 *  (default: off)
 * 
* * * * @author FracPete (fracpete at waikato dot ac dot nz) * @version $Revision: 10203 $ * @see Saver */ public class JSONSaver extends AbstractFileSaver implements BatchConverter { /** for serialization. */ private static final long serialVersionUID = -1047134047244534557L; /** the class index. */ protected SingleIndex m_ClassIndex = new SingleIndex(); /** whether to compress the output. */ protected boolean m_CompressOutput = false; /** * Constructor. */ public JSONSaver() { resetOptions(); } /** * Returns a string describing this Saver. * * @return a description of the Saver suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Writes to a destination that is in JSON format.\n" + "The data can be compressed with gzip, in order to save space.\n\n" + "For more information, see JSON homepage:\n" + "http://www.json.org/"; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy