Learn Emotion Analysis with R: Perform Sentiment Assessments, Extract Emotions, and Learn NLP Techniques Using R and Shiny by Partha Majumdar

Learn Emotion Analysis with R: Perform Sentiment Assessments, Extract Emotions, and Learn NLP Techniques Using R and Shiny by Partha Majumdar

Author:Partha Majumdar [Majumdar, Partha]
Language: eng
Format: epub
Publisher: BPB Publications
Published: 2021-08-15T00:00:00+00:00


The same word can be used to express a positive emotion in one context and a negative emotion in a different context.

Similarly, we can generate the list of words which express negative emotions.

We can now generate the sentiment score of each word using an inner join with the lexicon shown as follows:

v_word_count <- v_tidy_data %>%

inner_join(get_sentiments(v_lexicon)) %>%

count(word, sentiment, sort = TRUE)

## Joining, by = "word"

head(v_word_count, 15)

## # A tibble: 15 x 3

## word sentiment n

## <chr> <chr> <int>

## 1 system trust 45

## 2 management positive 25

## 3 management trust 25

## 4 solution positive 25

## 5 information positive 14

## 6 ministry joy 13

## 7 ministry positive 13

## 8 ministry trust 13

## 9 team trust 13

## 10 technology positive 12

## 11 architecture trust 10

## 12 government fear 10

## 13 government negative 10

## 14 assurance positive 9

## 15 assurance trust 9

We can see the number of times that each word expresses an emotion in the text. See the example of the word management in the preceding output. It expressed positive sentiments in 25 contexts, and it expressed the emotion of trust in 25 contexts.

We can visualize this output using the ggplot() function from the ggplot2 library shown as follows:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.