0

So I've a trained model that was created through command line with MALLET. I want to, somehow, import this trained model into a Java class. I looked through MALLET's API documentation and came across their ParallelTopicModel class but couldn't find a suitable way to import the model as a ParallelTopicModel which is what I want to do.

I know that it's possible to train a model using the MALLET Java API inside the Java class itself but I do not want to do this.

Is this possible?

higz555
  • 115
  • 8

1 Answers1

1

If that trained model generated both the data model and the data instances you can do this. The ParallelTopicModel will use the data model and the Pipe that it used to train the model will be used to create an InstanceList, which you will need for the TopicInferencer.

String testingText = "my test";
ParallelTopicModel model = ParallelTopicModel.read(new File("data_model_path"));
InstanceList instances = InstanceList.load(new File("data_instances_path"));

// Create a new instance with the testing text
InstanceList testing = new InstanceList(instances.getPipe());
testing.addThruPipe(new Instance(testing_text, null, "Test Instance", null));

// Create the inferencer
TopicInferencer inferencer = model.getInferencer();
c-chavez
  • 7,237
  • 5
  • 35
  • 49