weka.filters.unsupervised.attribute
Class RenameAttribute

java.lang.Object
  extended by weka.filters.Filter
      extended by weka.filters.SimpleFilter
          extended by weka.filters.SimpleStreamFilter
              extended by weka.filters.unsupervised.attribute.RenameAttribute
All Implemented Interfaces:
java.io.Serializable, CapabilitiesHandler, OptionHandler, RevisionHandler, StreamableFilter

public class RenameAttribute
extends SimpleStreamFilter

This filter is used for renaming attribute names.
Regular expressions can be used in the matching and replacing.
See Javadoc of java.util.regex.Pattern class for more information:
http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html

Valid options are:

 -find <regexp>
  The regular expression that the attribute names must match.
  (default: ([\s\S]+))
 -replace <regexp>
  The regular expression to replace matching attributes with.
  (default: $0)
 -all
  Replaces all occurrences instead of just the first.
  (default: only first occurrence)
 -R <range>
  The attribute range to work on.
 This is a comma separated list of attribute indices, with "first" and "last" valid values.
  Specify an inclusive range with "-".
  E.g: "first-3,5,6-10,last".
  (default: first-last)
 -V
  Inverts the attribute selection range.
  (default: off)

Version:
$Revision: 6108 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Constructor Summary
RenameAttribute()
           
 
Method Summary
 java.lang.String attributeIndicesTipText()
          Returns the tip text for this property.
 java.lang.String findTipText()
          Returns the tip text for this property.
 java.lang.String getAttributeIndices()
          Gets the current range selection.
 Capabilities getCapabilities()
          Returns the Capabilities of this filter.
 java.lang.String getFind()
          Returns the current regular expression for .
 boolean getInvertSelection()
          Gets whether to invert the selection of the attributes.
 java.lang.String[] getOptions()
          Gets the current settings of the filter.
 java.lang.String getReplace()
          Returns the regular expression to replace matching attribute names with.
 boolean getReplaceAll()
          Returns whether all occurrences are replaced or just the first one.
 java.lang.String getRevision()
          Returns the revision string.
 java.lang.String globalInfo()
          Returns a string describing this filter.
 java.lang.String invertSelectionTipText()
          Returns the tip text for this property.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] args)
          Main method for executing this filter.
 java.lang.String replaceAllTipText()
          Returns the tip text for this property.
 java.lang.String replaceTipText()
          Returns the tip text for this property.
 void setAttributeIndices(java.lang.String value)
          Sets which attributes are to be acted on.
 void setFind(java.lang.String value)
          Sets the regular expression that the attribute names must match.
 void setInvertSelection(boolean value)
          Sets whether to invert the selection of the attributes.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setReplace(java.lang.String value)
          Sets the regular expression to replace matching attribute names with.
 void setReplaceAll(boolean value)
          Sets whether to replace all occurrences or just the first one.
 
Methods inherited from class weka.filters.SimpleStreamFilter
batchFinished, input
 
Methods inherited from class weka.filters.SimpleFilter
debugTipText, getDebug, setDebug, setInputFormat
 
Methods inherited from class weka.filters.Filter
batchFilterFile, filterFile, getCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputPeek, toString, useFilter, wekaStaticWrapper
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenameAttribute

public RenameAttribute()
Method Detail

globalInfo

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

Specified by:
globalInfo in class SimpleFilter
Returns:
a description of the filter 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 OptionHandler
Overrides:
listOptions in class SimpleFilter
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:

 -find <regexp>
  The regular expression that the attribute names must match.
  (default: ([\s\S]+))
 -replace <regexp>
  The regular expression to replace matching attributes with.
  (default: $0)
 -all
  Replaces all occurrences instead of just the first.
  (default: only first occurrence)
 -R <range>
  The attribute range to work on.
 This is a comma separated list of attribute indices, with "first" and "last" valid values.
  Specify an inclusive range with "-".
  E.g: "first-3,5,6-10,last".
  (default: first-last)
 -V
  Inverts the attribute selection range.
  (default: off)

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class SimpleFilter
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
See Also:
SimpleFilter.reset()

getOptions

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

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class SimpleFilter
Returns:
an array of strings suitable for passing to setOptions

setFind

public void setFind(java.lang.String value)
Sets the regular expression that the attribute names must match.

Parameters:
value - the regular expression

getFind

public java.lang.String getFind()
Returns the current regular expression for .

Returns:
a string containing a comma separated list of ranges

findTipText

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

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

setReplace

public void setReplace(java.lang.String value)
Sets the regular expression to replace matching attribute names with.

Parameters:
value - the regular expression

getReplace

public java.lang.String getReplace()
Returns the regular expression to replace matching attribute names with.

Returns:
the regular expression

replaceTipText

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

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

setReplaceAll

public void setReplaceAll(boolean value)
Sets whether to replace all occurrences or just the first one.

Parameters:
value - if true then all occurrences are replace

getReplaceAll

public boolean getReplaceAll()
Returns whether all occurrences are replaced or just the first one.

Returns:
true if all occurrences are replaced

replaceAllTipText

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

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

setAttributeIndices

public void setAttributeIndices(java.lang.String value)
Sets which attributes are to be acted on.

Parameters:
value - a string representing the list of attributes. Since the string will typically come from a user, attributes are indexed from1.
eg: first-3,5,6-last

getAttributeIndices

public java.lang.String getAttributeIndices()
Gets the current range selection.

Returns:
a string containing a comma separated list of ranges

attributeIndicesTipText

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

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

setInvertSelection

public void setInvertSelection(boolean value)
Sets whether to invert the selection of the attributes.

Parameters:
value - if true then the selection is inverted

getInvertSelection

public boolean getInvertSelection()
Gets whether to invert the selection of the attributes.

Returns:
true if the selection is inverted

invertSelectionTipText

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

Returns:
tip text for this property 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

getRevision

public java.lang.String getRevision()
Returns the revision string.

Specified by:
getRevision in interface RevisionHandler
Overrides:
getRevision in class Filter
Returns:
the revision

main

public static void main(java.lang.String[] args)
Main method for executing this filter.

Parameters:
args - the arguments to the filter: use -h for help