The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Execute script Operator include many .java files

mmaragmmarag Member Posts: 35 Maven
edited June 2019 in Help
Hello,

I have a project in java that is consisted of 4 .java files 1 main.java and 3 others within a package called cs.nlp.module.

In the execute operator I have included the code of main.java but I cannot figure out how to include the other files.

import cs.nlp.module.File1; etc. does not seem to work.

I even try to put the files right in the lib folder of RM but no success.

Any help is highly appreciated

With regards
MM

Best Answer

Answers

  • mmaragmmarag Member Posts: 35 Maven
    thank you, I have compiled everything to a jar. Placed the jar in lib folder of rapidminer. 

    I have created a draft process to test it but I get a java.lang.ArrayIndexOutOfBoundsException of a function within this jar.

    here is the process
    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.0.002" expanded="true" name="Process" origin="GENERATED_TUTORIAL">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document" width="90" x="179" y="136">
            <parameter key="text" value="Αυτό είναι ένα μικρό παράδειγμα ανάλυσης κειμένου."/>
            <parameter key="add label" value="false"/>
            <parameter key="label_type" value="nominal"/>
          </operator>
          <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="313" y="289">
            <parameter key="text_attribute" value="Input"/>
            <parameter key="add_meta_information" value="true"/>
            <parameter key="datamanagement" value="double_sparse_array"/>
            <parameter key="data_management" value="auto"/>
          </operator>
          <operator activated="true" class="execute_script" compatibility="9.2.001" expanded="true" height="82" name="Execute Script (2)" origin="GENERATED_TUTORIAL" width="90" x="447" y="187">
            <parameter key="script" value="import com.rapidminer.tools.Ontology&#10;&#10;import java.io.File;&#10;import java.io.FileNotFoundException;&#10;import java.io.FileOutputStream;&#10;import java.io.IOException;&#10;import java.io.OutputStream;&#10;import java.io.PrintStream;&#10;import java.io.BufferedReader;&#10;import java.io.DataInputStream;&#10;import java.io.FileInputStream;&#10;import java.io.InputStreamReader;&#10;import java.util.ArrayList;&#10;import java.util.Vector;&#10;import java.util.HashMap;&#10;import java.util.Iterator;&#10;import java.util.StringTokenizer;&#10;import java.util.logging.Level;&#10;import java.util.logging.Logger;&#10;&#10;import gr.aueb.cs.nlp.postagger.SmallSetFunctions;&#10;import gr.aueb.cs.nlp.postagger.BigSetFunctions;&#10;import gr.aueb.cs.nlp.postagger.WordWithCategory;&#10;import java.util.List;&#10;&#10;&#10;&#10;ExampleSet exampleSet = operator.getInput(ExampleSet.class);&#13;&#10;Attributes attributes = exampleSet.getAttributes();&#10;Attribute att1 = attributes.get(&quot;Input&quot;);&#10;Attribute Output = AttributeFactory.createAttribute(&quot;Output&quot;, Ontology.STRING);&#10;attributes.addRegular(Output);&#10;exampleSet.getExampleTable().addAttribute(Output);&#10;&#10;        for (Example example : exampleSet) {&#10;            String tempText = example.getNominalValue(att1);&#10;            //String manolis=&quot;&quot;;&#10;&#9;&#9;  //start POS&#10;&#9;&#9;  List&lt;WordWithCategory&gt; list = null;&#10;&#9;&#9;  list = SmallSetFunctions.smallSetClassifyString(&quot;Αυτό είναι ένα μικρό παράδειγμα ανάλυσης κειμένου.&quot;);&#10;            //list = BigSetFunctions.bigSetClassifyString(&quot;tempText&quot;);&#10;            for (int i = 0; i &lt; list.size(); i++)&#10;               {&#10;                 //manolis=manolis + &quot; &quot; + list.get(i).toString();&#10;                 System.out.println(list.get(i).toString());&#10;               }&#10;&#9;&#9;  //end POS&#10;&#10;&#10;           &#10;            example.setValue(Output, tempText.toUpperCase());&#10;        }&#10;&#10;        //exampleSetOutput.deliver(exampleSet);&#10;return exampleSet;"/>
            <parameter key="standard_imports" value="true"/>
          </operator>
          <connect from_op="Create Document" from_port="output" to_op="Documents to Data" to_port="documents 1"/>
          <connect from_op="Documents to Data" from_port="example set" to_op="Execute Script (2)" to_port="input 1"/>
          <connect from_op="Execute Script (2)" from_port="output 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="90"/>
        </process>
      </operator>
    </process>


    and here: https://www.dropbox.com/s/r769u6323z1fxa0/TestPOS.zip?dl=0 
     you can find a Netbeans project I made to test if my jar works that works pretty fine.

    Any help would be highly appreciated!


  • mmaragmmarag Member Posts: 35 Maven
    Some update. I ran RM from script and from the exe and I get two different types of error messages


    regards
    mmarag
Sign In or Register to comment.