Naive Bayes Sentiment Analysis of Facebook Post

269 views Asked by At

Could any of you help me with the following issue?

My goal is to make a sentiment analysis of the comments of a post to see if the feedback is positive or negative.

To do it, i have the following code of RestFB JAVA API:

Comments commentsPolarity; 
commentsPolarity = post.getComments();

                        if (commentsPolarity != null){
                            polarity = bayes.classify(Arrays.asList(commentsPolarity.toString())).getCategory();

                            ((BayesClassifier<String, String>) bayes).classifyDetailed(Arrays.asList(commentsPolarity.toString()));
                        }

My problem is that every analysis come back as negative, so I check what is in "commentsPolarity" variable and found out that it contains things like:

"Comments[data=[Comment[attachment=null canRemove=true comments=null createdTime=Fri Jun 05 12:21:32 BRT 2015 from=CategorizedFacebookType[category=Artist id=1440092102975875 metadata=null name=Luis Henrique type=null] id=10153129969287326_10153133899852326 isHidden=null likeCount=0 likes=null message=Sou modelo e gostaria de mostrar meu trabalho, consultem meu catálogo! metadata=null object=null parent=null type=null userLikes=false canComment=false canHide=false]] totalCount=4]"

I believe that if I can get only the message, my problem will be solved.

I'd tried to use post.getComments().getData(); but then my Flume source stops create the final file with the data extracted.

So, could anybody give some clue of what to do?

1

There are 1 answers

3
Martin Boyanov On

The object commentsPolarity has an array called data which contains the individual comments. Each of these comments has a message property. You need to iterate over something like commentsPolarity.getData(); and extract the message from there.
Take this only as a guess because I have no idea how you initialized the post variable.