【发布时间】:2020-05-27 15:35:14
【问题描述】:
考虑这个简单的例子
library(tibble)
library(quanteda)
tibble(mytext = c('this is a good movie',
'oh man this is really bad',
'quanteda is great!'))
# A tibble: 3 x 1
mytext
<chr>
1 this is a good movie
2 oh man this is really bad
3 quanteda is great!
我想进行一些基本的情绪分析,但有一点不同。这是我的字典,存储在常规的tibble
mydictionary <- tibble(sentiment = c('positive', 'positive','negative'),
word = c('good', 'great', 'bad'))
# A tibble: 3 x 2
sentiment word
<chr> <chr>
1 positive good
2 positive great
3 negative bad
本质上,我想计算每个句子中检测到的正面和负面单词的数量,同时还要跟踪匹配的单词。换句话说,输出应该是这样的
mytext nb.pos nb.neg pos.words
1 this is a good and great movie 2 0 good, great
2 oh man this is really bad 0 1 bad
3 quanteda is great! 1 0 great
如何在quanteda 中做到这一点?这可能吗?
谢谢!
【问题讨论】: