use*_*217 9 r sentiment-analysis
R中的"情绪"包已从Cran存储库中删除.什么是其他可以做情感分析的套餐?
例如,我如何使用其他包重写它?
library(sentiment)
# CLASSIFY EMOTIONS
classify_emotion(some_txt,algorithm="bayes",verbose=TRUE)
# classify polarity
class_pol = classify_polarity(some_txt, algorithm="bayes")
Run Code Online (Sandbox Code Playgroud)
这里的文件定义为:
# DEFINE text
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
"I am very scared from OP question, annoyed, and irritated.")
Run Code Online (Sandbox Code Playgroud)
ags*_*udy 12
我找不到sentiment
包.这是基于tm.plugin.sentiment
包.你可以在这里找到它.
首先,我创建我的语料库:
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
+ "I am very scared from OP question, annoyed, and irritated.")
text.corpus <- Corpus(VectorSource(some_txt))
Run Code Online (Sandbox Code Playgroud)
然后,我在语料库上应用分数
> text.corpus <- score(text.corpus)
Run Code Online (Sandbox Code Playgroud)
结果存储在元数据中:
> meta(text.corpus)
MetaID polarity subjectivity pos_refs_per_ref neg_refs_per_ref senti_diffs_per_ref
1 0 0 0.2857143 0.1428571 0.1428571 0.0000000
2 0 -1 0.1428571 0.0000000 0.1428571 -0.1428571
Run Code Online (Sandbox Code Playgroud)
代码背后的score
函数(默认行为),将使用这些tm函数预处理语料库:
然后,应用评分函数: