🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

[NullPointerException] Text classification problem

User: "Duha"
New Altair Community Member
Updated by Jocelyn
Hi!

I'm trying to apply the code from https://blog.codecentric.de/en/2013/03/java-based-machine-learning-by-classification/ on my process which tests the classification of Arabic texts. I made the training and testing in two separate processes. Now I only need the testing process.
Here's the XML
<?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">
    <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" height="414" width="762">
      <operator activated="true" class="retrieve" compatibility="5.3.000" expanded="true" height="60" name="Retrieve" width="90" x="112" y="75">
        <parameter key="repository_entry" value="wordlistAr"/>
      </operator>
      <operator activated="true" class="text:process_document_from_file" compatibility="5.3.002" expanded="true" height="76" name="Process Documents from Files" width="90" x="246" y="30">
        <list key="text_directories">
          <parameter key="أخبار" value="C:\Users\WINDOWS 7\Desktop\rapid2\AraTest\New folder"/>
        </list>
        <parameter key="file_pattern" value="*"/>
        <parameter key="extract_text_only" value="true"/>
        <parameter key="use_file_extension_as_type" value="true"/>
        <parameter key="content_type" value="txt"/>
        <parameter key="encoding" value="SYSTEM"/>
        <parameter key="create_word_vector" value="true"/>
        <parameter key="vector_creation" value="TF-IDF"/>
        <parameter key="add_meta_information" value="true"/>
        <parameter key="keep_text" value="false"/>
        <parameter key="prune_method" value="none"/>
        <parameter key="prune_below_percent" value="3.0"/>
        <parameter key="prune_above_percent" value="30.0"/>
        <parameter key="prune_below_rank" value="0.05"/>
        <parameter key="prune_above_rank" value="0.95"/>
        <parameter key="datamanagement" value="double_sparse_array"/>
        <process expanded="true" height="414" width="762">
          <operator activated="true" class="text:tokenize" compatibility="5.3.002" expanded="true" height="60" name="Tokenize" width="90" x="45" y="30">
            <parameter key="mode" value="non letters"/>
            <parameter key="characters" value=".:"/>
            <parameter key="language" value="English"/>
            <parameter key="max_token_length" value="3"/>
          </operator>
          <operator activated="true" class="text:filter_stopwords_arabic" compatibility="5.3.002" expanded="true" height="60" name="Filter Stopwords (Arabic)" width="90" x="45" y="165"/>
          <operator activated="true" class="text:generate_n_grams_terms" compatibility="5.3.002" expanded="true" height="60" name="Generate n-Grams (Terms)" width="90" x="45" y="255">
            <parameter key="max_length" value="1"/>
          </operator>
          <connect from_port="document" to_op="Tokenize" to_port="document"/>
          <connect from_op="Tokenize" from_port="document" to_op="Filter Stopwords (Arabic)" to_port="document"/>
          <connect from_op="Filter Stopwords (Arabic)" from_port="document" to_op="Generate n-Grams (Terms)" to_port="document"/>
          <connect from_op="Generate n-Grams (Terms)" 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>
      <operator activated="true" class="retrieve" compatibility="5.3.000" expanded="true" height="60" name="Retrieve (2)" width="90" x="447" y="30">
        <parameter key="repository_entry" value="modelAr"/>
      </operator>
      <operator activated="true" class="apply_model" compatibility="5.3.000" expanded="true" height="76" name="Apply Model" width="90" x="514" y="165">
        <list key="application_parameters"/>
        <parameter key="create_view" value="false"/>
      </operator>
      <connect from_op="Retrieve" from_port="output" to_op="Process Documents from Files" to_port="word list"/>
      <connect from_op="Process Documents from Files" from_port="example set" to_op="Apply Model" to_port="unlabelled data"/>
      <connect from_op="Retrieve (2)" from_port="output" to_op="Apply Model" to_port="model"/>
      <connect from_op="Apply Model" from_port="labelled data" 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>
and here is the java code
// Path to process-definition
final String processPath =
  "C:/Users/WINDOWS 7/.RapidMiner5/repositories/NewLocalRepository/TestNews.rmp";

// Init RapidMiner
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
RapidMiner.init();

        try
        {   
         
// Load process
final com.rapidminer.Process process =
  new com.rapidminer.Process(new File(processPath));
       
        // Load learned model
final RepositoryLocation locWordList = new RepositoryLocation(
  "//NewLocalRepository/modelAr.model");
       
final IOObject wordlist = ((IOObjectEntry)
  locWordList.locateEntry()).retrieveData(null);

// Load Wordlist
final RepositoryLocation locModel = new RepositoryLocation(
  "//NewLocalRepository/wordlistAr.wordlist");
final IOObject model = ((IOObjectEntry)
  locModel.locateEntry()).retrieveData(null);

final IOContainer ioInput = new IOContainer(new IOObject[] { wordlist, model });
process.run(ioInput);
process.run(ioInput);
final long start = System.currentTimeMillis();
final IOContainer ioResult = process.run();
final long end = System.currentTimeMillis();
System.out.println("T:" + (end - start));

// Print some results
final SimpleExampleSet ses = ioResult.get(SimpleExampleSet.class);
for (int i = 0; i < Math.min(5, ses.size()); i++) {
final Example example = ses.getExample(i);
final Attributes attributes = example.getAttributes();

final String id = example.getValueAsString(attributes.getId());
final String prediction = example.getValueAsString(
  attributes.getPredictedLabel());

System.out.println("Path: " + id + ":\tPrediction:" + prediction);
        }
        }
        catch(Exception e)
        {e.printStackTrace();}
}
it says the problem is with this line

final IOObject wordlist = ((IOObjectEntry)
  locWordList.locateEntry()).retrieveData(null);

Thank you in advance