Analysis of offensive language in German tweets: General project description

In this capstone project, I am analyzing a publicly available dataset containing German tweets that were tagged for offensive language use. The dataset is the ‘DeTox-Dataset’, a German Offensive Language and Conversation Analysis dataset.

Christoph Demus, Jonas Pitz, Mina Schütz, Nadine Probol, Melanie Siegel, and Dirk Labudde. 2022. DeTox: A Comprehensive Dataset for German Offensive Language and Conversation Analysis.. In Proceedings of the Sixth Workshop on Online Abuse and Harms (WOAH), pages 143–153, Seattle, Washington (Hybrid). Association for Computational Linguistics.

The dataset is available in two versions and I am going to use the tsv-file. Data, codebook, and further information are available from https://github.com/hdaSprachtechnologie/detox.

Description of the dataset

The data contains 10,278 German Twitter comments collected in the first half of 2021. The comments were annotated for twelve categories by six annotators. The dataset contains all annotations of the three annotators as well as meta data such as annotation time.

The annotated categories are:

  • Whether the tweet is comprehensive [y/n]
  • Sentiment [-1, 0, 1]
  • Hate Speech [1, 0]
    • Hate Speech Entitites [free text input]
    • Type of Discrimination [10 types]
  • Criminal Relevance [y/n]
    • Legal Paragraphs [14 Paragraphs]
  • Expression [implicit/explicit]
  • Toxicity [1-5]
  • Extremism [y/n]
  • Target [person/group/public]
  • Threat [y/n]

All in all, the data thus contains 10,278 observations of 41 variables.

In opposition to what is stated in the general description of the dataset on the github page, Hate Speech Entities are not included in the dataset. Legal Paragraphs and Types of Discrimination as well as Targets are each represented as individual columns, each containing average ratings from multiple annotators. This is also true for the Hate Speech and Sentiment columns, where the values are not only -1, 0, and 1 as indicated in the codebook, but are averaged ratings. Thus, in order to analyze this dataset, there is a lot of data wrangling needed in order to bringt it into a format that is useful for analysis and visualization.

Analysis

Sentiment of tweets

In this section, I will give a general overview of the distributional properties of some of the variables included in the dataset.

First, let us look at a general overview over how many tweets are included in the dataset that are expressing a negative, a neutral or a positive sentiment. In general, it is expected that tweets expecting a negative sentiment are more likely to be of criminal relevance. Tweets of negative sentiment are also probably more likely to have higher overall toxicity ratings than tweets expressing neutral or positive sentiments.

The column for the sentiment of the original comment contains the sentiment (negative, neutral, positive) coded as -1, 0, and 1 respectively.

After cleaning the data (removing NAs, etc.) 10.167 tweets remain. The following figure displays the absolute values of tweets with positive, negative, and neutral sentiment.

As we can see, the majority of tweets are negative. This is to be expected in a dataset of tweets with potentially offensive language use.

Toxicity levels

The column for toxicity contains the toxicity rating (1-5) of the comment averaged over all annotations of the comment. The following figure shows a histogram of the frequency of the toxicity ratings over all tweets.

We can see that tweets with toxicity ratings from 1 to 2 are the most frequent. The red line denotes the mean toxicity rating (~ 1.6).

Sentiment and Criminal relevance

Since the data consists of tweets with offensive language use, the tweets have been tagged for criminal relevance. Being criminally relevant means that a tweet could serve as grounds for a criminal investigation based on German federal law. In the original data, the column for criminal relevance is coded with 1 for criminally relevant and 0 for criminally not relevant.

The above figure is a mosaic plot of the relationship between the criminal relevance of tweets and their sentiment rating. Their relationship is compared by means of Pearson residuals. Positive associations between categories, e.g. between neutral sentiment and no criminal relevance, are displayed in blue. The darker the blue, the stronger the positive correlation. Negative correlations are displayed in pink. The same holds here: The stronger the negative correlation, the darker the pink.

Interestingly, tweets with negative sentiment seem to be negatively correlated with criminal relevance. This means that they are less often judged as criminally relevant than to be expected. The proportion of tweets that are judged to be of relevance and have positive sentiment (n = 5) is too small to be displayed nicely in a mosaic plot. The same goes for tweets with neutral sentiment that have been judged as criminally relevant (n = 12). Overall, we can see that the majority of tweets is judged as not criminally relevant.

Sentiment and Toxicity Ratings

For the following figure, we will look at the distribution of toxicity ratings within the different levels of the sentiments of the tweets. The following visualization shows an interactive plotly rendering of a scatterplot of toxicity ratings per sentiment category.

