【问题标题】:sentiment analysis with different number of documents不同数量文档的情感分析
【发布时间】:2015-01-21 01:08:33
【问题描述】:

我正在尝试对报纸文章进行情绪分析,并随时间跟踪情绪水平。为此,基本上我会在一天内识别出所有相关的新闻文章,将它们输入到 polar() 函数中并获得所有文章的平均极性分数(更准确地说,是所有文章中所有句子的平均值)那天之内。

问题是,在某些日子里,与其他日子相比,文章会更多,我认为如果我们只是跟踪每日平均极性分数,这可能会掩盖一些信息。例如,30 篇新闻文章的 0.1 分应该比仅 3 篇文章产生的 0.1 分具有更大的权重。果然,我获得的一些更极端的极性分数来自于相关文章很少的日子。

我是否可以考虑每天不同数量的文章?

library(qdap)
sentence = c("this is good","this is not good")
polarity(sentence)

【问题讨论】:

  • 你的意思是可以用当天的文章数量来衡量每天的极性分数吗?
  • 是的,这是可以接受的做法吗?如果是这样,什么是好的加权因子?
  • 说明polarity 函数的来源以及给出一个最小的工作示例MWE 可能很有用:stackoverflow.com/help/mcve
  • 添加了一个简化的示例来显示函数的来源。

标签: r sentiment-analysis qdap


【解决方案1】:

我会警告说,有时用几句话说一些强有力的东西可能会带来最大的打击。确保您所做的事情对您的数据和研究问题有意义。

一种方法是使用以下示例中的单词数(我更喜欢这里的第一种方法):

poldat2 <- with(mraja1spl, polarity(dialogue, list(sex, fam.aff, died)))

output <- scores(poldat2)
weight <- ((1 - (1/(1 + log(output[["total.words"]], base = exp(2))))) * 2) - 1
weight <- weigth/max(weight)
weight2 <- output[["total.words"]]/max(output[["total.words"]])

output[["weighted.polarity"]] <- output[["ave.polarity"]] * weight   
output[["weighted.polarity2"]] <- output[["ave.polarity"]] * weight2   
output[, -c(5:6)]


##    sex&fam.aff&died total.sentences total.words ave.polarity weighted.polarity weighted.polarity2
## 1       f.cap.FALSE             158        1641        0.083       0.143583793        0.082504197
## 2        f.cap.TRUE              24         206        0.044       0.060969157        0.005564434
## 3       f.mont.TRUE               4          29        0.079       0.060996614        0.001397106
## 4       m.cap.FALSE              73         651        0.031       0.049163984        0.012191207
## 5        m.cap.TRUE              17         160       -0.176      -0.231357933       -0.017135804
## 6     m.escal.FALSE               9         170       -0.164      -0.218126656       -0.016977931
## 7      m.escal.TRUE              27         590       -0.067      -0.106080866       -0.024092720
## 8      m.mont.FALSE              70         868       -0.047      -0.078139272       -0.025099276
## 9       m.mont.TRUE             114        1175       -0.002      -0.003389105       -0.001433481
## 10     m.none.FALSE               7          71        0.066       0.072409049        0.002862997
## 11  none.none.FALSE               5          16       -0.300      -0.147087026       -0.002925046

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 2015-05-24
    • 1970-01-01
    • 2011-08-10
    • 1970-01-01
    相关资源
    最近更新 更多