RapidMiner:将属性拆分为字节

时间:2016-10-22 08:36:59

标签: split rapidminer

我有一个带有ASCII字符串形式属性的数据集,其中的字符有其自己的含义(例如,给定“L2A”,“L”,“2”和“A”各自代表不同的东西)

如何将此字符串拆分为其组成字符?我知道“拆分”,但我不确定如何在没有除界时使用它。

1 个答案:

答案 0 :(得分:0)

如果source属性的长度始终相同,那么您可以使用Generate Attributes运算符将字符串剪切成碎片。

以下是一个例子。

<?xml version="1.0" encoding="UTF-8"?><process version="7.2.003">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.2.003" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="generate_data_user_specification" compatibility="7.2.003" expanded="true" height="68" name="Generate Data by User Specification" width="90" x="179" y="85">
    <list key="attribute_values">
      <parameter key="s1" value="&quot;ABC&quot;"/>
    </list>
    <list key="set_additional_roles"/>
      </operator>
      <operator activated="true" class="generate_data_user_specification" compatibility="7.2.003" expanded="true" height="68" name="Generate Data by User Specification (2)" width="90" x="179" y="187">
    <list key="attribute_values">
      <parameter key="s1" value="&quot;DEF&quot;"/>
    </list>
    <list key="set_additional_roles"/>
      </operator>
      <operator activated="true" class="append" compatibility="7.2.003" expanded="true" height="103" name="Append" width="90" x="380" y="85"/>
      <operator activated="true" class="generate_attributes" compatibility="7.2.003" expanded="true" height="82" name="Generate Attributes" width="90" x="514" y="85">
    <list key="function_descriptions">
      <parameter key="att1" value="cut(s1, 0, 1)"/>
      <parameter key="att2" value="cut(s1, 1, 1)"/>
      <parameter key="att3" value="cut(s1,2,1)"/>
    </list>
      </operator>
      <connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
      <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 2"/>
      <connect from_op="Append" from_port="merged set" to_op="Generate Attributes" to_port="example set input"/>
      <connect from_op="Generate Attributes" 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>

如果长度不同,那么这是一个更难的问题