Class RenameAttribute
java.lang.Object
weka.filters.Filter
weka.filters.SimpleFilter
weka.filters.SimpleStreamFilter
weka.filters.unsupervised.attribute.RenameAttribute
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
,StreamableFilter
public class RenameAttribute
extends SimpleStreamFilter
implements WeightedInstancesHandler, WeightedAttributesHandler
This filter is used for renaming attributes.
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:
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 <string> The string to replace the regular expression of matching attributes with. Cannot be used in conjunction with '-remove'. (default: $0)
-remove In case the matching string needs to be removed instead of replaced. Cannot be used in conjunction with '-replace <string>'. (default: off)
-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: 14508 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the tip text for this property.Returns the tip text for this property.Gets the current range selection.Returns the Capabilities of this filter.getFind()
Returns the current regular expression for .boolean
Gets whether to invert the selection of the attributes.String[]
Gets the current settings of the filter.Returns the regular expression to replace matching attribute names with.boolean
Returns whether all occurrences are replaced or just the first one.Returns the revision string.Returns a string describing this filter.Returns the tip text for this property.Returns an enumeration describing the available options.static void
Main method for executing this filter.Returns the tip text for this property.Returns the tip text for this property.void
setAttributeIndices
(String value) Sets which attributes are to be acted on.void
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
(String[] options) Parses a given list of options.void
setReplace
(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
setInputFormat
Methods inherited from class weka.filters.Filter
batchFilterFile, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
RenameAttribute
public RenameAttribute()
-
-
Method Details
-
globalInfo
Returns a string describing this filter.- Specified by:
globalInfo
in classSimpleFilter
- Returns:
- a description of the filter suitable for displaying in the explorer/experimenter gui
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classFilter
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-find <regexp> The regular expression that the attribute names must match. (default: ([\s\S]+))
-replace <string> The string to replace the regular expression of matching attributes with. Cannot be used in conjunction with '-remove'. (default: $0)
-remove In case the matching string needs to be removed instead of replaced. Cannot be used in conjunction with '-replace <string>'. (default: off)
-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 interfaceOptionHandler
- Overrides:
setOptions
in classFilter
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Gets the current settings of the filter.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classFilter
- Returns:
- an array of strings suitable for passing to setOptions
-
setFind
Sets the regular expression that the attribute names must match.- Parameters:
value
- the regular expression
-
getFind
Returns the current regular expression for .- Returns:
- a string containing a comma separated list of ranges
-
findTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setReplace
Sets the regular expression to replace matching attribute names with.- Parameters:
value
- the regular expression
-
getReplace
Returns the regular expression to replace matching attribute names with.- Returns:
- the regular expression
-
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
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setAttributeIndices
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
Gets the current range selection.- Returns:
- a string containing a comma separated list of ranges
-
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
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCapabilities
Returns the Capabilities of this filter.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classFilter
- Returns:
- the capabilities of this object
- See Also:
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
Main method for executing this filter.- Parameters:
args
- the arguments to the filter: use -h for help
-