x <- c("I do not like whatsoever when an R package has soo many dependencies.",
"Making other people install java is annoying,
as it is a really painful experience in classrooms.")
if (FALSE) {
## Do the annotation to get the data.frame needed as input to txt_sentiment
anno <- udpipe(x, "english-gum")
}
anno <- data.frame(doc_id = c(rep("doc1", 14), rep("doc2", 18)),
paragraph_id = 1,
sentence_id = 1,
lemma = c("I", "do", "not", "like", "whatsoever",
"when", "an", "R", "package",
"has", "soo", "many", "dependencies", ".",
"Making", "other", "people", "install",
"java", "is", "annoying", ",", "as",
"it", "is", "a", "really", "painful",
"experience", "in", "classrooms", "."),
upos = c("PRON", "AUX", "PART", "VERB", "PRON",
"SCONJ", "DET", "PROPN", "NOUN", "VERB",
"ADV", "ADJ", "NOUN", "PUNCT",
"VERB", "ADJ", "NOUN", "ADJ", "NOUN",
"AUX", "VERB", "PUNCT", "SCONJ", "PRON",
"AUX", "DET", "ADV", "ADJ", "NOUN",
"ADP", "NOUN", "PUNCT"),
stringsasFactors = FALSE)
scores <- txt_sentiment(x = anno,
term = "lemma",
polarity_terms = data.frame(term = c("annoy", "like", "painful"),
polarity = c(-1, 1, -1)),
polarity_negators = c("not", "neither"),
polarity_amplifiers = c("pretty", "many", "really", "whatsoever"),
polarity_deamplifiers = c("slightly", "somewhat"))
scores$overall
scores$data
scores <- txt_sentiment(x = anno,
term = "lemma",
polarity_terms = data.frame(term = c("annoy", "like", "painful"),
polarity = c(-1, 1, -1)),
polarity_negators = c("not", "neither"),
polarity_amplifiers = c("pretty", "many", "really", "whatsoever"),
polarity_deamplifiers = c("slightly", "somewhat"),
constrain = TRUE, n_before = 4,
n_after = 2, amplifier_weight = .8)
scores$overall
scores$data
Run the code above in your browser using DataLab