你们中的任何一个都可以帮助我解决以下问题吗?
我的目标是对帖子的评论进行情感分析,以查看反馈是正面还是负面。
为此,我具有以下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”变量中的内容,发现其中包含以下内容:
"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]"
我相信,如果我只能得到消息,我的问题将得到解决。
我尝试使用
post.getComments().getData();
,但随后我的Flume源停止了使用提取的数据创建最终文件。
那么,有人可以提供一些有关该怎么做的线索吗?
最佳答案
对象commentsPolarity有一个名为data的数组,其中包含各个注释。这些注释中的每一个都有一个message属性。您需要遍历 commentsPolarity.getData();
之类的内容并从中提取消息。
仅将此作为猜测,因为我不知道如何初始化 post
变量。
关于facebook - Facebook帖子的朴素贝叶斯情感分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30735456/