Facebook帖子的朴素贝叶斯情感分析

时间:2015-06-09 14:47:07

标签: facebook hadoop sentiment-analysis restfb naivebayes

你们有没有人帮我解决以下问题?

我的目标是对帖子的评论进行情绪分析,看看反馈是正面还是负面。

为此,我有以下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()));
                        }

我的问题是每次分析都会回复为否定,所以我检查“commentsPolarity”变量中的内容,发现它包含的内容如下:

  

“评论[data = [评论[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 消息 = Sou modelo e gostaria de mostrar meu trabalho,   consultemmeucatálogo! metadata = null object = null parent = null   type = null userLikes = false canComment = false canHide = false]]   TOTALCOUNT = 4]“

我相信如果我只能获得消息,我的问题就会得到解决。

我尝试使用post.getComments().getData();,但我的Flume源停止了 用提取的数据创建最终文件。

那么,有人可以提供一些线索吗?

1 个答案:

答案 0 :(得分:0)

对象commentsPolarity有一个名为data的数组,其中包含各个注释。这些注释中的每一个都有一个消息属性。您需要迭代 commentsPolarity.getData(); 之类的内容并从那里提取消息 这只是猜测,因为我不知道你如何初始化 post 变量。

相关问题