R中的情感分数分析

问题描述 投票:0回答:1

我正在从kaggle复制以下代码

我收到错误均值错误:未找到对象“得分”对于我的一生,我无法弄清楚,我是r的新手,我正在练习代码,请帮助

计算每个脚本行的情感


calculate_sentiment <- function(review_text)
{
  sentiment_lines  =  review_text %>%
                  unnest_tokens(word, text) %>%
                  inner_join(get_sentiments("afinn"), by = "word") %>%
                  group_by(postID) %>%
                  summarize(sentiment = mean(score),words = n()) %>%
                  ungroup() %>%
                  filter(words >= 5) %>%
                  arrange(desc(sentiment))

  return(sentiment_lines)

}
sentiment_lines = calculate_sentiment(scripts)

r sentiment-analysis
1个回答
0
投票

由于缺少可复制的示例,我想您可能会在这里找到答案:https://www.kaggle.com/ambarish/seinfeld-text-mining-wordembeddings-modelling

行:846-851。更具体地说,在850行中:

summarize(score = sum(score * n) / sum(n)) %>%

尝试使用上面的函数中的代码来代替您的代码。

© www.soinside.com 2019 - 2024. All rights reserved.