Analyze Sentiments of Tweets

With MAXQDA you can perform a sentiment analysis of tweets. This automatically evaluates whether tweet content is to be assessed as negative, neutral, or positive. The tweets can be sorted and filtered according to their sentiments, and the tweets can also be automatically coded with their sentiments for further analysis.

Perform sentiment analysis

A prerequisite for performing the sentiment analysis is that you have already imported tweets into the currently opened MAXQDA project.

  1. Open the analysis view for tweets via Analysis > Twitter > Analyze Tweets.
  2. In the dialog that appears, select all the Twitter documents you want to include in the analysis.
  3. After clicking Analyze Tweets, the following analysis view appears:
MAXQDA workspace for analyzing tweets
  1. Start the Sentiment Analysis by clicking on the Sentiment Analysis icon in the Start tab.
  2. In the dialog that appears, you can select various options:


    Options for sentiment analysis of tweets

    At the top, set the language of the tweets so that MAXQDA will use the appropriate resource for sentiment evaluation (currently: English only, more languages will follow).

    Ignore hashtags – if this option is enabled, hashtags, such as #bestever, are not taken into account when evaluating sentiment.

    Apply stop list – if this option is enabled, all words from the selected stop list will be ignored when evaluating the sentiment.

  3. After clicking OK, the sentiment analysis is performed and four columns are added to the tweet table:

    • Sentiment: Contains the rating of the tweet in five levels from “negative” to “positive”. tweets that do not contain words with a sentiment value are marked with “No sentiment”.
    • (Positive) Words: Number of words that were evaluated as positive.
    • (Negative) Words: Number of words that were evaluated as negative.
    • Difference: Difference between positive and negative words. If the number is negative, the negative words predominate.
Columns for sentiment analysis

You can sort the table by the newly added columns by clicking the column header with the mouse.

Note: The sentiment ratings of the tweets are only temporarily visible in the analysis window and are not saved. If you close and reopen the analysis window, you can run the sentiment analysis again with the same or different options.

Filter tweets by sentiment

Once you have determined the sentiments of the tweets, another filter area will appear in the left pane of the analysis view:

Sentiment filter

Here you can see how many tweets were evaluated positive, neutral, or negative. By selecting oen of the sentiments, you can filter the tweets, for example, only the “positive” and “Slightly positive” tweets can be displayed.

Create a diagram of the sentiments

  1. Click on Statistics in the Start tab to access the chart function.
  2. In the chart view that appears, open the drop-down menu at the top and select “Sentiment”.
Diagram for the frequency distribution of sentiments

Autocode tweets with sentiments

You can save the assignment of the sentiments to the individual tweets as codes in MAXQDA’s code system:

  1. Call the function Start > Autocode Tweets with Sentiment in the menu tab. The following dialog appears:
    Options for coding the tweets with their sentiment
  2. In the upper area you select the sentiments to be coded. For example, you can choose to code only the positive and slightly positive tweets. Select the Code filtered tweets only option to limit the coding to the currently listed tweets. For example, it is possible to code only tweets containing a specific hashtag with their sentiments.

After clicking OK, the selected sentiments are created as codes in the “Code System” window. If they already exist in the code system, the existing codes will be used for coding. The text of the selected tweets will be autocoded with the selected codes.

If you close the Analyze tweets window, you can continue working with the coded tweets. For example, activate Twitter documents and the code “Positive” to compile all positively evaluated tweets in the “Retrieved Segments” window.

Sentiment codes in the 'Code System' (left); Coded tweet in the 'Document Browser' (right)

How does MAXQDA evaluate the sentiments?

MAXQDA uses a lexicon to evaluate sentiments, which contains a sentiment score for each word in the lexicon. This value is negative for words with negative connotations, close to zero for neutral words, and positive for words with positive connotations.

When analyzing a tweet, MAXQDA checks each word whether it is contained in the lexicon and assigns the sentiment score to this word (hashtags and stop list words are ignored if desired). If the word is not in the lexicon, MAXQDA looks up the word in a lemma list. If a lemma is found for the word and this lemma is contained in the sentiment lexicon, the sentiment score of the lemma is used for the word.

In addition, two rules are applied to optimize the evaluation of sentiment:

  1. In case of negation, the scores of the following 3 words are reversed, for example, the statement “I was not very happy” is classified as negative.
  2. In case of modal verbs, such as “can”, “should”, etc., the sentiment scores of the following words are reduced.

The mean value is calculated from the sentiment scores of the evaluated words in a tweet. If the mean value is negative, the tweet is evaluated as “negative” or “slightly negative”, if the mean value is positive, the tweet is evaluated as “positive” or “slightly positive”. If the mean value is equal or close to zero, the tweet text is classified as “neutral”. Tweets that don’t contain any word with a sentiment score are classified as “no sentiment”.

Note: Sorting in the “Sentiment” column is based on the calculated sentiment value, not on the difference between positive and negative words.

In the literature on automatic sentiment analysis, values of 60 to 70% agreement compared to a human control assignment are usually reported. It has to be taken into account that human assessments of the same text can also differ. The quality of a sentiment analysis depends on several factors, especially the fit of the lexicon for a given topic. Please also note that a sentiment analysis has little meaning for tweets in which little to no evaluations are expressed.

English lexicon

The lexicon for English is based on the resource SentiWordNet 3.0, which is licensed under an Attribution-ShareAlike 4.0 Unported (CC BY-SA 4.0) license (for more info on SentiWordNet, see Baccianella, Esuli & Sebastiani, 2010). The SentiWordNet 3.0 lexicon has been optimized for use in MAXQDA, including

  • removal of special characters and duplicates
  • addition of typical social media abbreviations (e.g. LOL – laughing out loud), emojis, and superlatives
  • manual adjustment of scores for individual words to scores of their synonyms
Note: You can view and customize the lexicons used by MAXQDA for sentiment analysis. The lexicons are located in the “Resources\SentimentScore” subfolder of the MAXQDA installation folder:

Windows: local installation

C:\Programs\MAXQDA2020\Resources\SentimentScore

Windows: portable installation on USB stick

USB stick\MAXQDA2020

Mac: local installation

Program directory > Right mouse click on MAXQDA2020 > Show package contents:
Contents / Resources / SentimentScore

Mac: portable installation on USB stick

USB stick > MAXQDA 2020 Portable for Mac > Right mouse click on MAXQDA2020 > Show package contents:
Contents / Resources / SentimentScore

Bibliography

Baccianella, S.; Esuli, A.; Sebastiani, F. (2010). SentiWordNet 3.0: An Enhanced Lexical Resource for Sentiment Analysis and Opinion Mining. Proceedings of LREC. 10.
http://nmis.isti.cnr.it/sebastiani/Publications/LREC10.pdf