[Solved]Regular Expression in FIlter Example
Hi every,
I have a dataset with an attribute with values d_[number], i_[number] , p_[number],
I'd like to know how I can use regular expression in filtering examples, and how I can parse numbers out of values of an attribute,
So I will be able to filter those examples which start with d_ and parse the number in this value,
I'd be happy if you could help me,
Thanks ,
Arian
I have a dataset with an attribute with values d_[number], i_[number] , p_[number],
I'd like to know how I can use regular expression in filtering examples, and how I can parse numbers out of values of an attribute,
So I will be able to filter those examples which start with d_ and parse the number in this value,
I'd be happy if you could help me,
Thanks ,
Arian
Tagged:
0
Answers
-
Hi Arian,
here you go! The first two operators are just to prepare the data.
Best, Marius<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.000" expanded="true" name="Process">
<process expanded="true" height="116" width="681">
<operator activated="true" class="generate_nominal_data" compatibility="5.3.000" expanded="true" height="60" name="Generate Nominal Data" width="90" x="45" y="30"/>
<operator activated="true" breakpoints="after" class="replace" compatibility="5.3.000" expanded="true" height="76" name="Replace (2)" width="90" x="179" y="30">
<parameter key="replace_what" value="value(\d+)"/>
<parameter key="replace_by" value="p_$1"/>
</operator>
<operator activated="true" class="filter_examples" compatibility="5.3.000" expanded="true" height="76" name="Filter Examples" width="90" x="313" y="30">
<parameter key="condition_class" value="attribute_value_filter"/>
<parameter key="parameter_string" value="att1=.*_\d"/>
</operator>
<operator activated="true" class="replace" compatibility="5.3.000" expanded="true" height="76" name="Replace" width="90" x="447" y="30">
<parameter key="replace_what" value="p_(\d+)"/>
<parameter key="replace_by" value="$1"/>
</operator>
<operator activated="true" class="parse_numbers" compatibility="5.3.000" expanded="true" height="76" name="Parse Numbers" width="90" x="581" y="30"/>
<connect from_op="Generate Nominal Data" from_port="output" to_op="Replace (2)" to_port="example set input"/>
<connect from_op="Replace (2)" from_port="example set output" to_op="Filter Examples" to_port="example set input"/>
<connect from_op="Filter Examples" from_port="example set output" to_op="Replace" to_port="example set input"/>
<connect from_op="Replace" from_port="example set output" to_op="Parse Numbers" to_port="example set input"/>
<connect from_op="Parse Numbers" from_port="example set output" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>0 -
Thanks buddy,
It's solved0