
194
■
9
章 ケーススタディ:
Usenet
テキストの分析
9.3.1
単語ごとのセンチメント分析
ある種のニュースグループがほかのニュースグループよりもポジティブ、あるい
はネガティブな感じになる理由を理解するために、データをもう少し深く掘り下げ
てみましょう。個々の単語がポジティブ
/
ネガティブな感情にどれだけ寄与してい
るかを調べてみます。
contributions <- usenet_words %>%
inner_join(get_sentiments("afinn"), by = "word") %>%
group_by(word) %>%
summarize(occurences = n(),
contribution = sum(score))
contributions
## # A tibble: 1,909
×
3
## word occurences contribution
## <
chr> <int> <int>
## 1 abandon 13 -26
## 2 abandoned 19 -38
## 3 abandons 3 -6
## 4 abduction 2 -4
## 5 abhor 4 -12
## 6 abhorred 1 -3
## 7 abhorrent 2 -6
## 8 abilities 16 32
## 9 ability 177 354
## 10 aboard
8 8
## # ... with 1,899 more rows
センチメントスコア全体に最も大きな影響を与えた単語はどれでし ...