你會多少單字?Zipf 定律與主觀性詞彙表

R 情感分析

Ted Kwartler

Data Dude

主觀性詞彙表

library(qdap)
library(magrittr)

text_df %$% polarity(text)

回傳一個「polarity」物件,含正負分數。

主觀性詞彙表是預先定義的詞清單,標註情緒語境,如正向/負向,或特定情緒如「frustration」或「joy」。

R 情感分析

哪裡取得主觀性詞彙表?

  • qdappolarity() 使用 hash_sentiment_huliu 詞彙表

  • tidytext 提供 sentiments tibble,內含

    • NRC-依 8 種情緒(如「angry」或「joy」)與正/負標記的詞
    • Bing-標註為正向或負向的詞
    • AFINN-詞彙分數介於 -5 到 5
R 情感分析

library(lexicon)

Name Description
dodds_sentiment Mechanical Turk 情感詞彙
hash_emoticons 基本文字符號表情的對應 :)
hash_sentiment_huliu U of IL @CHI 的極性(+/-)詞彙研究
hash_sentiment_jockers 承襲自 library(syuzhet) 的詞彙表
hash_sentiment_nrc 群眾外包的 5,468 個詞,分數介於 -1 與 1 之間
R 情感分析

不可能!詞太少了。

思考

  • Zipf 定律
  • 最小努力原則
R 情感分析

Zipf 定律實例

Rank City 2010 Census Population Actual % Zipf's Expected %
1 New York 8,175,133 100% ...
2 LA 3,792,621 46% 50%
3 Chicago 2,695,598 33% 33%
4 Houston 2,100,263 26% 25%
5 Philadelphia 1,526,006 19% 20%
R 情感分析

最小努力原則

如果達成同一目標有多種方法,人們會選擇最省力的做法。

懶貓

R 情感分析

接下來…

twitter 標誌

football

R 情感分析

一起來練習吧!

R 情感分析

Preparing Video For Download...