这是一个基本的情绪示例。通过该get_sentences
函数将文本数据拆分为句子。我们为列表的整个元素(在本例中)sentiment_by
近似文本的情感(极性)。mytext
例如,例如:
library(sentimentr)
mytext <- c(
'do you like it? But I hate really bad dogs',
'I am the best friend.',
'Do you really like it? I\'m not a fan'
)
mytext <- get_sentences(mytext)
sentiment_by(mytext)
我得到了以下结果:
element_id word_count sd ave_sentiment
1: 1 10 1.497465 -0.8088680
2: 2 5 NA 0.5813777
3: 3 9 0.284605 0.2196345
在应用情感功能之前,我想从mytext
. 我想我可以使用,例如:
library("tm")
tm_map(mytext, removeNumbers)
tm_map(mytext, removeWords, stopwords())
但我得到:
Error in UseMethod("tm_map", x) :
no applicable method for 'tm_map' applied to an object of class "c('get_sentences',
'get_sentences_character', 'list')"