"NoSuchMethodError during using text input plugin"
Hi All,
I am following this tutorial to do text classification by rapid and wvtools.
http://nemoz.org/joomla/content/view/65/53/lang,en/
I can build the model and word list successfully, and I try to run the Java problem to classify text by the model. I have changed all the path to my own setting. But it
I am following this tutorial to do text classification by rapid and wvtools.
http://nemoz.org/joomla/content/view/65/53/lang,en/
I can build the model and word list successfully, and I try to run the Java problem to classify text by the model. I have changed all the path to my own setting. But it
import java.io.File;But it return an error like that
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.tools.OperatorService;
public class RapidMinerTextClassifier {
private OperatorChain wvtoolOperator;
private Operator modelApplier;
private Model model;
public RapidMinerTextClassifier(File modelFile, File wordListFile)
throws IOException, OperatorCreationException, OperatorException {
RapidMiner.init(false, false, false, true);
// 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");
wvtoolOperator.setParameter("input_word_list", 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_file", 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("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);
// Obtain the example set from the io container. It contains only a single example with our text in it.
ExampleSet eset = container.get(ExampleSet.class);
Example e = eset.iterator().next();
// Compare the predicted label with the positive label
return eset.getAttributes().getPredictedLabel().getMapping().mapIndex((int) e.getPredictedLabel());
}
public static void main(String args[]) throws Exception {
System.setProperty("rapidminer.home", "C:/Program Files/Rapid-I/RapidMiner-4.2");
// Create a text classifier
RapidMinerTextClassifier tr = new RapidMinerTextClassifier(
new File(
“C: / / user /我的文件和设置Documents/rm_workspace/sample/data/training_model.mod"),
new File(
“C: / / user /我的文件和设置Documents/rm_workspace/sample/data/training_words.list"));
// Call the classifier with texts
system . out。println (+ tr.apply(“Test1: povrai公司ick resolution gif"));
system . out。println("Test2:" + tr.apply("workstation intel switch"));
}
}
Anyone idea to solve this problem ? Thank you very much
Exception in thread "main" java.lang.NoSuchMethodError: edu.udo.cs.wvtool.main.WVTool.createVector(Ledu/udo/cs/wvtool/main/WVTTokenSequence;Ledu/udo/cs/wvtool/generic/vectorcreation/WVTVectorCreator;Ledu/udo/cs/wvtool/wordlist/WVTWordList;)Ledu/udo/cs/wvtool/main/WVTWordVector;
at com.rapidminer.operator.TextInput.apply(Unknown Source)
at com.rapidminer.operator.Operator.apply(Operator.java:664)
at com.RapidMiner.demo.RapidMinerTextClassifier.apply(RapidMinerTextClassifier.java:64)
at com.RapidMiner.demo.RapidMinerTextClassifier.main(RapidMinerTextClassifier.java:89)
Tagged:
0
Answers
are you sure you used the same version of RapidMiner / the Text plugin for model creation and model application?
Cheers,
Ingo
I have found out the reason. I have included the wvtool jar file in my problem, and the version may be not correct.
I can run it after removing it in my classpath. Thank you very much.
Regards,
Ben