【发布时间】:2021-12-28 08:30:23
【问题描述】:
我有一个包含如下社交媒体帖子的数据集,但它是波斯语的,我找不到现成的 R/Python 情绪分析包。
post/tweet
"we are tired of this regime and need to make a change happen now"
理想情况下,我想将每个陈述分类为具有负面、正面或中性情绪。因此,我创建了一个小字典,将单词分为否定词或肯定词。
library(tidyverse)
library(stringr)
library(readxl)
#install.packages("tidyverse")
#install.packages("stringr")
#install.packages("readxl")
分为三个类别:正面、负面和中性
Raw_data_on_posts %>% mutate(p_count = str_count(post, str_c(Dictionary$positive, collapse = '|')),
n_count = str_count(post, str_c(Dictionary$negative, collapse = '|'))) %>%
mutate(label = case_when(p_count > n_count ~ 'positive',
p_count < n_count ~ 'negative',
TRUE ~ 'neutral')) %>% select(post, label)
尽管根据我对社交媒体帖子的阅读,我的大多数声明都是中立的,但要么支持伊朗政权,要么反对伊朗政权。具体来说,我认为这是因为它将我既不分类为负面也不分类为中性的词分类为中性词。但是是否可以只比较一个陈述是否有更多的否定词或肯定词?
post/tweet sentiment
"we are tired of this regime neutral
and need to make a change happen now"
我想知道上述问题是否是由于 R 无法识别/阅读波斯语单词和字母造成的?我之所以问是因为我在上面运行了相同的代码来用下面的英文单词对其进行测试,并且效果很好:
post
<chr>
label
<chr>
bad and good neutral
really good positive
in the middle neutral
bad negative
【问题讨论】:
标签: r nlp sentiment-analysis