r - 从 R 中的 qdap 包结果中获取 all.polity 值

标签 r rstudio sentiment-analysis text-analysis qdap

Screenshot of the data frame result我想使用 qdap 包在 R 中进行情感分析。 它给出一个包含 all.all、all.wc、all.polity、all.pos.words、all.neg.words 等的数据框。

我想提取 all.polity、all.pos.words、all.neg.words 的值,但是当我使用 情感$all.极性或情感$all.pos.words,

结果为 NULL。

dput(head(sentiment))

list(structure(list(all = c("all", "all", "all"), wc = c(44L, 
1L, 1L), polarity = c(-0.422115882408869, 0, 0), pos.words = list(
    "-", "-", "-"), neg.words = list(c("disappointed", "issue"
), "-", "-"), text.var = c("list(list(content = \"  misleaded  icici bank customer care  branch excutive    really disappointed   bank dont know  steps   take  get  issue fixed\", meta = list(author = character(0), datetimestamp = list(sec = 20.097678899765, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), heading = character(0), id = \"1\", language = \"en\", origin = character(0))))", 
"list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
"wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"), 
    structure(list(all = c("all", "all", "all"), wc = c(61L, 
    1L, 1L), polarity = c(0, 0, 0), pos.words = list("led", "-", 
        "-"), neg.words = list("expire", "-", "-"), text.var = c("list(list(content = \" didnt know   customer banking  icici   years will  led    people   looking  student travel card   staff  mg road     treat customers  tried  offer  card  wud expire  one year n told  get  new card  one year    dont know\", meta = list(author = character(0), datetimestamp = list(sec = 20.3989679813385, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), heading = character(0), id = \"1\", language = \"en\", origin = character(0))))", 
    "list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
    "wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"), 
    structure(list(all = c("all", "all", "all"), wc = c(58L, 
    1L, 1L), polarity = c(0, 0, 0), pos.words = list("top", "-", 
        "-"), neg.words = list("worst", "-", "-"), text.var = c("list(list(content = \"  asked   staff    can upgrade  platinum  coral card   documentation  fee will  involoved  even  receiving  card poeple sill keep calling   top      levied  rs joining fee    interested  paying     card  one   worst customer care   experienced\", meta = list(author = character(0), datetimestamp = list(sec = 20.648964881897, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), heading = character(0), id = \"1\", language = \"en\", \n    origin = character(0))))", 
    "list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
    "wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"), 
    structure(list(all = c("all", "all", "all"), wc = c(59L, 
    1L, 1L), polarity = c(-0.494717861727131, 0, 0), pos.words = list(
        "-", "-", "-"), neg.words = list(c("long time", "long time", 
    "disappointed"), "-", "-"), text.var = c("list(list(content = \" applied   credit card   corporate scheme long time back got  verification call also long time back initially   getting  least  response   executive  now    longer picking   call neither letting  know  status   application extremely disappointed   service\", meta = list(author = character(0), datetimestamp = list(sec = 20.8989698886871, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), heading = character(0), id = \"1\", \n    language = \"en\", origin = character(0))))", 
    "list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
    "wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"), 
    structure(list(all = c("all", "all", "all"), wc = c(66L, 
    1L, 1L), polarity = c(0.0246182981958665, 0, 0), pos.words = list(
        c("work", "support"), "-", "-"), neg.words = list("disappointed", 
        "-", "-"), text.var = c("list(list(content = \" otp service   working    used  work   month     decided  change everything im  getting  otp sms   registered mobile number ive tried contacting  customer support several times   keep asking   send  sms   despite  done  several times  several days  havent received  otps ever really disappointed\", meta = list(author = character(0), datetimestamp = list(sec = 21.1935319900513, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), \n    heading = character(0), id = \"1\", language = \"en\", origin = character(0))))", 
    "list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
    "wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"), 
    structure(list(all = c("all", "all", "all"), wc = c(50L, 
    1L, 1L), polarity = c(-0.282842712474619, 0, 0), pos.words = list(
        "-", "-", "-"), neg.words = list(c("pathetic", "lied"
    ), "-", "-"), text.var = c("list(list(content = \"  pathetic service  behavior  icici bank   facing  past  days icici executive lied  luring   upgrade  debit card terms  conditions  just opposite   booklet   received    told  phone\", meta = list(author = character(0), datetimestamp = list(sec = 21.4258019924164, min = 51, hour = 11, mday = 6, mon = 6, year = 115, wday = 1, yday = 186, isdst = 0), description = character(0), heading = character(0), id = \"1\", language = \"en\", origin = character(0))))", 
    "list()", "list()")), row.names = c(NA, -3L), .Names = c("all", 
    "wc", "polarity", "pos.words", "neg.words", "text.var"), class = "data.frame"))

有人可以建议如何做到这一点吗?

最佳答案

以下内容对我有用 -

 library(qdap)

 text <- "I am liking the work "  # the text for which polarity score is needed

 sentiment <- polarity(text) #make the call 

 sentiment$all$pos.words # returns the positive words detected by the algo
 #[[1]]
 #[1] "liking" "work"  

 sentiment$all$polarity # returns the sentence polarity score 
 #[1] 0.8944272

关于r - 从 R 中的 qdap 包结果中获取 all.polity 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31242629/

相关文章:

r - 自动格式化日期

java - 如何传递一个 rJava .jnew 调用多个参数?

r - 编译较旧的 R 版本并在 Ubuntu 和 RStudio 中的版本之间切换

php - 自动否定单词

Python情感分析(比较单词时,文本中重复的单词不计算在内)

r - 您是如何经历从 SPSS 到 R 的过渡的?

reshape 从宽到长,简单的 data.table 问题

r - 在 RStudio 中处理带有 .Rtex 扩展名的文件,如 knit/Sweave 文件

Rstudio 自动完成变量

java - 斯坦福情感分析评分java