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 Details

    • RenameRelation

      public RenameRelation()
  • Method Details

    • globalInfo

      public 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:
    • 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

      public 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(String match)
      Set the match string for regex modifications
      Parameters:
      match - the regular expression to apply for matching
    • getRegexMatch

      public 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 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:
      Exception - if something goes wrong
    • input

      public boolean input(Instance instance)
      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.
      Overrides:
      input in class Filter
      Parameters:
      instance - the input instance
      Returns:
      true if the filtered instance may now be collected with output().
    • getRevision

      public 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(String[] argv)
      Main method for testing this class.
      Parameters:
      argv - should contain arguments to the filter: use -h for help