Package weka.core.converters
Class SimpleArffSaver
- java.lang.Object
-
- weka.core.converters.AbstractSaver
-
- weka.core.converters.AbstractFileSaver
-
- weka.core.converters.SimpleArffSaver
-
- All Implemented Interfaces:
adams.core.io.EncodingSupporter
,Serializable
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.converters.BatchConverter
,weka.core.converters.FileSourcedConverter
,weka.core.converters.Saver
,weka.core.EnvironmentHandler
,weka.core.OptionHandler
,weka.core.RevisionHandler
,weka.core.WeightedInstancesHandler
public class SimpleArffSaver extends weka.core.converters.AbstractFileSaver implements weka.core.converters.BatchConverter, weka.core.WeightedInstancesHandler, adams.core.io.EncodingSupporter
Writes the Instances to an ARFF file in batch mode.
Valid options are:-i <the input file> The input file
-o <the output file> The output file
-decimal <num> The maximum number of digits to print after the decimal place for numeric values (default: 6)
-encoding <charset> Character set to use for writing the file.
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
Saver
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_DECIMAL_PLACES
the default number of decimal places.protected adams.core.base.BaseCharset
m_Encoding
the encoding to use.protected int
m_MaxDecimalPlaces
Max number of decimal places for numeric valuesprotected File
m_OutputFile
the file to write to.-
Fields inherited from class weka.core.converters.AbstractFileSaver
m_env, m_incrementalCounter, m_useRelativePath
-
-
Constructor Summary
Constructors Constructor Description SimpleArffSaver()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
encodingTipText()
Returns the tip text for this property.weka.core.Capabilities
getCapabilities()
Returns the Capabilities of this saver.adams.core.base.BaseCharset
getEncoding()
Returns the encoding to use.String
getFileDescription()
Returns a description of the file type.String[]
getFileExtensions()
Gets all the file extensions used for this type of fileint
getMaxDecimalPlaces()
Returns the maximum number of decimal places to printString[]
getOptions()
returns the options of the current setupString
getRevision()
Returns the revision string.String
globalInfo()
Returns a string describing this SaverEnumeration
listOptions()
Returns an enumeration describing the available options.static void
main(String[] args)
Main method.String
maxDecimalPlacesTipText()
Returns the tip text for this property.void
resetOptions()
void
setDestination(File file)
Sets the destination file (and directories if necessary).void
setDestination(OutputStream output)
Default implementation throws an IOException.void
setEncoding(adams.core.base.BaseCharset value)
Sets the encoding to use.void
setMaxDecimalPlaces(int value)
Set the maximum number of decimal places to printvoid
setOptions(String[] options)
Parses the options for this object.void
writeBatch()
Writes a Batch of instances-
Methods inherited from class weka.core.converters.AbstractFileSaver
cancel, filePrefix, getFileExtension, getUseRelativePath, getWriter, makeOptionStr, resetWriter, retrieveDir, retrieveFile, runFileSaver, setDir, setDirAndPrefix, setEnvironment, setFile, setFileExtension, setFilePrefix, setUseRelativePath, useRelativePathTipText
-
-
-
-
Field Detail
-
DEFAULT_MAX_DECIMAL_PLACES
public static final int DEFAULT_MAX_DECIMAL_PLACES
the default number of decimal places.- See Also:
- Constant Field Values
-
m_OutputFile
protected File m_OutputFile
the file to write to.
-
m_MaxDecimalPlaces
protected int m_MaxDecimalPlaces
Max number of decimal places for numeric values
-
m_Encoding
protected adams.core.base.BaseCharset m_Encoding
the encoding to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this Saver- Returns:
- a description of the Saver suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.core.converters.AbstractFileSaver
- Returns:
- an enumeration of all the available options.
-
resetOptions
public void resetOptions()
- Overrides:
resetOptions
in classweka.core.converters.AbstractFileSaver
-
getOptions
public String[] getOptions()
returns the options of the current setup- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.core.converters.AbstractFileSaver
- Returns:
- the current options
-
setOptions
public void setOptions(String[] options) throws Exception
Parses the options for this object.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.core.converters.AbstractFileSaver
- Parameters:
options
- the options to use- Throws:
Exception
- if setting of options fails
-
setMaxDecimalPlaces
public void setMaxDecimalPlaces(int value)
Set the maximum number of decimal places to print- Parameters:
value
- the maximum number of decimal places to print
-
getMaxDecimalPlaces
public int getMaxDecimalPlaces()
Returns the maximum number of decimal places to print- Returns:
- the maximum number of decimal places to print
-
maxDecimalPlacesTipText
public String maxDecimalPlacesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setEncoding
public void setEncoding(adams.core.base.BaseCharset value)
Sets the encoding to use.- Specified by:
setEncoding
in interfaceadams.core.io.EncodingSupporter
- Parameters:
value
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
getEncoding
public adams.core.base.BaseCharset getEncoding()
Returns the encoding to use.- Specified by:
getEncoding
in interfaceadams.core.io.EncodingSupporter
- Returns:
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
encodingTipText
public String encodingTipText()
Returns the tip text for this property.- Specified by:
encodingTipText
in interfaceadams.core.io.EncodingSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFileDescription
public String getFileDescription()
Returns a description of the file type.- Specified by:
getFileDescription
in interfaceweka.core.converters.FileSourcedConverter
- Specified by:
getFileDescription
in classweka.core.converters.AbstractFileSaver
- Returns:
- a short file description
-
getFileExtensions
public String[] getFileExtensions()
Gets all the file extensions used for this type of file- Specified by:
getFileExtensions
in interfaceweka.core.converters.FileSourcedConverter
- Overrides:
getFileExtensions
in classweka.core.converters.AbstractFileSaver
- Returns:
- the file extensions
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns the Capabilities of this saver.- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Overrides:
getCapabilities
in classweka.core.converters.AbstractSaver
- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
setDestination
public void setDestination(File file) throws IOException
Sets the destination file (and directories if necessary).- Specified by:
setDestination
in interfaceweka.core.converters.Saver
- Overrides:
setDestination
in classweka.core.converters.AbstractFileSaver
- Parameters:
file
- the File- Throws:
IOException
- always
-
setDestination
public void setDestination(OutputStream output) throws IOException
Default implementation throws an IOException.- Specified by:
setDestination
in interfaceweka.core.converters.Saver
- Overrides:
setDestination
in classweka.core.converters.AbstractFileSaver
- Parameters:
output
- the OutputStream- Throws:
IOException
- always
-
writeBatch
public void writeBatch() throws IOException
Writes a Batch of instances- Specified by:
writeBatch
in interfaceweka.core.converters.Saver
- Specified by:
writeBatch
in classweka.core.converters.AbstractSaver
- Throws:
IOException
- throws IOException if saving in batch mode is not possible
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Returns:
- the revision
-
-