Categories

Versions

Replace (In Database) (In-Database Processing)

Synopsis

This operator replaces parts of the values of nominal attributes.

Description

This operator replaces parts of the string values of all nominal attributes it is applied on. The attribute filter type gives the possibility to restrict them. For each value of each attribute it is checked if the regular expression of replace what matches the string. Each matching part of the string will be replaced by the value of the replace_what parameter. The replacement might be empty and can contain capturing groups.

Please keep in mind that certain databases may not support regular expressions, in that case a design-time warning will appear if special characters are used. Also note that regular expressions may differ between different database engines. Please consult the documentation of your database regarding more complicated examples.

Note that the output data type for the columns with replaced values may depend on your database (e.g. LONGTEXT in case of MySQL that becomes Text in RapidMiner). In other cases, the replace expression may cause that the value becomes too large for the default return data type, in which case the result may be erroneous (e.g. max 4000 characters in Oracle).

Examples The attribute contains the values "color red", "color green" and "color blue".

  • replacing "color" by "" yields: " red", " green", " blue"
  • replacing "color" by "colour" yields: "colour red", "colour green", "colour blue"
  • replacing "color\s" by "" yields: "red", "green", "blue"
  • replacing "\s+" by "_" yields: "color_red", "color_green", "color_blue"

Input

  • example set input

Output

  • example set output

Parameters

  • attribute filter type The condition specifies which attributes are selected or affected by this operator.
  • attribute The attribute which should be chosen.
  • attributes The attribute which should be chosen.
  • regular expression A regular expression for the names of the attributes which should be kept.
  • use except expression If enabled, an exception to the specified regular expression might be specified. Attributes of matching this will be filtered out, although matching the first expression.
  • except regular expression A regular expression for the names of the attributes which should be filtered out although matching the above regular expression.
  • value type The value type of the attributes.
  • use value type exception If enabled, an exception to the specified value type might be specified. Attributes of this type will be filtered out, although matching the first specified type.
  • except value type Except this value type.
  • block type The block type of the attributes.
  • use block type exception If enabled, an exception to the specified block type might be specified.
  • except block type Except this block type.
  • numeric condition Parameter string for the condition, e.g. '>= 5'
  • invert selection Indicates if only attributes should be accepted which would normally filtered.
  • replace what A regular expression specifying what should be replaced.
  • replace by The replacement for the region matched by the regular expression. Possibly including capturing groups.