Pages: [1]
Author Topic: Creating attributes  (Read 1402 times)
Posts: 3

« on: March 26, 2009, 05:31:31 AM »

I am trying to create an attribute with existing variables containing hyphens.

ex: a-1

However, when I try to use the AttributeConstructor in conjunction with this variable name, it misinterprets this as the variable a (nonexistent) subtracted by 1.

I have worked around this by using the Attribute renaming facility, however this is proving cumbersome as 120 of my 154 variables contain hyphens.

Is there an easier way to encapsulate a variable name containing ambiguous characters such as the hyphen?


- Pat
Ingo Mierswa
Hero Member
Posts: 1238

« Reply #1 on: March 26, 2009, 09:56:42 AM »

Hello Pat,

in RM 4.4 there is a new operator called "ChangeAttributeNamesReplace" which can be used to replace all non-word characters (regular expression for replace_what is '\W') by an empty string or for example an underscore (replace_by could be "_"). If you apply this operator to all attributes (regular expression for the attribute names parameter would be ".*") then you end up with attribute names which can be used by the AttributeConstruction operator.

Hope that helps,

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at
Hero Member
Posts: 887

« Reply #2 on: March 26, 2009, 10:08:40 AM »

Just like this...

<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
        <parameter key="number_examples" value="200"/>
        <parameter key="number_of_attributes" value="2"/>
        <parameter key="target_function" value="random"/>
    <operator name="ChangeAttributeName" class="ChangeAttributeName">
        <parameter key="new_name" value="X-1"/>
        <parameter key="old_name" value="att1"/>
    <operator name="ChangeAttributeNamesReplace" class="ChangeAttributeNamesReplace">
        <parameter key="apply_on_special" value="false"/>
        <parameter key="attributes" value="X.*"/>
        <parameter key="replace_by" value="_"/>
        <parameter key="replace_what" value="\-"/>

Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?

T.S.Eliot ~ Choruses from the Rock 1934
Pages: [1]
Jump to: