Sentiment analysis for software engineering: How far can zero-shot learning (ZSL) go?
Organizations: Department of Software Engineering, College of Computer and Information Sciences, King Saud University, P.O. Box 51178, Riyadh 11543, Saudi Arabia
Abstract
Sentiment analysis in software engineering focuses on understanding emotions expressed in software artifacts. Previous research highlighted the limitations of applying general off-the-shelf sentiment analysis tools within the software engineering domain and indicated the need for specialized tools tailored to various software engineering contexts. The development of such tools heavily relies on supervised machine learning techniques that necessitate annotated datasets. Acquiring such datasets is a substantial challenge, as it requires domain-specific expertise and significant effort. Objective: This study explores the potential of ZSL to address the scarcity of annotated datasets in sentiment analysis within software engineering Method:} We conducted an empirical experiment to evaluate the performance of various ZSL techniques, including embedding-based, NLI-based, TARS-based, and generative-based ZSL techniques. We assessed the performance of these techniques under different labels setups to examine the impact of label configurations. Additionally, we compared the results of the ZSL techniques with state-of-the-art fine-tuned transformer-based models. Finally, we performed an error analysis to identify the primary causes of misclassifications. Results: Our findings demonstrate that ZSL techniques, particularly those combining expert-curated labels with embedding-based or generative-based models, can achieve macro-F1 scores comparable to fine-tuned transformer-based models. The error analysis revealed that subjectivity in annotation and polar facts are the main contributors to ZSL misclassifications. Conclusion: This study demonstrates the potential of ZSL for sentiment analysis in software engineering. ZSL can provide a solution to the challenge of annotated dataset scarcity by reducing reliance on annotated dataset.
Figures & tables
| Dataset Name | Total | Polarity distribution |
| API reviews | 4,522 | Positive (890), negative (496), and neutral (3,136) |
| Gerrit | 1,600 | Negative (398) and non-negative (1,202) |
| GitHub | 7,122 | Positive (2,013), negative (2,087), and neutral (3,022) |
| Gitter | 201 | Positive (127) and negative (74) |
| Google Play | 341 | Positive (186), negative (130), and neutral (25) |
| Jira | 926 | Positive (290) and negative (636) |
| Approach | Model | Identifier |
| Embedding-based ZSL | BERT-base-uncased | E_M1 |
| RoBERTa-base | E_M2 | |
| DistilBERT-base-uncased | E_M3 | |
| ALBERT-base-v2 | E_M4 | |
| XLNet-base-cased | E_M5 | |
| All-MiniLM-L12-v2 | E_M6 |
| Identifier | Category | Description | Example |
| L1 | Original | Labels used as originally described in each dataset, where emotions were mapped to corresponding sentiments (i.e., joy and love to positive; anger and sadness to negative). | Positive |
| L2 | Expert-curated | Labels that use the term sentiment to describe the type of instances in each dataset, where neutral is described using negations of both sentiments. | A positive app review |
| L3 | Expert-curated | Labels describing the type of dataset instances with attached sentiment using “with” along with the term “sentiment”, where neutral is described using negations of both sentiments. | An app review with positive sentiment |
| L4 | Expert-curated | Labels describing the type of dataset instances with attached sentiment and associated original emotions mapped to the sentiment (i.e., joy and love for positive; anger and sadness for negative) using “with” and the term “sentiment” , where neutral is described using negations of both sentiments and their associated emotions. | An app review with positive, joy, or love sentiments |
| L5 | Expert-curated | Labels describing the type of dataset instances with only the emotions mapped to the sentiment (i.e., joy and love for positive; anger and sadness for negative) using “with”, where neutral is described by negating both the sentiments associated emotions. | An app review with joy or love sentiments |
| L6 | LLM -generated | Labels describing the type of dataset instances with only words generated by the LLM using “with”, where neutral is described by negating both sentiments associated words. | An app review with cheerfulness, happiness, amusement, satisfaction, bliss, gaiety, glee, jolliness, joviality, joy, delight, enjoyment, gladness, jubilation, elation, ecstasy, euphoria, zest, enthusiasm, excitement, thrill, zeal, exhilaration, contentment, pleasure, and optimism sentiments |
| Model | Identifier |
|---|---|
| BERT-base-cased | F_M1 |
| RoBERTa-base | F_M2 |
| DistilBERT-base-uncased | F_M3 |
| ALBERT-base-v1 | F_M4 |
| XLNet-base-cased | F_M5 |
| Model | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| Embedding-based ZSL | ||||||||||||||
| E_M1 | 0.37 | 0.48 | 0.2 | 0.25 | 0.26 | 0.39 | 0.29 | 0.38 | 0.27 | 0.36 | 0.61 | 0.75 | 0.33 | 0.4 |
| E_M2 | 0.12 | 0.13 | 0.43 | 0.75 | 0.18 | 0.3 | 0.33 | 0.39 | 0.19 | 0.38 | 0.48 | 0.7 | 0.17 | 0.28 |
| E_M3 | 0.37 | 0.48 | 0.21 | 0.26 | 0.4 | 0.41 | 0.47 | 0.52 | 0.27 | 0.36 | 0.59 | 0.6 | 0.5 | 0.5 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| E_M1_L2 | 0.22 | 0.25 | 0.2 | 0.25 | 0.23 | 0.44 | 0.54 | 0.55 | 0.05 | 0.07 | 0.72 | 0.72 | 0.28 | 0.38 |
| E_M1_L3 | 0.45 | 0.57 | 0.2 | 0.25 | 0.49 | 0.5 | 0.43 | 0.46 | 0.04 | 0.07 | 0.9 | 0.92 | 0.48 | 0.53 |
| E_M1_L4 | 0.22 | 0.23 | 0.43 | 0.75 | 0.27 | 0.33 | 0.29 | 0.38 | 0.37 | 0.47 | 0.59 | 0.74 | 0.32 | 0.33 |
| E_M1_L7 | 0.16 | 0.21 | 0.45 | 0.71 | 0.15 | 0.28 | 0.39 | 0.63 | 0.27 | 0.55 | 0.24 | 0.31 | 0.27 | 0.39 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| N_M1_L1 | 0.41 | 0.42 | 0.66 | 0.71 | 0.56 | 0.57 | 0.89 | 0.9 | 0.61 | 0.85 | 0.93 | 0.94 | 0.63 | 0.65 |
| N_M1_L2 | 0.4 | 0.41 | 0.68 | 0.74 | 0.58 | 0.59 | 0.92 | 0.93 | 0.68 | 0.83 | 0.92 | 0.93 | 0.68 | 0.69 |
| N_M1_L3 | 0.47 | 0.61 | 0.49 | 0.49 | 0.47 | 0.53 | 0.92 | 0.92 | 0.66 | 0.83 | 0.9 | 0.91 | 0.73 | 0.74 |
| N_M1_L4 | 0.22 | 0.22 | 0.27 | 0.3 | 0.46 | 0.52 | 0.89 | 0.9 | 0.59 | 0.82 | 0.9 | 0.91 | 0.47 | 0.56 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| T_M1_L1 | 0.49 | 0.63 | 0.64 | 0.7 | 0.49 | 0.52 | 0.77 | 0.78 | 0.59 | 0.67 | 0.89 | 0.9 | 0.62 | 0.62 |
| T_M1_L2 | 0.36 | 0.68 | 0.55 | 0.58 | 0.5 | 0.54 | 0.83 | 0.84 | 0.6 | 0.68 | 0.82 | 0.84 | 0.63 | 0.63 |
| T_M1_L3 | 0.33 | 0.46 | 0.52 | 0.59 | 0.44 | 0.44 | 0.62 | 0.62 | 0.58 | 0.65 | 0.6 | 0.64 | 0.36 | 0.36 |
| T_M1_L4 | 0.3 | 0.39 | 0.5 | 0.64 | 0.38 | 0.41 | 0.43 | 0.46 | 0.47 | 0.53 | 0.5 | 0.57 | 0.3 | 0.3 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| G_M1_L1 | 0.52 | 0.58 | 0.75 | 0.8 | 0.73 | 0.73 | 0.9 | 0.91 | 0.67 | 0.89 | 0.88 | 0.89 | 0.72 | 0.73 |
| G_M1_L2 | 0.5 | 0.57 | 0.72 | 0.77 | 0.73 | 0.73 | 0.88 | 0.89 | 0.66 | 0.89 | 0.76 | 0.77 | 0.76 | 0.76 |
| G_M1_L3 | 0.5 | 0.57 | 0.72 | 0.77 | 0.64 | 0.65 | 0.86 | 0.88 | 0.62 | 0.86 | 0.82 | 0.82 | 0.72 | 0.73 |
| G_M1_L4 | 0.51 | 0.63 | 0.75 | 0.82 | 0.82 | 0.82 | 0.91 | 0.92 | 0.62 | 0.87 | 0.8 | 0.8 | 0.74 | 0.74 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| reviews | Play | |||||||||||||
| Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | Mac | Mic | |
| Embedding-based ZSL models | ||||||||||||||
| E_M9_L1 | 0.47 | 0.49 | 0.43 | 0.75 | 0.61 | 0.62 | 0.95 | 0.95 | 0.6 | 0.86 | 0.99 | 0.99 | 0.64 | 0.67 |
| E_M9_L2 | 0.56 | 0.67 | 0.79 | 0.84 | 0.74 | 0.73 | 0.95 | 0.95 | 0.6 | 0.86 | 0.96 | 0.97 | 0.77 | 0.77 |
| E_M9_L3 | 0.58 | 0.67 | 0.79 | 0.86 | 0.79 | 0.78 | 0.95 | 0.95 | 0.6 | 0.86 | 0.96 | 0.97 | 0.81 | 0.81 |
| M&L | API | Gerrit | GitHub | Gitter | Jira | SO | |
|---|---|---|---|---|---|---|---|
| reviews | Play | ||||||
| Test set size | 452 | 160 | 713 | 21 | 35 | 93 | 443 |
| ZSL -based models | |||||||
| E_M9_L1 | 229 | 40 | 270 | 1 | 5 | 1 | 148 |
| E_M9_L2 | 148 | 25 | 193 | 1 | 5 | 3 | 101 |
| E_M9_L3 | 149 | 23 | 154 | 1 | 5 | 3 | 86 |
Sentiment Analysis
Sentiment analysis detects and measures opinions, emotions, and evaluative stance in text and multimodal data.
See all 127 papers