July 2017
Beginner to intermediate
715 pages
17h 3m
English
We can now perform sentiment analysis using the model built in the Building the sentiment model section of this chapter. We create a new Classification object by passing our cleaned text to the classify method. We then use the bestCategory method to classify our text as either positive or negative. Finally, we set category to the result and return the TweetHandler object:
public TweetHandler performSentimentAnalysis() { Classification classification = classifier.classify(this.text); String bestCategory = classification.bestCategory(); this.category = bestCategory; return this; }
We are now ready to analyze the results of our application.