简体   繁体   中英

Unable to use NRC lexicon in tidytext. Error in match.arg(lexicon) : 'arg' should be one of “afinn”, “bing”, “loughran”

I am learning sentiment analysis in R using tidytext package. However, i am unable to set nrc as lexicon. Whenever i type get_sentiments ("nrc"), the above error is displayed. It says that lexicon coud only be "afinn", "bing" or "loughran". I tried updating the package (tidytext) and also installed 'syuzhet' package but still the problem exists. Please help!

You can just replace;

nrc_joy <- get_sentiments("nrc") %>% 
  filter(sentiment == "joy")

with;

nrc_joy <- get_sentiments("afinn") %>% 
  filter(value == 2 |value == 3 | value == 4 | value == 5)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM