milk.experiment
Class MICSVResultListener

java.lang.Object
  |
  +--milk.experiment.MICSVResultListener
All Implemented Interfaces:
MIResultListener, weka.core.OptionHandler, java.io.Serializable
Direct Known Subclasses:
MIInstancesResultListener

public class MICSVResultListener
extends java.lang.Object
implements MIResultListener, weka.core.OptionHandler

MICSVResultListener outputs the received results in csv format to a Writer

See Also:
Serialized Form

Field Summary
protected  java.io.PrintWriter m_Out
          The destination for results (typically connected to the output file)
protected  java.io.File m_OutputFile
          The destination output file, null sends to System.out
protected  MIResultProducer m_RP
          The MIResultProducer sending us results
 
Constructor Summary
MICSVResultListener()
           
 
Method Summary
 void acceptResult(MIResultProducer rp, java.lang.Object[] key, java.lang.Object[] result)
          Just prints out each result as it is received.
 java.lang.String[] determineColumnConstraints(MIResultProducer rp)
          Determines if there are any constraints (imposed by the destination) on the result columns to be produced by resultProducers.
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 java.io.File getOutputFile()
          Get the value of OutputFile.
 java.lang.String globalInfo()
          Returns a string describing this result listener
 boolean isResultRequired(MIResultProducer rp, java.lang.Object[] key)
          Always says a result is required.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options..
 java.lang.String outputFileTipText()
          Returns the tip text for this property
 void postProcess(MIResultProducer rp)
          Perform any postprocessing.
 void preProcess(MIResultProducer rp)
          Prepare for the results to be received.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setOutputFile(java.io.File newOutputFile)
          Set the value of OutputFile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_RP

protected MIResultProducer m_RP
The MIResultProducer sending us results


m_OutputFile

protected java.io.File m_OutputFile
The destination output file, null sends to System.out


m_Out

protected transient java.io.PrintWriter m_Out
The destination for results (typically connected to the output file)

Constructor Detail

MICSVResultListener

public MICSVResultListener()
Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing this result listener

Returns:
a description of the result listener suitable for displaying in the explorer/experimenter gui

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options..

Specified by:
listOptions in interface weka.core.OptionHandler
Returns:
an enumeration of all the available options.

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

-O filename
The filename where output will be stored. Use - for stdout. (default stdout)

Specified by:
setOptions in interface weka.core.OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the Classifier.

Specified by:
getOptions in interface weka.core.OptionHandler
Returns:
an array of strings suitable for passing to setOptions

outputFileTipText

public java.lang.String outputFileTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getOutputFile

public java.io.File getOutputFile()
Get the value of OutputFile.

Returns:
Value of OutputFile.

setOutputFile

public void setOutputFile(java.io.File newOutputFile)
Set the value of OutputFile.

Parameters:
newOutputFile - Value to assign to OutputFile.

preProcess

public void preProcess(MIResultProducer rp)
                throws java.lang.Exception
Prepare for the results to be received.

Specified by:
preProcess in interface MIResultListener
Parameters:
rp - the MIResultProducer that will generate the results
Throws:
java.lang.Exception - if an error occurs during preprocessing.

postProcess

public void postProcess(MIResultProducer rp)
                 throws java.lang.Exception
Perform any postprocessing. When this method is called, it indicates that no more results will be sent that need to be grouped together in any way.

Specified by:
postProcess in interface MIResultListener
Parameters:
rp - the MIResultProducer that generated the results
Throws:
java.lang.Exception - if an error occurs

determineColumnConstraints

public java.lang.String[] determineColumnConstraints(MIResultProducer rp)
                                              throws java.lang.Exception
Determines if there are any constraints (imposed by the destination) on the result columns to be produced by resultProducers. Null should be returned if there are NO constraints, otherwise a list of column names should be returned as an array of Strings.

Specified by:
determineColumnConstraints in interface MIResultListener
Parameters:
rp - the MIResultProducer to which the constraints will apply
Returns:
an array of column names to which resutltProducer's results will be restricted.
Throws:
java.lang.Exception - if an error occurs.

acceptResult

public void acceptResult(MIResultProducer rp,
                         java.lang.Object[] key,
                         java.lang.Object[] result)
                  throws java.lang.Exception
Just prints out each result as it is received.

Specified by:
acceptResult in interface MIResultListener
Parameters:
rp - the MIResultProducer that generated the result
key - The key for the results.
result - The actual results.
Throws:
java.lang.Exception - if the result could not be accepted.

isResultRequired

public boolean isResultRequired(MIResultProducer rp,
                                java.lang.Object[] key)
                         throws java.lang.Exception
Always says a result is required. If this is the first call, prints out the header for the csv output.

Specified by:
isResultRequired in interface MIResultListener
Parameters:
rp - the MIResultProducer wanting to generate the result
key - The key for which a result may be needed.
Returns:
true if the result should be calculated.
Throws:
java.lang.Exception - if it could not be determined if the result is needed.