Description Usage Arguments Value Examples
Create word dictionary
1 | dict(x)
|
x |
Input can be a vector of words, a list of 'positive' and 'negative' word vectors, a data frame with 'word' and 'weight' columns |
A dictionary
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | pos <- c("like", "love", "amazing", "excellent", "great", "fantastic",
"incredible", "awesome", "best", "favorite", "fan", "fun", "enjoyed",
"good", "solid", "better", "soooo", "happy")
neg <- c("hate", "loathe", "dislike", "awful", "horrible", "worst",
"miserable", "ruin", "ruining", "destroy", "destroyed", "destroying",
"pathetic", "hated", "hateful", "unhappy", "terrible")
## create dictionary using only positive words
dict(pos)
## create dictionary using only negative words
dict(neg)
## create dictionary using both positive and negative words
d <- dict(list(pos = pos, neg = neg))
## view up to n entries of dictionary
print(d, n = 15)
## example text
txt <- c("love amazing excellent good",
"hate loathe horrifies unhappy terrible",
"awesome best hateful hated worst")
## get estimate for each element of txt using pos/neg dictionary
d$score(txt)
## create tibble
tibble::tibble(
text = txt,
sent = d$score_score(txt)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.