"rapidminer and java setlistparameter"

platanas20
platanas20 New Altair Community Member
edited November 5 in Community Q&A
Hello to everyone,
I want to create in java a project using rapidminer libraries.What i want to do is to add the operator "process documents from files" , but i dont know how to use the method setlistparameter to add my directories.
The code in xml is this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.008">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process">
    <parameter key="encoding" value="UTF-8"/>
    <parameter key="parallelize_main_process" value="true"/>
    <process expanded="true" height="510" width="791">
      <operator activated="true" class="text:process_document_from_file" compatibility="5.1.002" expanded="true" height="76" name="Process Documents from Files" width="90" x="112" y="120">
        <list key="text_directories">
          <parameter key="P" value="H:\Epifaneia Ergasias\RapidMiner\Positive"/>
          <parameter key="N" value="H:\Epifaneia Ergasias\RapidMiner\Negative"/>
        </list>
        <parameter key="encoding" value="UTF-8"/>
        <parameter key="parallelize_vector_creation" value="true"/>
        <process expanded="true" height="528" width="809">
          <operator activated="true" class="text:tokenize" compatibility="5.1.002" expanded="true" height="60" name="Tokenize" width="90" x="45" y="30"/>
          <operator activated="true" class="text:stem_porter" compatibility="5.1.002" expanded="true" height="60" name="Stem (Porter)" width="90" x="313" y="30"/>
          <connect from_port="document" to_op="Tokenize" to_port="document"/>
          <connect from_op="Tokenize" from_port="document" to_op="Stem (Porter)" to_port="document"/>
          <connect from_op="Stem (Porter)" from_port="document" to_port="document 1"/>
          <portSpacing port="source_document" spacing="0"/>
          <portSpacing port="sink_document 1" spacing="0"/>
          <portSpacing port="sink_document 2" spacing="0"/>
        </process>
      </operator>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
    </process>
  </operator>
</process>
How can i convert in java this part of xml "<list key="text_directories">
          <parameter key="P" value="H:\Epifaneia Ergasias\RapidMiner\Positive"/>
          <parameter key="N" value="H:\Epifaneia Ergasias\RapidMiner\Negative"/>
          </list>"?


thanks
platanas
Tagged:

Answers

  • colo
    colo New Altair Community Member
    Hi platanas,

    unfortunately I don't have the time to test this right now, but perhaps this piece of code, that I used to set list parameters some time ago, will also help you to find the solution. This was used for "Cut Documents", but I guess in your case it should be rather similar (maybe using other types).

    List<String[]> extractionExpressionList = new ArrayList<String[]>();
    String[] extractionExpressions = {"Expression_Results", regex};
    extractionExpressionList.add(extractionExpressions);

    extractionOperator.setParameter("query_type", Integer.toString(QueryService.MODE_REGULAR_EXPRESSION));
    extractionOperator.setListParameter(QueryService.PARAMETER_REGEX_QUERIES, extractionExpressionList);
    Regards
    Matthias