Class CSVResultListener

java.lang.Object
weka.experiment.CSVResultListener
All Implemented Interfaces:
Serializable, OptionHandler, RevisionHandler, ResultListener
Direct Known Subclasses:
InstancesResultListener

public class CSVResultListener extends Object implements ResultListener, OptionHandler, RevisionHandler
Takes results from a result producer and assembles them into comma separated value form.

Valid options are:

 -O <file name>
  The filename where output will be stored. Use - for stdout.
  (default temp file)
 
Version:
$Revision: 11690 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)
See Also:
  • Constructor Details

    • CSVResultListener

      public CSVResultListener()
      Sets temporary file.
  • Method Details

    • globalInfo

      public 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 Enumeration<Option> listOptions()
      Returns an enumeration describing the available options..
      Specified by:
      listOptions in interface OptionHandler
      Returns:
      an enumeration of all the available options.
    • setOptions

      public void setOptions(String[] options) throws Exception
      Parses a given list of options.

      Valid options are:

       -O <file name>
        The filename where output will be stored. Use - for stdout.
        (default temp file)
       
      Specified by:
      setOptions in interface OptionHandler
      Parameters:
      options - the list of options as an array of strings
      Throws:
      Exception - if an option is not supported
    • getOptions

      public String[] getOptions()
      Gets the current settings of the Classifier.
      Specified by:
      getOptions in interface OptionHandler
      Returns:
      an array of strings suitable for passing to setOptions
    • outputFileTipText

      public String outputFileTipText()
      Returns the tip text for this property
      Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getOutputFile

      Get the value of OutputFile.
      Returns:
      Value of OutputFile.
    • setOutputFile

      public void setOutputFile(File newOutputFile)
      Set the value of OutputFile. Also sets the OutputFileName.
      Parameters:
      newOutputFile - Value to assign to OutputFile.
    • outputFileName

      public String outputFileName()
      Get the value of OutputFileName.
      Returns:
      Value of OutputFile.
    • setOutputFileName

      public void setOutputFileName(String name)
      Set the value of OutputFileName. Must be used AFTER setOutputFile.
      Parameters:
      name - the name of OutputFile.
    • preProcess

      public void preProcess(ResultProducer rp) throws Exception
      Prepare for the results to be received.
      Specified by:
      preProcess in interface ResultListener
      Parameters:
      rp - the ResultProducer that will generate the results
      Throws:
      Exception - if an error occurs during preprocessing.
    • postProcess

      public void postProcess(ResultProducer rp) throws 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 ResultListener
      Parameters:
      rp - the ResultProducer that generated the results
      Throws:
      Exception - if an error occurs
    • determineColumnConstraints

      public String[] determineColumnConstraints(ResultProducer rp) throws 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 ResultListener
      Parameters:
      rp - the ResultProducer to which the constraints will apply
      Returns:
      an array of column names to which resutltProducer's results will be restricted.
      Throws:
      Exception - if an error occurs.
    • acceptResult

      public void acceptResult(ResultProducer rp, Object[] key, Object[] result) throws Exception
      Just prints out each result as it is received.
      Specified by:
      acceptResult in interface ResultListener
      Parameters:
      rp - the ResultProducer that generated the result
      key - The key for the results.
      result - The actual results.
      Throws:
      Exception - if the result could not be accepted.
    • isResultRequired

      public boolean isResultRequired(ResultProducer rp, Object[] key) throws 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 ResultListener
      Parameters:
      rp - the ResultProducer wanting to generate the result
      key - The key for which a result may be needed.
      Returns:
      true if the result should be calculated.
      Throws:
      Exception - if it could not be determined if the result is needed.
    • getRevision

      public String getRevision()
      Returns the revision string.
      Specified by:
      getRevision in interface RevisionHandler
      Returns:
      the revision