【发布时间】:2018-08-21 14:32:01
【问题描述】:
我有带有 cmets 列的调查数据。我期待对回复进行情绪分析。问题是数据中有多种语言,我不知道如何从集合中消除多个语言停用词
'nps' 是我的数据源,nps$customer.feedback 是 cmets 列。
首先我将数据标记化
#TOKENISE
comments <- nps %>%
filter(!is.na(cusotmer.feedback)) %>%
select(cat, Comment) %>%
group_by(row_number(), cat)
comments <- comments %>% ungroup()
摆脱停用词
nps_words <- nps_words %>% anti_join(stop_words, by = c('word'))
然后使用 Stemming 和 get_sentimets("bing") 按情绪显示字数。
#stemgraph
nps_words %>%
mutate(word = wordStem(word)) %>%
inner_join(get_sentiments("bing") %>% mutate(word = wordStem(word)), by =
c('word')) %>%
count(cat, word, sentiment) %>%
group_by(cat, sentiment) %>%
top_n(7) %>%
ungroup() %>%
ggplot(aes(x=reorder(word, n), y = n, fill = sentiment)) +
geom_col() +
coord_flip() +
facet_wrap( ~cat, scales = "free") +
scale_fill_brewer(palette = "Set1") +
labs(title = "Word counts by Sentiment by Category - Bing (Stemmed)", x =
`"Words", y = "Count")`
但是,由于正在分析德语文本,“di”和“die”出现在“否定”图中。
有人可以帮忙吗?
我的目标是使用上述代码消除德语停用词。
【问题讨论】:
标签: r text text-mining text-analysis