Creating attributes
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?
Thanks,
- Pat
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?
Thanks,
- Pat
Tagged:
0
Answers
-
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,
Ingo0 -
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>
<operator name="ChangeAttributeName" class="ChangeAttributeName">
<parameter key="new_name" value="X-1"/>
<parameter key="old_name" value="att1"/>
</operator>
<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="\-"/>
</operator>
</operator>0