weka.filters.unsupervised.attribute

## Class AddUserFields

- java.lang.Object
- - weka.filters.Filter
  - - weka.filters.unsupervised.attribute.AddUserFields

- All Implemented Interfaces:
    java.io.Serializable, CapabilitiesHandler, CapabilitiesIgnorer, CommandlineRunnable, EnvironmentHandler, OptionHandler, RevisionHandler, WeightedAttributesHandler, WeightedInstancesHandler, UnsupervisedFilter

      public class AddUserFields
      extends Filter
      implements OptionHandler, EnvironmentHandler, UnsupervisedFilter, WeightedInstancesHandler, WeightedAttributesHandler

  A filter that adds new attributes with user specified type and constant value. Numeric, nominal, string and date attributes can be created. Attribute name, and value can be set with environment variables. Date attributes can also specify a formatting string by which to parse the supplied date value. Alternatively, a current time stamp can be specified by supplying the special string "now" as the value for a date attribute.

  Valid options are:

       -A <name:type:value>
        New field specification (name@type@value).
         Environment variables may be used for any/all parts of the
        specification. Type can be one of (numeric, nominal, string or date).
        The value for date be a specific date string or the special string
        "now" to indicate the current date-time. A specific date format
        string for parsing specific date values can be specified by suffixing
        the type specification - e.g. "myTime@date:MM-dd-yyyy@08-23-2009".This option may be specified multiple times

  Version:
    $Revision: 14534 $
  Author:
    Mark Hall (mhall{[at]}pentaho{[dot]}com)
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AddUserFields.AttributeSpec` Inner class encapsulating a new user-specified attribute to create.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AddUserFields()` Constructs a new AddUserFields

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttributeSpec(java.lang.String spec)` Add an attribute spec to the list
    `java.lang.String` | `attributeSpecsTipText()` Returns the tip text for this property.
    `void` | `clearAttributeSpecs()` Clear the list of attribute specifications
    `java.util.List<AddUserFields.AttributeSpec>` | `getAttributeSpecs()` Get the list of attribute specs to use to create the new attributes.
    `Capabilities` | `getCapabilities()` Returns the Capabilities of this filter.
    `java.lang.String[]` | `getOptions()` Gets the current settings of the filter
    `java.lang.String` | `globalInfo()` Returns a string describing this filter
    `boolean` | `input(Instance instance)` Input an instance for filtering.
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options.
    `static void` | `main(java.lang.String[] argv)` Main method for testing this class.
    `void` | `setAttributeSpecs(java.util.List<AddUserFields.AttributeSpec> specs)` Set the list of attribute specs to use to create the new attributes.
    `void` | `setEnvironment(Environment env)` Set environment varialbes to use
    `boolean` | `setInputFormat(Instances instanceInfo)` Sets the format of the input instances.
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.

    - ### Methods inherited from class weka.filters.Filter

      `batchFilterFile, batchFinished, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOutputFormat, getRevision, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AddUserFields

          public AddUserFields()

      Constructs a new AddUserFields

  - ### Method Detail

    - #### globalInfo

          public java.lang.String globalInfo()

      Returns a string describing this filter
      Returns:
        a description of the filter suitable for displaying in the explorer/experimenter gui

    - #### getCapabilities

          public Capabilities getCapabilities()

      Returns the Capabilities of this filter.
      Specified by:
        `getCapabilities` in interface `CapabilitiesHandler`
      Overrides:
        `getCapabilities` in class `Filter`
      Returns:
        the capabilities of this object
      See Also:
        `Capabilities`

    - #### clearAttributeSpecs

          public void clearAttributeSpecs()

      Clear the list of attribute specifications

    - #### listOptions

          public java.util.Enumeration<Option> listOptions()

      Returns an enumeration describing the available options.
      Specified by:
        `listOptions` in interface `OptionHandler`
      Overrides:
        `listOptions` in class `Filter`
      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:

      * *

           -A <name:type:value>
           *  New field specification (name@type@value).
           *   Environment variables may be used for any/all parts of the
           *  specification. Type can be one of (numeric, nominal, string or date).
           *  The value for date be a specific date string or the special string
           *  "now" to indicate the current date-time. A specific date format
           *  string for parsing specific date values can be specified by suffixing
           *  the type specification - e.g. "myTime@date:MM-dd-yyyy@08-23-2009".This option may be specified multiple times

      *
      Specified by:
        `setOptions` in interface `OptionHandler`
      Overrides:
        `setOptions` in class `Filter`
      Parameters:
        `options` - the list of options as an array of string
      Throws:
        `java.lang.Exception` - if an option is not supported

    - #### getOptions

          public java.lang.String[] getOptions()

      Gets the current settings of the filter
      Specified by:
        `getOptions` in interface `OptionHandler`
      Overrides:
        `getOptions` in class `Filter`
      Returns:
        an array of strings suitable for passing to setOptions

    - #### addAttributeSpec

          public void addAttributeSpec(java.lang.String spec)

      Add an attribute spec to the list
      Parameters:
        `spec` - the attribute spec to add

    - #### attributeSpecsTipText

          public java.lang.String attributeSpecsTipText()

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

    - #### setAttributeSpecs

          public void setAttributeSpecs(java.util.List<AddUserFields.AttributeSpec> specs)

      Set the list of attribute specs to use to create the new attributes.
      Parameters:
        `specs` - the list of attribute specs to use

    - #### getAttributeSpecs

          public java.util.List<AddUserFields.AttributeSpec> getAttributeSpecs()

      Get the list of attribute specs to use to create the new attributes.
      Returns:
        the list of attribute specs to use

    - #### setEnvironment

          public void setEnvironment(Environment env)

      Set environment varialbes to use
      Specified by:
        `setEnvironment` in interface `EnvironmentHandler`
      Parameters:
        `env` - the environment variables to use

    - #### setInputFormat

          public boolean setInputFormat(Instances instanceInfo)
                                 throws java.lang.Exception

      Sets the format of the input instances.
      Overrides:
        `setInputFormat` in class `Filter`
      Parameters:
        `instanceInfo` - an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).
      Returns:
        true if the outputFormat may be collected immediately
      Throws:
        `java.lang.Exception` - if the input format can't be set successfully

    - #### input

          public boolean input(Instance instance)

      Input an instance for filtering. Ordinarily the instance is processed and made available for output immediately. Some filters require all instances be read before producing output.
      Overrides:
        `input` in class `Filter`
      Parameters:
        `instance` - the input instance
      Returns:
        true if the filtered instance may now be collected with output().
      Throws:
        `java.lang.IllegalStateException` - if no input format has been defined.

    - #### main

          public static void main(java.lang.String[] argv)

      Main method for testing this class.
      Parameters:
        `argv` - should contain arguments to the filter: use -h for help