0

I have explored mallet and it is working good. What I am trying to do is making a model twice in a program scope and facing exception. My program code is as:

List<String> commands = new ArrayList<String>();
commands.add("--input input.mallet --output-classifier output_classifier.classifier --trainer MaxEnt --report train:accuracy");

commands.add("--input input.mallet --output-classifier output_classifier.classifier --trainer MaxEnt --report train:accuracy");

for( int index = 0; index < commands.size(); index++ ) {
    try {
        Vectors2Classify.main(commands.get(index).split(" "));
    } catch (EvalError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

First one command is running successfully. On second command I am getting following exception.

Exception in thread "main" java.lang.IllegalArgumentException: Alphabets don't match: Instance: [9327, 3], InstanceList: [9327, 3]

    at cc.mallet.types.InstanceList.add(InstanceList.java:335)
    at cc.mallet.types.InstanceList.shallowClone(InstanceList.java:213)
    at cc.mallet.types.InstanceList.split(InstanceList.java:513)
    at cc.mallet.classify.tui.Vectors2Classify.main(Vectors2Classify.java:397)

I have searched this problem but did not found any solution till now. It look like that no one have tried until now making a model twice in a program scope.
If anyone can help me on this, will be thankful to you.

Hammad Hassan
  • 1,192
  • 17
  • 29

1 Answers1

0

The main function is designed to be called once within a program execution. There is probably some variable that is being carried over from one invocation to the next. There is a lot of logic in this Vectors2Classify for figuring out user intention from command line arguments. If you need to write Java code, copying code from Vectors2Classify to do exactly what you want is probably a better option.

David Mimno
  • 1,836
  • 7
  • 7