public void printTopicsToFile(File file, Model model) throws IOException { FileWriter writer = new FileWriter(file); BufferedWriter buffWriter = new BufferedWriter(writer); ParallelTopicModel malletParallelTopicModel = model.malletModel; Object[][] topicWords = malletParallelTopicModel.getTopWords(malletParallelTopicModel.numTypes); for (int i = 0; i < topicWords.length; i++) { buffWriter.write("Topic " + i + "\n"); for (int j = 0; j < topicWords[i].length; j++) { buffWriter.write("Word " + j + ": " + topicWords[i][j] + "\n"); } buffWriter.write("\n"); } buffWriter.close(); LOGGER.info("Topics written in " + file.getAbsolutePath() + "."); } }
public void verifyModel(String modelFilename, String configFileName) throws ConfigurationException { MalletTopicModeling tm = new MalletTopicModeling(); XMLConfiguration xmlConfig = tm.loadConfig(configFileName); Model model = tm.readModel(modelFilename); ParallelTopicModel savedMalletModel = model.malletModel; Object[][] topicWords = savedMalletModel.getTopWords(savedMalletModel.numTypes); if (topicWords.length == xmlConfig.getInt("train.parameters.parameter.numTopics")) { LOGGER.info("Topic model verified."); } else { LOGGER.info("Topic model verification failed."); } }
Object[][] sorted = lda.getTopWords(seqAlphabet.size());
Object[][] sorted = lda.getTopWords(seqAlphabet.size());
Object[][] sorted = lda.getTopWords(seqAlphabet.size());