No operator description object
danii
New Altair Community Member
Hi,
I have to write a Java-Application for my master-thesis where I want to apply a model (which I created before in the RM GUI as "output_type" binary) to some texts, but I got the error-message below. I use
rapidminer.jar (version 4.1) and rapidminer-text-4.1.jar, which I have in my classpath, but I have also tested it with the current CVS-Version. I don't understand the message because the code works fine with the wvtool-operators "StringTokenizer", etc. but not with the rapidminer-operators "ModelApplier" and "ModelLoader"??
Hope someone can give me an advise. I'm despaired because it's very important for me that it works.
******************************
[java] G May 24, 2008 11:35:21 AM: Loading operators from 'operators.xml'.
[java] G May 24, 2008 11:35:22 AM: Loading JDBC driver information from 'resources:jdbc_properties.xml'.
[java] Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'ModelApplier'
[java] at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:465)
[java] at tagger.test.RapidMinerTextClassifier.<init>(Unknown Source)
[java] at tagger.test.RapidMinerTextClassifier.main(Unknown Source)
******************************
Greetings,
Danii
I have to write a Java-Application for my master-thesis where I want to apply a model (which I created before in the RM GUI as "output_type" binary) to some texts, but I got the error-message below. I use
rapidminer.jar (version 4.1) and rapidminer-text-4.1.jar, which I have in my classpath, but I have also tested it with the current CVS-Version. I don't understand the message because the code works fine with the wvtool-operators "StringTokenizer", etc. but not with the rapidminer-operators "ModelApplier" and "ModelLoader"??
Hope someone can give me an advise. I'm despaired because it's very important for me that it works.
******************************
[java] G May 24, 2008 11:35:21 AM: Loading operators from 'operators.xml'.
[java] G May 24, 2008 11:35:22 AM: Loading JDBC driver information from 'resources:jdbc_properties.xml'.
[java] Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'ModelApplier'
[java] at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:465)
[java] at tagger.test.RapidMinerTextClassifier.<init>(Unknown Source)
[java] at tagger.test.RapidMinerTextClassifier.main(Unknown Source)
******************************
...
RapidMiner.init();
//RapidMiner.init(false, false, false, true);
OperatorChain wvtoolOperator = (OperatorChain) OperatorService.createOperator("SingleTextInput");
wvtoolOperator.setParameter("input_word_list", wordListFile.getAbsolutePath());
wvtoolOperator.addOperator(OperatorService.createOperator("StringTokenizer"));
wvtoolOperator.addOperator(OperatorService.createOperator("PorterStemmer"));
// Create the model applier and load the model into a field of the class
Operator modelApplier = OperatorService.createOperator("ModelApplier");
Operator modelLoader = OperatorService.createOperator("ModelLoader");
modelLoader.setParameter("model_file", modelFile.getAbsolutePath());
IOContainer container = modelLoader.apply(new IOContainer());
Model model = container.get(Model.class);
...
Greetings,
Danii
0
Answers
-
Hello Danii,
hmm, this looks indeed a bit strange. Since there could be a problem with the combination of the text plugin (please refer to http://rapid-i.com/rapidforum/index.php/topic,26.0.html ) I will try to check this during the next days and will write back as soon as possible. Thanks for sending in the detailed information.
Cheers,
Ingo0 -
Hi Danii,
I had a look into this issue and I just tried to use RapidMiner together with the Text plugin myself in a fresh and new project. Here is what I have done:
- create a new project
- add a lib directory containing rapidminer.jar (Version: 4.1) and rapidminer-text-4.1.jar
- add the libraries to the classpath of the project
- create only a single class containing the following code:
Please note that I used basically the same code as you but replaced the operator creation by the variant using the class name (does actually not make a difference but guarantees the availability of operators during compile time) and I used the new PARAMETER_... constants where possible. Please note also that you would have to adapt the plugin directory path.
package com.rapidminer.texttest;
import java.io.File;
import com.rapidminer.RapidMiner;
public class TextTest {
public static void main(String[] argv) throws Exception {
String pluginDirString = new File("C:\\Dokumente und Einstellungen\\Mierswa\\Eigene Dateien\\workspace\\RMTextTest\\lib").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
File wordListFile = new File(".");
File modelFile = new File(".");
RapidMiner.init();
OperatorChain wvtoolOperator = (OperatorChain) OperatorService.createOperator(SingleTextInput.class);
wvtoolOperator.setParameter("input_word_list", wordListFile.getAbsolutePath());
wvtoolOperator.addOperator(OperatorService.createOperator(SimpleTokenizer.class));
wvtoolOperator.addOperator(OperatorService.createOperator(PorterStemmer.class));
Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
Operator modelLoader = OperatorService.createOperator(ModelLoader.class);
modelLoader.setParameter(ModelLoader.PARAMETER_MODEL_FILE, modelFile.getAbsolutePath());
IOContainer container = modelLoader.apply(new IOContainer());
Model model = container.get(Model.class);
}
}
We introduced a new plugin path which should ease project management for developers. Especially for the case where no plugin is used the only necessary line is "RapidMiner.init()" which should be much more convenient. Just for the sake of explanation why we introduced this change.
Please let me hear if this did the trick...
Cheers,
Ingo
0 -
Hi Ingo,
Thank you for your prompt reply and also thank you for your efforts. Your code worked really fine!
But I don't know how to say, when I extend the code to apply the model to a test-example, this line caused an error:
IOContainer container = wvtoolOperator.apply(new IOContainer(model));
[java] Exception in thread "main" java.lang.NoSuchMethodError: com.rapidminer.operator.IOContainer.<init>(Lcom/rapidminer/operator/IOObject;)V
[java] at com.rapidminer.operator.TextInput.getTokenSequence(Unknown Source)
[java] at com.rapidminer.operator.TextInput.apply(Unknown Source)
[java] at com.rapidminer.operator.Operator.apply(Operator.java:656)
[java] at miner.test.TextTest.apply(TextTest.java:47)
[java] at miner.test.TextTest.main(TextTest.java:61)
[java] Java Result: 1
I don't want to be a nuisance but what have I done wrong this time? I’m very grateful for any help.
package miner.test;
import java.io.File;
import java.io.IOException;
import com.rapidminer.RapidMiner;
import com.rapidminer.operator.*;
import com.rapidminer.operator.io.*;
import com.rapidminer.tools.*;
import com.rapidminer.operator.tokenizer.*;
import com.rapidminer.operator.reducer.*;
import com.rapidminer.example.Example;
import com.rapidminer.example.ExampleSet;
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("C:\\Users\\...\\eclipse-workspace\\TestMiner\\lib").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
RapidMiner.init();
wvtoolOperator = (OperatorChain) OperatorService.createOperator(SingleTextInput.class);
wvtoolOperator.setParameter("input_word_list", wordListFile.getAbsolutePath());
wvtoolOperator.addOperator(OperatorService.createOperator(SimpleTokenizer.class));
wvtoolOperator.addOperator(OperatorService.createOperator(PorterStemmer.class));
modelApplier = OperatorService.createOperator(ModelApplier.class);
Operator modelLoader = OperatorService.createOperator(ModelLoader.class);
modelLoader.setParameter(ModelLoader.PARAMETER_MODEL_FILE, modelFile.getAbsolutePath());
IOContainer container = modelLoader.apply(new IOContainer());
model = container.get(Model.class);
}
public String apply(String text) throws OperatorException {
// set the text and call the model applier (the model was added already before calling the text input)
wvtoolOperator.setParameter("text", text);
IOContainer container = wvtoolOperator.apply(new IOContainer(model)); //<-- ERROR
container = modelApplier.apply(container);
// obtain the example set from the io 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:\\Users\\...\\eclipse-workspace\\TestMiner\\data\\trained_model_SVM.mod"),
new File("C:\\Users\\...\\eclipse-workspace\\TestMine\\data\\trained_wordlist.list"));
System.out.println("Test:" + tr.apply(" .... "));
}
}
Greetings,
Danii0 -
Hi Danii,
could it be that you access RapidMiner via CVS and have compiled the project yourself (and maybe build the file rapidminer.jar and added it to your project)?
I got the same error when I use a freshly compiled CVS version of RapidMiner together with the download version of the text plugin. Since we changed one of the constructors of IOContainer the plugin needs to be recompiled and used then. I have rebuild the plugin for you and it is stored at:
http://rapid-i.com/snapshot/rapidminer-text-4.1.jar
After re-compiling everything (RapidMiner and the plugin) your process works for me without any problems.
Hope that helps,
Ingo0 -
Hi Ingo,
Thank you again for your efforts. Your are right, this was the fault - now everything works.
Cheers,
Danii0 -
Hi,
great to hear. And don't worry: I made the same mistake
Cheers,
Ingo0 -
Hi there,
I seem to be having a similar problem, but I haven't been able to get the same results by modifying your examples :-\
I get the "No operator description object" error when I run my code, but nothing shows when it's compiled... Here's the basic code:
I'm using both RM and text plugin 4.2, and I've added both .jar's to my buildpath, but I don't know what else to do ???package experiment4;
import java.io.File;
import com.rapidminer.Process;
import com.rapidminer.RapidMiner;
import com.rapidminer.operator.*;
import com.rapidminer.operator.reducer.PorterStemmer;
import com.rapidminer.operator.tokenizer.SimpleTokenizer;
import com.rapidminer.operator.wordfilter.EnglishStopwordFilter;
import com.rapidminer.tools.OperatorService;
public class IngoText {
public static void main(String[] argv) throws OperatorCreationException {
// initialization
RapidMiner.init();
// set properties to point to plugin directory
String pluginDirString = new File("C:\\Program_Files\\Rapid-I\\RapidMiner-4.2\\lib\\plugins").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
// Set operator field types
Process root = new Process();
OperatorChain wvtoolOperator;
Operator inputOperator;
/* create operator 1 - IMPORT DATA FROM MYSQL */
inputOperator = OperatorService.createOperator("DatabaseExampleSource");
// set parameters
inputOperator.setParameter("database_url", "jdbc:mysql:\\localhost:3306\\dr");
inputOperator.setParameter("password", "E/3vEpvMx4o");
inputOperator.setParameter("query", "SELECT * FROM fss_drs WHERE id<36;");
inputOperator.setParameter("username", "root");
// add operator 1 to root process
root.getRootOperator().addOperator(inputOperator);
/* Operator 2 - Input Text as Strings */
wvtoolOperator = (OperatorChain) OperatorService.createOperator("StringTextInput");
// Add suboperators for text preprocessing
wvtoolOperator.addOperator(OperatorService.createOperator(SimpleTokenizer.class));
wvtoolOperator.addOperator(OperatorService.createOperator(PorterStemmer.class));
wvtoolOperator.addOperator(OperatorService.createOperator(EnglishStopwordFilter.class));
/* Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
* Operator modelLoader = OperatorService.createOperator(ModelLoader.class);
* modelLoader.setParameter(ModelLoader.PARAMETER_MODEL_FILE, modelFile.getAbsolutePath());
* IOContainer container = modelLoader.apply(new IOContainer());
*
* Model model = container.get(Model.class);
*/
// ... I'll do more with the exampleset after this, but the text part is my main problem
}
}
Thanks so much in advance to anyone who can help!
Eric0 -
Hi Eric,
exchange the order of the following lines:
to
// initialization
RapidMiner.init();
// set properties to point to plugin directory
String pluginDirString = new File("C:\\Program_Files\\Rapid-I\\RapidMiner-4.2\\lib\\plugins").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
// set properties to point to plugin directory
String pluginDirString = new File("C:\\Program_Files\\Rapid-I\\RapidMiner-4.2\\lib\\plugins").getAbsolutePath();
System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
// initialization
RapidMiner.init();
You first have to set the properties and then initialize RapidMiner - the properties are read during initialization.
Cheers,
Ingo0 -
Thanks Ingo,
I switched the order of the properties and initialization methods, but unfortunately I'm still getting the same runtime error. Is there something extra that has to be done with the operators.xml file?
Error Message:
Thanks so much,
Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.StringTextInput'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:565)
at experiment4.IngoText.main(IngoText.java:41)
Eric
(Edit:)
There has to be something wrong with the way my rapidminer is using operators.xml. I've gone through the debug of my code and I end up inside OperatorService. The variable 'clazz' iterates through a list of all the operators, but not in the same order as the operators.xml file. When I trace the variables through the classes to find where it gets these operator names, I end up all the way back at the top (rapidminer.class) and I can't even find where the default is hardcoded.
I've even tried just adding the text plugin operators.xml file (from the plugin src) to the main operators.xml file, and a few different ways of initializing so that it looks for the operators.xml file in the right spot or looks for additional ones.
If you've read this far, I sincerely appreciate your time. Sorry for the lengthy post and edits, I'll keep working at it.
-Eric0 -
Success!
Well, I finally got it to run, at least. After spending a large number of hours messing with the code, I found _'s in the file path to my plugin instead of spaces. The null pointer error was because my text plugins were pointing to classes that were in the text plugin, which wasn't being pointed to correctly.
Words cannot describe the emotions I'm going through right now, but if any could, they would probably include embarassment, disappointment, and a general sense of self loathing...
Anyways, for anyone else who's new to Java, don't use _ for spaces...
Cheers,
Eric0 -
Hi Eric,
great news to hear about! So now the fun can begin and you can get deeper in your actual analysis tasks. And I totally understand your emotions - I am going through those at least once per month ;D
All the best,
Ingo0 -
Dear Ingo,
How can I solve the same problem for RM Plugin. I have implemented R-extension (I have jar-file inside lib/plugins). Now I would like to use OperatorChain (called DCTFragment) in another plugin:try {
And I see:
DCTFragment dctFragment;
dctFragment = (DCTFragment) OperatorService.createOperator(com.rapidminer.operator.r.DCTFragment.class);
} catch (OperatorCreationException e) {
e.printStackTrace();
}
com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.r.DCTFragment'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:587)
at com.rapidminer.elico.ida.gui.wizard.steps.FetchPlansStep$3.run(FetchPlansStep.java:207)
at com.rapidminer.gui.tools.ProgressThread$2.run(ProgressThread.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)0