Package weka.filters
Class RenameRelation
java.lang.Object
weka.filters.Filter
weka.filters.RenameRelation
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,WeightedAttributesHandler
,WeightedInstancesHandler
,StreamableFilter
public class RenameRelation
extends Filter
implements StreamableFilter, WeightedAttributesHandler, WeightedInstancesHandler
A simple filter that allows the relation name of a set of instances to be
altered in various ways.
- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the Capabilities of this filter.Get the modification text to applyweka.filters.RenameRelation.ModType
Get the modification type to applyGet the match string for regex modificationsboolean
Get whether to replace all regular expression matches, or just the first.Returns the revision string.Returns a string describing this filterboolean
Input an instance for filtering.static void
Main method for testing this class.boolean
setInputFormat
(Instances instanceInfo) Sets the format of the input instances.void
setModificationText
(String text) Set the modification text to applyvoid
setModType
(weka.filters.RenameRelation.ModType mod) Set the modification type to applyvoid
setRegexMatch
(String match) Set the match string for regex modificationsvoid
setReplaceAll
(boolean replaceAll) Set whether to replace all regular expression matches, or just the first.Methods inherited from class weka.filters.Filter
batchFilterFile, batchFinished, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOptions, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, listOptions, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, setOptions, toString, useFilter, wekaStaticWrapper
-
Constructor Details
-
RenameRelation
public RenameRelation()
-
-
Method Details
-
globalInfo
Returns a string describing this filter- Returns:
- a description of the filter 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:
-
setModificationText
@OptionMetadata(displayName="Text to use", description="The text to modify the relation name with", commandLineParamName="modify", commandLineParamSynopsis="-modify <string>", displayOrder=0) public void setModificationText(String text) Set the modification text to apply- Parameters:
text
- the text to apply
-
getModificationText
Get the modification text to apply- Returns:
- the modification text
-
setModType
@OptionMetadata(displayName="Relation name modification type", description="The type of modification to apply (default = REPLACE)", commandLineParamName="mod-type", commandLineParamSynopsis="-mod-type <REPLACE | PREPEND | APPEND | REGEX>", displayOrder=1) public void setModType(weka.filters.RenameRelation.ModType mod) Set the modification type to apply- Parameters:
mod
- the modification type to apply
-
getModType
public weka.filters.RenameRelation.ModType getModType()Get the modification type to apply- Returns:
- the modification type to apply
-
setRegexMatch
@OptionMetadata(displayName="Regular expression", description="Regular expression to use for matching when performing a REGEX modification (default = ([\\s\\S]+))", commandLineParamName="find", commandLineParamSynopsis="-find <pattern>", displayOrder=2) public void setRegexMatch(String match) Set the match string for regex modifications- Parameters:
match
- the regular expression to apply for matching
-
getRegexMatch
Get the match string for regex modifications- Returns:
- the regular expression to apply for matching
-
setReplaceAll
@OptionMetadata(displayName="Replace all regex matches", description="Replace all matching occurrences if set to true, or just the first match if set to false", commandLineParamName="replace-all", commandLineParamSynopsis="-replace-all", commandLineParamIsFlag=true, displayOrder=3) public void setReplaceAll(boolean replaceAll) Set whether to replace all regular expression matches, or just the first.- Parameters:
replaceAll
- true to replace all regex matches
-
getReplaceAll
public boolean getReplaceAll()Get whether to replace all regular expression matches, or just the first.- Returns:
- true to replace all regex matches
-
setInputFormat
Sets the format of the input instances.- Overrides:
setInputFormat
in classFilter
- 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:
Exception
- if something goes wrong
-
input
Description copied from class:Filter
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, in which case output instances should be collected after calling batchFinished(). If the input marks the start of a new batch, the output queue is cleared. This default implementation assumes all instance conversion will occur when batchFinished() is called. -
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classFilter
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv
- should contain arguments to the filter: use -h for help
-