I want to use a macro inside

Prentice
Prentice New Altair Community Member
edited November 2024 in Community Q&A
I have an Excel sheet where the examples of an attribute can be either upper and lower case. However, I want to filter these out with one filter. I've already seen a thread where you put in the expression "matches(lower(word),"eng.+")", this was to filter out the word english, which could be in the forms of English and english. But my text is variable, now I know that I can use a macro for this. The problem is, I don't know the syntax for it to work inside the expression. I've already tried something like "matches(lower(word),%{Macro_Name})" or "matches(lower(word),".+%{Macro_Name}.+")", but with no succes. Is it even possible to do it this way, or is there another way?

Thanks!

-Prentice

Best Answer

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    Hi,
    have a look at the attached process.
    I'm using
    matches(text,%{prefix}+".+")
    there.

    That should do it.

    BR,
    Martin

    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"><br>  <context><br>    <input/><br>    <output/><br>    <macros/><br>  </context><br>  <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"><br>    <parameter key="logverbosity" value="init"/><br>    <parameter key="random_seed" value="2001"/><br>    <parameter key="send_mail" value="never"/><br>    <parameter key="notification_email" value=""/><br>    <parameter key="process_duration_for_mail" value="30"/><br>    <parameter key="encoding" value="SYSTEM"/><br>    <process expanded="true"><br>      <operator activated="true" class="utility:create_exampleset" compatibility="9.2.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="313" y="85"><br>        <parameter key="generator_type" value="comma separated text"/><br>        <parameter key="number_of_examples" value="100"/><br>        <parameter key="use_stepsize" value="false"/><br>        <list key="function_descriptions"/><br>        <parameter key="add_id_attribute" value="false"/><br>        <list key="numeric_series_configuration"/><br>        <list key="date_series_configuration"/><br>        <list key="date_series_configuration (interval)"/><br>        <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br>        <parameter key="time_zone" value="SYSTEM"/><br>        <parameter key="input_csv_text" value="text&#10;english"/><br>        <parameter key="column_separator" value=","/><br>        <parameter key="parse_all_as_nominal" value="false"/><br>        <parameter key="decimal_point_character" value="."/><br>        <parameter key="trim_attribute_names" value="true"/><br>      </operator><br>      <operator activated="true" class="set_macro" compatibility="9.2.000" expanded="true" height="82" name="Set Macro" width="90" x="447" y="85"><br>        <parameter key="macro" value="prefix"/><br>        <parameter key="value" value="eng"/><br>      </operator><br>      <operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Filter Examples" width="90" x="581" y="85"><br>        <parameter key="parameter_expression" value="matches(text,%{prefix}+&quot;.+&quot;)"/><br>        <parameter key="condition_class" value="expression"/><br>        <parameter key="invert_filter" value="false"/><br>        <list key="filters_list"/><br>        <parameter key="filters_logic_and" value="true"/><br>        <parameter key="filters_check_metadata" value="true"/><br>      </operator><br>      <connect from_op="Create ExampleSet" from_port="output" to_op="Set Macro" to_port="through 1"/><br>      <connect from_op="Set Macro" from_port="through 1" to_op="Filter Examples" to_port="example set input"/><br>      <connect from_op="Filter Examples" from_port="example set output" to_port="result 1"/><br>      <portSpacing port="source_input 1" spacing="0"/><br>      <portSpacing port="sink_result 1" spacing="0"/><br>      <portSpacing port="sink_result 2" spacing="0"/><br>    </process><br>  </operator><br></process><br><br>




Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    Hi,
    have a look at the attached process.
    I'm using
    matches(text,%{prefix}+".+")
    there.

    That should do it.

    BR,
    Martin

    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"><br>  <context><br>    <input/><br>    <output/><br>    <macros/><br>  </context><br>  <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"><br>    <parameter key="logverbosity" value="init"/><br>    <parameter key="random_seed" value="2001"/><br>    <parameter key="send_mail" value="never"/><br>    <parameter key="notification_email" value=""/><br>    <parameter key="process_duration_for_mail" value="30"/><br>    <parameter key="encoding" value="SYSTEM"/><br>    <process expanded="true"><br>      <operator activated="true" class="utility:create_exampleset" compatibility="9.2.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="313" y="85"><br>        <parameter key="generator_type" value="comma separated text"/><br>        <parameter key="number_of_examples" value="100"/><br>        <parameter key="use_stepsize" value="false"/><br>        <list key="function_descriptions"/><br>        <parameter key="add_id_attribute" value="false"/><br>        <list key="numeric_series_configuration"/><br>        <list key="date_series_configuration"/><br>        <list key="date_series_configuration (interval)"/><br>        <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br>        <parameter key="time_zone" value="SYSTEM"/><br>        <parameter key="input_csv_text" value="text&#10;english"/><br>        <parameter key="column_separator" value=","/><br>        <parameter key="parse_all_as_nominal" value="false"/><br>        <parameter key="decimal_point_character" value="."/><br>        <parameter key="trim_attribute_names" value="true"/><br>      </operator><br>      <operator activated="true" class="set_macro" compatibility="9.2.000" expanded="true" height="82" name="Set Macro" width="90" x="447" y="85"><br>        <parameter key="macro" value="prefix"/><br>        <parameter key="value" value="eng"/><br>      </operator><br>      <operator activated="true" class="filter_examples" compatibility="9.2.000" expanded="true" height="103" name="Filter Examples" width="90" x="581" y="85"><br>        <parameter key="parameter_expression" value="matches(text,%{prefix}+&quot;.+&quot;)"/><br>        <parameter key="condition_class" value="expression"/><br>        <parameter key="invert_filter" value="false"/><br>        <list key="filters_list"/><br>        <parameter key="filters_logic_and" value="true"/><br>        <parameter key="filters_check_metadata" value="true"/><br>      </operator><br>      <connect from_op="Create ExampleSet" from_port="output" to_op="Set Macro" to_port="through 1"/><br>      <connect from_op="Set Macro" from_port="through 1" to_op="Filter Examples" to_port="example set input"/><br>      <connect from_op="Filter Examples" from_port="example set output" to_port="result 1"/><br>      <portSpacing port="source_input 1" spacing="0"/><br>      <portSpacing port="sink_result 1" spacing="0"/><br>      <portSpacing port="sink_result 2" spacing="0"/><br>    </process><br>  </operator><br></process><br><br>




  • Prentice
    Prentice New Altair Community Member
    This worked, thanks a lot