Package weka.filters
Class RenameRelation
- java.lang.Object
-
- weka.filters.Filter
-
- weka.filters.RenameRelation
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RenameRelation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CapabilitiesgetCapabilities()Returns the Capabilities of this filter.java.lang.StringgetModificationText()Get the modification text to applyweka.filters.RenameRelation.ModTypegetModType()Get the modification type to applyjava.lang.StringgetRegexMatch()Get the match string for regex modificationsbooleangetReplaceAll()Get whether to replace all regular expression matches, or just the first.java.lang.StringgetRevision()Returns the revision string.java.lang.StringglobalInfo()Returns a string describing this filterbooleaninput(Instance instance)Input an instance for filtering.static voidmain(java.lang.String[] argv)Main method for testing this class.booleansetInputFormat(Instances instanceInfo)Sets the format of the input instances.voidsetModificationText(java.lang.String text)Set the modification text to applyvoidsetModType(weka.filters.RenameRelation.ModType mod)Set the modification type to applyvoidsetRegexMatch(java.lang.String match)Set the match string for regex modificationsvoidsetReplaceAll(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
-
-
-
-
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:
getCapabilitiesin interfaceCapabilitiesHandler- Overrides:
getCapabilitiesin classFilter- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
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(java.lang.String text)
Set the modification text to apply- Parameters:
text- the text to apply
-
getModificationText
public java.lang.String 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(java.lang.String match)
Set the match string for regex modifications- Parameters:
match- the regular expression to apply for matching
-
getRegexMatch
public java.lang.String 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
public boolean setInputFormat(Instances instanceInfo) throws java.lang.Exception
Sets the format of the input instances.- Overrides:
setInputFormatin 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:
java.lang.Exception- if something goes wrong
-
input
public boolean input(Instance instance)
Description copied from class:FilterInput 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
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classFilter- Returns:
- the revision
-
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
-
-