The purple dots within each sentiment category denote the mean toxicity rating for this category. As expected, negative tweets have a higher mean toxicity rating than neutral and positive tweets. Additionally, we can see that while toxicity ratings are quite low in general, the maximum ratings for negative tweets are higher than for positive tweets. Interestingly, neutral tweets have outliers with toxicity ratings as high as the negative tweets, but the majority of their ratings is clustered between 1 and 2.5. There are also some positive tweets which show toxicity ratings between 3 and 4. These interesting data points would warrant a qualitative look at the data to find out how these tweets differ from the other ones in their respective sentiment category.

Types of Discrimation Uttered Against Different Targets

In the dataset, three different targets of offensive language use are identified: individuals, groups, and the public. In the following figure, I will visualize the distribution of the different types of discrimination in relation to these different targets. There are ten types of discrimination:

  • Job
  • Attitude,
  • Engagement,
  • Sexual Identity,
  • Characteristics,
  • Nation,
  • Religion,
  • Social Status,
  • Worldview,
  • Ethnicity.

The next figure is a correlation plot showing the correlations between the types of discrimination and the target group of the tweet. It aims to answer the question whether certain target groups are more likely to be targeted with specific kinds of discrimination.

In a correlation plot, the correlation coefficient (indicated by the colour and shown in the legend) measures the strength and direction of the linear relationship between two variables. The correlation coefficient can take values between -1 and 1, and these values indicate different levels and directions of correlation.

For the correlation between these variables, we find only weak correlations:

Weak positive correlations (0 < Correlation Coefficient < 0.3) indicated in red. A correlation coefficient between 0 and 0.3 suggests a weak positive correlation. It indicates that there is a positive relationship between the variables, but it’s relatively weak and may not be very meaningful. All the positive correlations are with groups as targets, while specific persons and the public do not show positive correlations at all.

White spaces in the plot indicate a correlation of 0, meaning no correlation at all.

Weak negative correlation (-0.3 < Correlation Coefficient < 0) can be seen within persons and groups as targets of discrimination. A correlation coefficient between -0.3 and 0 suggests a weak negative correlation.It implies that there is a negative relationship between the variables, but it’s relatively weak and may not be very meaningful.

Overall, the fact that positive correlations only occur within the target category of groups and that negative correlations only occur within the target categories of persons and the public indicates that there might be some issue with the underlying data that has not yet been uncovered.

Average Duration to Annotate Tweets

The data contains information about the average duration it took for the different annotators to annotate all the parameters for the respective tweet. The duration is given in seconds.

The figure below shows a density plot of the average durations.

We can see that the majority of tweets were annotated in a time between four and roughly four hundred seconds. The red line indicated the mean time it took to annotate the tweets, which is 88.52 seconds. The long right tail of the distribution indicates outliers with a really high duration. The maximum duration was 9751 seconds, which equals to roughly 162 minutes. It is questionable whether this is a realistic time or whether we are dealing with a faulty data point here, especially given the fact that the second highest value is 3607 seconds, which is equivalent to about 60 minutes. While still being a very long time, it is very far away from the maximum value of 162 minutes.

Explicit vs. Implicit Expression

The tweets were judged by different annotators in regard to whether a discrimination or threat in them is expressed implicitly or explicitly. The following figure is a mocaic plot showing the different ratings

What we can see is that there is a large overlap between the two categories, meaning that there are tweets which were rated as both explicit and implicit. This makes one doubt the reliability of these ratings.

Average Duration to Annotate Tweets and Explicit vs. Implicit Expression

The next figure will visualize the average duration for the annotation in relation to whether the discrimination was judged to be expressed implicitly or explicitly. Since it could be seen in the last figure that the ratings for explicit/implicit overlap, I will only consider data points here that were rated as either explicit or as implicit, but not as both. In addition, to create boxplots that do not look like flat lines due to the large outliers in the duration category, I will restrict the maximum duration to 500 seconds. Before plotting the data, we could assume that tweets where discrimination is expressed explicitly should on average take less time to annotate than tweets where the discrimination is only expressed implicitly.

Interestingly, the average confidence intervals overlap, so we see no significant difference between the time it took to annotate tweets that were judged as explicit or implicit. Additionally, we see a lot more outliers for the explicit tweets.

One probable cause for this result might be that these tweets might have been more difficult to judge in regard to the paragraphs from German law that are applicable to the threat/discrimination expressed in the tweets. In a real data analysis, the correlation between these parameters would now be the next step.