# sample for dictionary-based sentiment analysis
weights <- data.table::data.table(
word = c("gut", "super", "herrlich", "schlecht", "grob", "mies"),
weight = c(1,1,1,-1,-1,-1)
)
corp <- corpus("GERMAPARLMINI")
sc <- subset(corp, date == "2009-11-11")
cnt <- count(sc, p_attribute = "word")
cnt <- weigh(cnt, with = weights)
y <- summary(cnt)
# old, partition-based workflow
p <- partition("GERMAPARLMINI", date = "2009-11-11")
p <- enrich(p, p_attribute = "word")
weights <- data.table::data.table(
word = c("gut", "super", "herrlich", "schlecht", "grob", "mies"),
weight = c(1,1,1,-1,-1,-1)
)
p <- weigh(p, with = weights)
summary(p)
Run the code above in your browser using DataLab