Improving multilingual lexicon-based sentiment analysis for Scandinavian languages

Baglini, Rebekah
Department of Linguistics, Cognitive Science, and Semiotics, Aarhus University; Interacting Minds Centre, Aarhus University
rbkh@cc.au.dk

Kurm, Anita
Center for Humanities Computing, Aarhus University
201608652@post.au.dk

Hansen, Lasse
Center for Humanities Computing, Aarhus University
lasseh0310@gmail.com

Enevoldsen, Kenneth
Center for Humanities Computing, Aarhus University
kenneth.enevoldsen@cas.au.dk

Table of contents

1. Introduction

In this paper, we address the challenge of multilingual sentiment analysis using traditional lexicon and rule-based tools, since these tools are inherently tailored to capture sentiment patterns in a particular language. Focusing on a case study of three closely related Scandinavian languages (Danish, Norwegian, and Swedish) using three tailored versions of VADER, we measured the relative degree of variation in valence using the OpenSubtitles corpus. We found that scores for Swedish systematically skewed lower their translational pairs in Danish, and that scores for Norwegian skewed higher than for both other languages. We then trained a neural network to optimize the fit of Swedish > Danish and Norwegian > Danish, effectively correcting this skew.

2. Background

Lexicon-based tools are widely used in automated sentiment analysis and opinion-mining tasks, and remain the most accessible and easy to validate method of performing sentiment analysis on a text corpus. One of the most popular tools of this kind is Valence Aware Dictionary and sEntiment Reasoner (VADER) (Hutto / Gilbert 2014).

