🎉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

"NoSuchMethodError during using text input plugin"

User: "cnj125"
New Altair Community Member
Updated by Jocelyn
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
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.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:/Documents and Settings/user/My Documents/rm_workspace/sample/data/training_model.mod"),
new File(
"C:/Documents and Settings/user/My Documents/rm_workspace/sample/data/training_words.list"));

// Call the classifier with texts
System.out.println("Test1:" + tr.apply("povrai xflick resolution gif"));
System.out.println("Test2:" + tr.apply("workstation intel switch"));

}

}
But it return an error like that
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)
Anyone idea to solve this problem ? Thank you very much

Find more posts tagged with