Package weka.filters

Class CheckSource

java.lang.Object
weka.filters.CheckSource
All Implemented Interfaces:
OptionHandler, RevisionHandler

public class CheckSource extends Object implements OptionHandler, RevisionHandler
A simple class for checking the source generated from Filters implementing the weka.filters.Sourcable interface. It takes a filter, the classname of the generated source and the dataset the source was generated with as parameters and tests the output of the built filter against the output of the generated source. Use option '-h' to display all available commandline options. Valid options are:

 -W <classname and options>
  The filter (incl. options) that was used to generate
  the source code.
 
 -S <classname>
  The classname of the generated source code.
 
 -t <file>
  The training set with which the source code was generated.
 
 -c <index>
  The class index of the training set. 'first' and 'last' are
  valid indices.
  (default: none)
 
Options after -- are passed to the designated filter.

Version:
$Revision: 10210 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
  • Constructor Details

    • CheckSource

      public CheckSource()
  • Method Details

    • 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:

       -W <classname and options>
        The filter (incl. options) that was used to generate
        the source code.
       
       -S <classname>
        The classname of the generated source code.
       
       -t <file>
        The training set with which the source code was generated.
       
       -c <index>
        The class index of the training set. 'first' and 'last' are
        valid indices.
        (default: none)
       
      Options after -- are passed to the designated filter.

      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 filter.
      Specified by:
      getOptions in interface OptionHandler
      Returns:
      an array of strings suitable for passing to setOptions
    • setFilter

      public void setFilter(Filter value)
      Sets the filter to use for the comparison.
      Parameters:
      value - the filter to use
    • getFilter

      public Filter getFilter()
      Gets the filter being used for the tests, can be null.
      Returns:
      the currently set filter
    • setSourceCode

      public void setSourceCode(Filter value)
      Sets the class to test.
      Parameters:
      value - the class to test
    • getSourceCode

      public Filter getSourceCode()
      Gets the class to test.
      Returns:
      the currently set class, can be null.
    • setDataset

      public void setDataset(File value)
      Sets the dataset to use for testing.
      Parameters:
      value - the dataset to use.
    • getDataset

      public File getDataset()
      Gets the dataset to use for testing, can be null.
      Returns:
      the dataset to use.
    • setClassIndex

      public void setClassIndex(int value)
      Sets the class index of the dataset.
      Parameters:
      value - the class index of the dataset.
    • getClassIndex

      public int getClassIndex()
      Gets the class index of the dataset.
      Returns:
      the current class index.
    • execute

      public boolean execute() throws Exception
      performs the comparison test
      Returns:
      true if tests were successful
      Throws:
      Exception - if tests fail
    • getRevision

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

      public static void main(String[] args) throws Exception
      Executes the tests, use "-h" to list the commandline options.
      Parameters:
      args - the commandline parameters
      Throws:
      Exception - if something goes wrong