Need Help for

sasss52sasss52 Member Posts: 9 Contributor II
edited November 2018 in Help
Hi,
I am new in  programing, I am trying to run this code for some test but it is giving me some error. I spend a quite a bit of time in order to find solution. Can some one please help me out to solve this problem. I read all the relevant post and try all the recommended solution but non of them is working for my code. Please help me out.... 

I add the rapidminer.jar and rapidminer-text.jar to the lib folder as suggest.
Code:...
import java.io.File;
import java.io.IOException;

import com.rapidminer.RapidMiner;
import com.rapidminer.example.Example;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.Model;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorChain;
import com.rapidminer.operator.OperatorCreationException;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.operator.SingleTextInput;
import com.rapidminer.tools.OperatorService;

public class texttest {

private OperatorChain wvtoolOperator;
private Operator modelApplier;
private Model model;

public texttest(File modelFile, File wordListFile)
throws IOException, OperatorCreationException, OperatorException {



String pluginDirString = new File("rapidminer.home","C:\\Documents and Settings\\ssubpol\\Desktop\\WorkFile\\rapidminertest\\lib").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);

// Create the text input operator and set the path to the word list you stored using Rapid Miner
// As there is only a single text, we use the SingleTextInput operator
//wvtoolOperator = (OperatorChain) OperatorService.createOperator("SingleTextInput");
RapidMiner.init(false, false, false, true);
OperatorChain wvtoolOperator=(OperatorChain) OperatorService.createOperator(SingleTextInput.class);

wvtoolOperator.setParameter("word", wordListFile.getAbsolutePath());

// Add additional processing steps.
// Note the setup must be same as the one you used when creating the classification model
wvtoolOperator.addOperator(OperatorService.createOperator("StringTokenizer"));
wvtoolOperator.addOperator(OperatorService.createOperator("EnglishStopwordFilter"));
wvtoolOperator.addOperator(OperatorService.createOperator("TokenLengthFilter"));
wvtoolOperator.addOperator(OperatorService.createOperator("PorterStemmer"));

// Create the model applier
modelApplier = OperatorService.createOperator("ModelApplier");

// Load the model into a field of the class
Operator modelLoader = OperatorService.createOperator("ModelLoader");
modelLoader.setParameter("model.mod", modelFile.getAbsolutePath());
IOContainer container = modelLoader.apply(new IOContainer());
model = container.get(Model.class);

}

public String apply(String text) throws OperatorException {

// Set the text
wvtoolOperator.setParameter("test_text", text);

// Call the text input operator
IOContainer container = wvtoolOperator.apply(new IOContainer(model));

// Call the model applier (the model was added already before calling the text input)
container = modelApplier.apply(container);


ExampleSet eset = container.get(ExampleSet.class);
Example e = eset.iterator().next();

return eset.getAttributes().getPredictedLabel().getMapping().mapIndex((int) e.getPredictedLabel());

}

public static void main(String args[]) throws Exception {

texttest tr = new texttest(
new File("C:\\Documents and Settings\\ssubpol\\Desktop\\WorkFile\\rapidminertest\\data\\model.mod"),
new File("C:\\Documents and Settings\\ssubpol\\Desktop\\WorkFile\\rapidminertest\\data\\words.list"));

// Call the classifier with texts
System.out.println("Test1:" + tr.apply("........"));
System.out.println("Test2:" + tr.apply("..."));

}

}

Error:................


G Mar 30, 2009 11:15:41 PM: Property rapidminer.home is not set. Guessing.
G Mar 30, 2009 11:15:41 PM: Trying parent directory of 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\lib\rapidminer.jar'...gotcha!
G Mar 30, 2009 11:15:41 PM: Trying base directory of classes (build) 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest'...gotcha!
G Mar 30, 2009 11:15:41 PM: ----------------------------------------------------
G Mar 30, 2009 11:15:41 PM: Initialization Settings
G Mar 30, 2009 11:15:41 PM: ----------------------------------------------------
G Mar 30, 2009 11:15:41 PM: Default system encoding for IO: windows-1252
G Mar 30, 2009 11:15:41 PM: Load core operators...
G Mar 30, 2009 11:15:41 PM: Load Weka operators: weka not found
G Mar 30, 2009 11:15:41 PM: Load JDBC drivers from lib directory: false
G Mar 30, 2009 11:15:41 PM: Load JDBC drivers from classpath: false
G Mar 30, 2009 11:15:41 PM: Load plugins: true
G Mar 30, 2009 11:15:41 PM: Load plugins from 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\lib\plugins'
G Mar 30, 2009 11:15:41 PM: ----------------------------------------------------
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\etc\rapidminerrc'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\etc\rapidminerrc.Windows XP'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\.rapidminer\4_4_0_rapidminerrc'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\.rapidminer\4_4_0_rapidminerrc.Windows XP'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\rapidminerrc'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rcfile 'C:\Documents and Settings\ssubpol\Desktop\WorkFile\rapidminertest\rapidminerrc.Windows XP'...skipped
G Mar 30, 2009 11:15:41 PM: Trying rapidminer.rcfile. Property not specified...skipped
G Mar 30, 2009 11:15:42 PM: Loading operators from 'operators.xml'.
G Mar 30, 2009 11:15:42 PM: [Error] Cannot register 'ExcelExampleSetWriter': java.lang.NoClassDefFoundError: jxl/format/CellFormat
G Mar 30, 2009 11:15:43 PM: [Error] Cannot register 'NeuralNet': java.lang.NoClassDefFoundError: org/joone/engine/NeuralNetListener
G Mar 30, 2009 11:15:43 PM: [Error] Cannot register 'NeuralNetSimple': java.lang.NoClassDefFoundError: org/encog/neural/data/NeuralDataSet
G Mar 30, 2009 11:15:44 PM: Loading JDBC driver information from 'resources:jdbc_properties.xml'.
G Mar 30, 2009 11:15:44 PM: [Error] Cannot initialize XML serialization. Probably the libraries 'xstream.jar' and 'xpp.jar' were not provided. XML serialization will not work!
G Mar 30, 2009 11:15:44 PM: [Warning] Cannot register renderer: java.lang.NoClassDefFoundError: org/joone/engine/OutputPatternListener
G Mar 30, 2009 11:15:44 PM: [Warning] Cannot register renderer: java.lang.NoClassDefFoundError: org/encog/neural/data/NeuralData
Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.SingleTextInput'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:565)
at texttest.<init>(texttest.java:34)
at texttest.main(texttest.java:77)

Tagged:

Answers

  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Hi,

    those two lines simply make no sense at all:

          String pluginDirString = new File("rapidminer.home","C:\\Documents and Settings\\ssubpol\\Desktop\\WorkFile\\rapidminertest\\lib").getAbsolutePath();
          System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);     
    I assume that you mixed up things here. You should do two things:
    • Set "rapidminer.home" to the main directory of RapidMiner with System.setProperty("rapidminer.home", path)
    • Set the property for the plugins with the correct directory (the one you specified actually is "rapidminer.home\C:\\....\lib" which does not make any sense on a windows system
    Cheers,
    Ingo
Sign In or Register to comment.