Database Reference
In-Depth Information
...
instances.addThruPipe(new StringArrayIterator(textList.
toArray(new String[textList.size()])));
ParallelTopicModel model = new ParallelTopicModel
(NUM_TOPICS);
model.addInstances(instances);
model.setNumThreads(THREADS);
model.setNumIterations(ITERATIONS);
model.estimate();
// The data alphabet maps word IDs to strings
Alphabet dataAlphabet = instances.getDataAlphabet();
int topicIdx=0;
StringBuilder sb;
for (TreeSet<IDSorter> set : model.getSortedWords()) {
sb = new StringBuilder().append(topicIdx);
sb.append( "-" );
int j = 0;
double sum = 0.0;
for (IDSorter s : set) {
sum += s.getWeight();
}
for (IDSorter s : set) {
sb.append(dataAlphabet.lookupObject(s.getID())).
append( ":" ).append(s.getWeight() / sum).
append( ", " );
if (++j >= NUM_WORDS_TO_ANALYZE) break;
}
System.out.println(sb.append( "\n" ).toString());
topicIdx++;
}
}
}
Source: Chapter4/tweetlda/LDA.java
4.2.2
Sentiment Analysis
Often its not important to know what users are saying, but how they are saying
it . “Sentiment analysis” seeks to automatically associate a piece of text with a
“sentiment score”, a positive or negative emotional score. Aggregating sentiment
can give an idea of how people are responding to a company, product, or topic.
4.2.2.1
Sentiment Analysis Overview
Sentiment analysis, is done on a per-Tweet basis. The words in each Tweet are
compared with those in other Tweets that have been previously labeled as “positive”,
 
Search WWH ::




Custom Search