Prior to this study, cross-linguistic comparative sentiment analysis using VADER required the use of the multilingual version of VADER (https://pypi.org/project/vader-multi/), which uses integration with Google Translate API to automatically translate the source language into English to produce sentiment scores. However, translation-based approaches are inadequate for high-fidelity multilingual sentiment analysis given the high degree of variation in the valency in the translational equivalents of evaluative, subjective, and expressive words and expressions (Jackson et al. 2019; Mohammed et al. 2016).

To avoid the problem of translation, we use an alternative approach to cross-linguistic VADER sentiment analysis which applies a normalization algorithm, trained on a parallel corpus, to adjust language-specific VADER model scores for Danish, Norwegian, and Swedish texts making them more comparable.

3. VADER Sentiment Analysis tools in Danish, Swedish, and Norwegian

The sentiment dictionaries used in this study build upon VADER (Hutto / Gilbert 2014), a dictionary- and rules-based approach to sentiment analysis on social media. The new Danish VADER builds upon previous rule-based approaches to Danish sentiment analysis namely SENTIDA (Lauridsen et al. 2019), EMMA (Kran / Orm 2020), and AFINN (Nielsen 2011) and extends upon them by adding support emoji and replacing the use of stems with lemmas. The Swedish utilized the publicly available VADER implementation of Swedish (Hutto 2017) while the Norwegian (Bokmål) used a translation of the Danish corpus translated and validated by two native speakers. As the dictionaries used are fairly small1 all models utilize lemmatization using Stanza (Peng et al. 2020) as opposed to the full word as the English2 VADER to obtain much wider coverage. These versions are freely available online on https://github.com/centre-for-humanities-computing/text to x.

Note that comparatively better performance have been found for sentiment analysis using attention-based model such as BERT (Devlin et al. 2019), but these treat sentiment as a classification problem (for instance, GLUE reduces the sst-2 to a classification task (Wang et al. 2019)).3

Language pairDataset sizeMean DanishMean SwedishMean Norwegian
Danish - Swedish1,902,6850.0230.013-
Danish - Norwegian1,920,4090.023-0.046
Swedish - Norwegian1,909,422-0.0120.047

Table 1: Total number of OpenSubtitles parallel sentences and mean VADER compound score

4. Parallel translation corpus for sentiment tool validation

The next step was to conduct pairwise comparisons of Danish, Swedish and Norwegian VADER sentiment tools using a corpus of translated movie subtitles (OpenSubtitles v.2018). From this corpus we sampled 1.9 million parallel sentence pairs for each language pair. We then applied our sentiment tools and calculated the average score (see Table 1).

Figure 1: Original VADER scores in Norwegian (blue), Swedish (yellow) and Danish (red) against each other. (Data: whole dataset reported in Table 1.)

From Table 1, we can see that in comparison to Danish VADER, our Norwegian VADER tool has a tendency to assign higher sentiment scores, while the Swedish VADER tool – lower scores. From Figure 1 (centre), we can also see that Norwegian and Swedish VADER tools are similarly aligned in relation to the Danish version. We therefore selected Danish VADER as the baseline, and developed Swedish-to-Danish and Norwegian-to-Danish models to improve alignment of the other two SA tools.

5. Model development and optimization

We first tried to identify data input features for optimal prediction of target Danish compound score. By testing various linear models and shallow artificial neural networks (Sequential model with 2-3 dense layers composed of 16, 32, 64 nodes) with different input features, we selected the following best features:

We applied Autokeras 1.0.2 [6] for automated neural network architecture selection with these features, and then optimized the hyperparameters using the sweep functionality from Weights and Biases [1] on a validation set consisting of 20% of the data. This was done using Bayesian grid search over the following parameters: number of units in each layer l1-5 (16-254), batch size (250-1000), dropout, and learning rate (0.0005-0.002). The resulting optimal parameters were: l1 111 units, l2 174 units, l3 225 units, l4 247 units, l5 36 units, batch size 623, dropout 0.06, learning rate 0.0005.

6. Effects of normalisation

A random sample (n=50,000) from the testing part of the dataset was selected for every language pair for evaluation of normalisation effects. As shown in the results in Table 2, normalisation produces almost identical mean sentiment values in parallel sentences, but has significantly decreased variation of sentiment scores in the normalised data.

Language pairDanishSwedishNorwegian
Danish - Swedishµ = 0.025, σ = 0.264µ = 0.025, σ = 0.104 ( µ = 0.014, σ = 0.272)-
Danish - Norwegianµ = 0.022, σ = 0.258-µ = 0.022, σ = 0.094 ( µ = 0.049, σ = 0.083)
Swedish - Norwegian-µ = 0.022, σ = 0.104µ = 0.024, σ = 0.094
( µ = 0.011, σ = 0.273)( µ = 0.048, σ = 0.284)

Table 2: Adjusted mean VADER compound scores and standard deviation after normalisation. Non-normed scores in parentheses. (Data: the 50K sample from the OpenSubtitles test set for each language pair)

Furthermore, Table 3 shows that normalisation of Swedish and Norwegian sentiment scores has led to an increase in correlation (measured with non-parametric Spearman correlation test) and decrease in RMSE across all three language pairs.

Table 3: Spearman correlation rs and RMSE before and after normalisation using the developed models. All reported correlation tests yielded p-value < 0.001. (Data: the 50K sample from the OpenSubtitles test set for each language pair).

7. Conclusion and future work

By applying a combination approach of language-specific sentiment scoring plus crosslingual score normalization, we hope to achieve a more satisfactory method for comparative lexicon-based sentiment analysis for these Scandinavian languages, without the use of automated translation.

Because this is work in progress, neither the baseline nor normalized scores produced by the three VADER models have yet been validated against a sentiment evaluation corpus. Existing resources (tagged sentiment corpora) for all three languages will be used in an upcoming benchmarking task, comparing our normalized scores with the compound scores of the three original VADER models and VADER multilingual.

Appendix A

Bibliography
  1. Biewald, Lukas (2020): Experiment Tracking with Weights and Biases <https://www.wandb.com/> [22.09.2021].
  2. Devlin, Jacob / Ming-Wei, Chang / Kenton, Lee / Toutanova, Kristina (2019): “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding”, in: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies 1 (Long and Short Papers) 4171– 4186. Minneapolis, Minnesota: Association for Computational Linguistics <https://www.aclweb.org/anthology/N19-1423> [22.09.2021].
  3. Hutto, C. J. / Gilbert, Eric (2014): “VADER: A Parsimonious Rule-Based Model for Sentiment Analysis of Social Media Text”, in: Proceedings of the International AAAI Conference on Web and Social Media 8, 1 <https://ojs.aaai.org/index.php/ICWSM/article/view/14550>.
  4. Hutto, C. J. (2017): vaderSentiment-swedish: VADER Sentiment Analysis. VADER (Valence Aware Dictionary and Sentiment Reasoner) swedish <https://github.com/AlexGustafsson/vaderSentiment-swedish> [22.09.2021].
  5. Jackson, Joshua Conrad / Watts, Joseph / Henry, Teague R / List, Johann-Mattis / Forkel, Robert / Mucha, Peter J. / Greenhill, Simon J. / Gray, Russell D / Lindquist, Kristen A (2019): “Emotion semantics show both cultural variation and universal structure”, in: American Association for the Advancement of Science (ed.): Science 366: 1517–1522.
  6. Jin, Haifeng / Song, Qingquan / Hu, Xia (2019): “Auto-Keras: An Efficient Neural Architecture Search System”, in: Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining 1946–1956. ACM.
  7. Kran, Esben / Orm, Søren (2020): “EMMA: Danish Natural-Language Processing of Emotion in Text”, in: Journal of Language Works - Sprogvidenskabeligt Studentertidsskrift 5: 1: 92–110 <https://tidsskrift.dk/lwo/article/view121221/> [22.09.2021].
  8. Lauridsen, Gustav Aarup / Dalsgaard, Jacob Aarup / Svendsen, Lars Kjartan Bacherva (2019): “SENTIDA: A New Tool for Sentiment Analysis in Danish", in: Journal of Language Works - Sprogvidenskabeligt Studentertidsskrift 4: 38–53 <https://tidsskrift.dk/lwo/article/view/115711> [22.09.2021].
  9. Mohammad, Saif M. / Salameh, Mohammad / Kiritchenko, Svetlana (2016): “How translation alters sentiment”, in: Journal of Artificial Intelligence Research 55: 95–130.
  10. Nielsen, Finn Arup (2011): “A new ANEW: Evaluation of a word list for sentiment analysis in microblogs”, in: arXiv 1103.2903.
  11. Qi, Peng / Zhang, Yuhao / Zhang, Yuhui / Bolton, Jason / Manning, Christopher D. (2020): “Stanza: A Python Natural Language Processing Toolkit for Many Human Languages”, in: arXiv 2003.07082 [cs] <http://arxiv.org/abs/2003> [22.09.2021].
  12. Wang, Alex / Singh, Amanpreet / Michael, Julian / Hill, Felix / Levy, Omer / Bowman, Samuel R. (2019): “GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding”, in: arXiv 1804.07461 [cs] <http://arxiv.org/abs/1804.07461> [22.09.2021].
Notes
1.

The Danish, Norwegian and Swedish contain 5264, 3214, and 5501 rated words, respectively.

2.

For reference the English VADER contain 50% more rated words than the Danish and Swedish models.

3.

For a full comparison of Danish NLP methods which nicely reflect these trends please see

https://github.com/alexandrainst/danlp/blob/master/docs/docs/tasks/sentiment_analysis.md.