## 3 Datasets and Methods
### Preprocessing  
Before the feature extraction, preprocessing is applied to the text in order to clean it and keep only those terms that provide real information for sentiment detection. It is possible to outline in points the action that the cleaning function will perform on our corpus:  
* Removal of mentions and URLs from the text.
* Hashtags can provide value, so the # symbol is simply removed.
* Removal of punctuation marks.
* All text is made lowercase.
* Removal of words shorter than 2 characters.  
It is important to note the role of emojis in qualifying the sentiment that the author of a message wants to convey, so it makes sense to develop two different cleanup functions, each resulting in a different set of data:  
1. Cleaned text and cleaned text and lemmatised text.
2. Cleaned text and cleaned and lemmatised text, using the emoji ([[https://pypi.org/project/emoji](https://pypi.org/project/emoji)]([https://pypi.org/project/emoji](https://pypi.org/project/emoji)), accessed on 3 July 2022) package to translate emotion icons into text strings and remove stop-words.  
Both datasets were tested to compare the performance of each model. Finally, it should be noted that after each text cleaning function, duplicate tweets were detected and removed. This inevitably reduces the number of tweets but increases the quality of our data. In the end, we obtained 2 datasets depending on the cleaning function applied:  
1. 100,105 tweets: cleaned and lemmatised text.
2. 98,701 tweets: cleaned, lemmatised, taking into account emojis and without stop-words.  
For ease of reference, each dataset will be referred to by its respective number (1 or 2). It should be clearer if you look at the flowchart in Figure 2.  
Once the text has been captured, cleaned up and the appropriate preprocessing transformations have been applied, it moves on to the feature extraction phase. When working with text, in order to make the text set usable for the learning task, it needs to be converted into numerical vectors. We have used two techniques to extract these vectors, so that they can be used by ML models:  
* Bag of Words (BOW): A common vocabulary is created for all documents with all unique terms. A matrix of dimensions \(n\times m\) is created, where \(n\) represents the number of documents and \(m\) the terms, and it is marked with 1 if the word is present in the text and with 0 if it is not [11; 12].
* Term Frequency-Inverse Document Frequency (TF-IDF): Performs a weighting to promote the least common terms and discount the most frequent terms. This technique  
Figure 1: Single dataset class proportion.  
relates the number of times a term appears in a document (TF) to the number of documents in which it appears [13].  
The major drawback of the two previous feature extraction techniques is the loss of the relationship between words and, as a consequence, the context of a document. To overcome this problem, we have used a third extraction technique:  
* Word Embeddings: The idea is to assign to similar terms close vectors of a continuous and multidimensional vector space in a way that makes it possible to calculate similarities between words or sentences thanks to the distance between vectors, as well as to generalise a sentence into similar sentences, since the vectors will be similar [14].