Get startedGet started for free

Introspection using sentiment analysis

1. Introspection using sentiment analysis

If you took the intro Text Mining course you covered comparison clouds. These visuals show dissimilar word frequencies. For sentiment analysis, you can use the values or emotions to subset a single corpus for use in a comparison cloud. And yes, I did advise you to avoid word clouds but here we go!

2. qdap's polarity for subsetting corpora

The first comparison cloud is based on qdap’s polarity. Using the polarity scores divide the corpus into positive and negative subsections. For this purpose the subsections represent complete positive or negative documents for the comparison cloud. This visual can be useful to explore feature based sentiment. For example if you analyze restaurant reviews positive reviews may state "good" and the negative section "rude" Thus, the food is good but the staff is rude since only people can be rude!

3. Comparing frequent words in Plutchik's Framework

In the next exercise you go beyond subsections based on positive and negative. You will inner join the NRC lexicon and Moby Dick text. Remember the NRC lexicon has 8 primary emotions and positive or negative. As a result the book words will be dissected into multiple subsections instead of just positive or negative.

4. Where's Waldo? Where isn't Waldo?

In another exercise you will want to drop the positive and negative words and only focus on the 8 primary emotions. You will use grepl along with the exclamation mark, negator, and regular expression or operator. Grep functions use regular expressions to search for character patterns. For example, you could use grep() searching for “Waldo” in x. grep() will return a 3 meaning “Waldo” was found in the third spot. Similarly grepl() will return a logical outcome. With grepl() only the third outcome is TRUE and all others are FALSE. Adding an exclamation with grepl() will switch TRUE or FALSE. Your exercise uses a grepl with exclamation point to negate the outcome.

5. Adding an "or" operator

If you are searching for Waldo or “Nicole” you utilize the or operator. The or is represented as a straight line found above the enter key on your keyboard. Now grepl() will search for either with its TRUE or FALSE return. Your exercise uses grepl() along with a negation as an exclamation point and searches with an or statement for Positive or Negative.

6. Stacked comparisons for polarity mixture

You may want to explore the mixture of a document in terms of the polarity or sentiment. So you will create a stacked bar chart of emotions to understand how much of a document is made of positive or negative terms. This can be useful for comparing multiple documents' sentiment make up.

7. Let's practice!