public Model readMalletModel(File file) { Model model = new Model(); try { ParallelTopicModel malletParallelTopicModel = ParallelTopicModel.read(file); model.malletModel = malletParallelTopicModel; } catch (Exception e) { e.printStackTrace(); } return model; }
/** * Initialize. * * @param modelFile * the file containing the model * @param nWords * the number of words that should be written for each topic * @throws IOException * if the model cannot be read */ public PrintTopicWordWeights(File modelFile, int nWords) throws IOException { try { model = ParallelTopicModel.read(modelFile); } catch (Exception e) { throw new IOException(e); } alphabet = model.getAlphabet(); this.nWords = nWords; }
public static void main(String[] args) throws IOException { setOptions(args); String targetFile = modelFile + TARGET_FILE_SUFFIX; LOG.info(String.format("%nReading model from '%s'.%nStoring topic words in '%s'.", modelFile, targetFile)); ParallelTopicModel model; try { model = ParallelTopicModel.read(modelFile); } catch (Exception e) { throw new IOException(e); } model.printTopWords(new File(targetFile), nWords + 1, false); }
/** * Print the top n words of each topic into a file. * * @param modelFile * the model file * @param targetFile * the file in which the topic words are written * @param nWords * the number of words to extract * @throws IOException * if the model file cannot be read or if the target file cannot be written */ public static void printTopicWords(File modelFile, File targetFile, int nWords) throws IOException { boolean newLineAfterEachWord = false; ParallelTopicModel model; try { model = ParallelTopicModel.read(modelFile); } catch (Exception e) { throw new IOException(e); } model.printTopWords(targetFile, nWords, newLineAfterEachWord); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { model = ParallelTopicModel.read(new File(modelPath)); pipe = new TopicModelPipe(stopwordResource.getStopwords(stoplist), model.getAlphabet()); topicWords = new TopicWords(model); } catch (Exception e) { throw new ResourceInitializationException(); } }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { model = ParallelTopicModel.read(new File(modelPath)); pipe = new TopicModelPipe(stopwordResource.getStopwords(stoplist), model.getAlphabet()); topicWords = new TopicWords(model); } catch (Exception e) { throw new ResourceInitializationException(); } }
ParallelTopicModel model; try { model = ParallelTopicModel.read(modelFile);
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { logger.warning("Unable to restore saved topic model " +
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { logger.warning("Unable to restore saved topic model " +
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { logger.warning("Unable to restore saved topic model " +
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { System.err.println("Unable to restore saved topic model " +
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { System.err.println("Unable to restore saved topic model " +
topicModel = ParallelTopicModel.read(new File(inputModelFilename.value)); } catch (Exception e) { System.err.println("Unable to restore saved topic model " +
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); ParallelTopicModel model; try { getLogger().info("Loading model file " + modelLocation); model = ParallelTopicModel.read(modelLocation); if (maxTopicAssignments <= 0) { maxTopicAssignments = model.getNumTopics() / 10; } } catch (Exception e) { throw new ResourceInitializationException(e); } getLogger().info("Model loaded."); inferencer = model.getInferencer(); malletPipe = new TokenSequence2FeatureSequence(model.getAlphabet()); try { sequenceGenerator = new PhraseSequenceGenerator.Builder() .featurePath(tokenFeaturePath) .minTokenLength(minTokenLength) .lowercase(lowercase) .buildStringSequenceGenerator(); } catch (IOException e) { throw new ResourceInitializationException(e); } }