public Object[] getVocabulary(Model model) { ParallelTopicModel malletModel = model.malletModel; Alphabet alphabet = malletModel.getAlphabet(); Object[] alphabetArray = alphabet.toArray(); return alphabetArray; } }
/** * @param topic * @param number of keywords required * @return key words for topic */ public List<String> forTopic(int topic, int number) { return model .getSortedWords() .get(topic) .stream() .map(IDSorter::getID) .map(model.getAlphabet()::lookupObject) .map(Object::toString) .limit(number) .collect(Collectors.toList()); } }
/** * 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; }
/** * @param topic * @param number of keywords required * @return key words for topic */ public List<String> forTopic(int topic, int number) { return model .getSortedWords() .get(topic) .stream() .map(IDSorter::getID) .map(model.getAlphabet()::lookupObject) .map(Object::toString) .limit(number) .collect(Collectors.toList()); } }
@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(); } }
ArrayList<Integer> features = new ArrayList<Integer>(); Alphabet seqAlphabet = lda.getAlphabet();
ArrayList<Integer> features = new ArrayList<Integer>(); Alphabet seqAlphabet = lda.getAlphabet();
ArrayList<Integer> features = new ArrayList<Integer>(); Alphabet seqAlphabet = lda.getAlphabet();
alphabet = model.getAlphabet(); topicSortedWords = model.getSortedWords();
alphabet = model.getAlphabet(); topicSortedWords = model.getSortedWords();
alphabet = model.getAlphabet(); topicSortedWords = model.getSortedWords();
throw new IOException(e); Alphabet alphabet = model.getAlphabet();
public void topicPhraseXMLReport(PrintWriter out, int numWords) { int numTopics = this.getNumTopics(); gnu.trove.TObjectIntHashMap<String>[] phrases = new gnu.trove.TObjectIntHashMap[numTopics]; Alphabet alphabet = this.getAlphabet();
public void topicPhraseXMLReport(PrintWriter out, int numWords) { int numTopics = this.getNumTopics(); gnu.trove.TObjectIntHashMap<String>[] phrases = new gnu.trove.TObjectIntHashMap[numTopics]; Alphabet alphabet = this.getAlphabet();
public void topicPhraseXMLReport(PrintWriter out, int numWords) { int numTopics = this.getNumTopics(); gnu.trove.TObjectIntHashMap<String>[] phrases = new gnu.trove.TObjectIntHashMap[numTopics]; Alphabet alphabet = this.getAlphabet();
@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); } }