get_dictionary.Rd
On a server, the sentiment dictionaries have to be manually uploaded. On a
local machine they can be loaded using {tidytext}
. Check to see if they
are already loaded (by a previous function run), if they are on disk
(which would indicate the code is on a server), or just load using
{tidytext}
.
get_dictionary(dictionary)
dictionary | A string. One of "afinn" (Nielsen, 2013), "nrc" (Mohammad & Turney, 2013) or "bing" (Hu & Liu, 2004), indicating the dictionary to be loaded. |
---|
A data frame with two columns: the word and its sentiment according to the requested sentiment dictionary.
Hu M. & Liu B. (2004). Mining and summarizing customer
reviews. Proceedings of the ACM SIGKDD International Conference on
Knowledge Discovery & Data Mining (KDD-2004), Seattle, Washington, USA,
Aug 22-25, 2004.
Mohammad S.M. & Turney P.D. (2013). Crowdsourcing a Word–Emotion
Association Lexicon. Computational Intelligence, 29(3):436-465.
Nielsen F.A. (2013). A new ANEW: Evaluation of a word list for
sentiment analysis in microblogs. Proceedings of the ESWC2011 Workshop
on 'Making Sense of Microposts': Big things come in small packages 718
in CEUR Workshop Proceedings 93-98. https://arxiv.org/abs/1103.2903.
Silge J. & Robinson D. (2017). Text Mining with R: A Tidy Approach.
Sebastopol, CA: O’Reilly Media. ISBN 978-1-491-98165-8.
get_dictionary("afinn")#> # A tibble: 2,477 x 2 #> word value #> <chr> <dbl> #> 1 abandon -2 #> 2 abandoned -2 #> 3 abandons -2 #> 4 abducted -2 #> 5 abduction -2 #> 6 abductions -2 #> 7 abhor -3 #> 8 abhorred -3 #> 9 abhorrent -3 #> 10 abhors -3 #> # ... with 2,467 more rowsget_dictionary("nrc")#> # A tibble: 13,901 x 2 #> word sentiment #> <chr> <chr> #> 1 abacus trust #> 2 abandon fear #> 3 abandon negative #> 4 abandon sadness #> 5 abandoned anger #> 6 abandoned fear #> 7 abandoned negative #> 8 abandoned sadness #> 9 abandonment anger #> 10 abandonment fear #> # ... with 13,891 more rowsget_dictionary("bing")#> # A tibble: 6,786 x 2 #> word sentiment #> <chr> <chr> #> 1 2-faces negative #> 2 abnormal negative #> 3 abolish negative #> 4 abominable negative #> 5 abominably negative #> 6 abominate negative #> 7 abomination negative #> 8 abort negative #> 9 aborted negative #> 10 aborts negative #> # ... with 6,776 more rows