【发布时间】:2021-01-27 22:35:43
【问题描述】:
我正在尝试根据文档中出现的单词对文档进行评分。对于语料库中出现的每个单词,我有两种类型的分数。它本质上类似于情感分析,但具有定制的字典和相应的分数。谢谢
#documents to be scored on 2 dimensions: score1 and score2
documents <- data.frame(textID = 1:3, text = c("Hello everybody, pleased to see everyone together", " DHL postmen have faced difficulties this year", "divorcees have trouble finding jobs in this country"), scored1 = rep(NA,3), scored2=rep(NA,3) )
#first scoring dimension
scores1 <- as.matrix(data.frame(words = c("hello", "everybody", "pleased", "to" ,"see", "everyone","together", "DHL", "postmen", "have", "faced","difficulties","this", "year", "divorcees", "trouble", "finding", "jobs", "in", "country" ), scores = 1:20))
#second scoring dimension
scores2 <- as.matrix(data.frame(words = c("hello", "everybody", "pleased", "to" ,"see", "everyone","together", "DHL", "postmen", "have", "faced","difficulties","this", "year", "divorcees", "trouble", "finding", "jobs", "in", "country" ), scores = 10:29))
#the result should look like this, where each text receives a score that represents the sum of #individual word scores:
#textID text scored1 scored2
#1 1 Hello everybody, pleased to see everyone together 28 91
#2 2 DHL postmen have faced difficulties this year 77 140
#3 3 divorcees have trouble finding jobs in this country 128 200
【问题讨论】:
-
不要。单独的文字对于情感分析是绝对没有用的。
-
这不仅仅是文字。我使用的分数实际上是平均词嵌入。我简化了问题。
标签: r nlp tidyverse tidyr sentiment-analysis