## 3 Proposed Work
### Dataset Preparation  
This study used the HARD dataset [17], the most significant standard and dialectical Arabic dataset containing emojis and emoticons. It was divided, similar to the authors' approach, into 80% for training and 20% for testing. The study conducted experiments on two variations of the dataset. The unbalanced dataset consists of 409,562 reviews, and the balanced dataset consists of 62,500 reviews, where each rating has 12,500 reviews. The reviews' data needed preprocessing to extract the following features in order to be used with the machine learning models: the total weight of positive words, the total weight of negative words, the emotions score, and the number of the following--positive words,negative words, negation words, booster words, repeated characters, question marks, exclamation marks, periods, and commas. There are two preprocessing methods; the method selected depends on the required generated feature. Both applied preprocessing methods involve emoji removal, Arabic diacritics removal, URL removal, special characters removal, and tokenization, and they differ only in applying punctuation removal. An exception is calculating the emotion scores, which did not require any preprocessing, as they only need to detect emojis and emoticons in the text for the computation.  
An example of applying data preprocessing steps with the case of removing punctuations from an Arabic review text is shown in Table 1; the other case of not removing punctuations is excluding the step that precedes the last one. The preprocessing steps involved using regular expressions, emojis, and NLTK libraries.  
There is another variation of the HARD dataset made for the unbalanced and balanced data. The indicated meanings of emojis and emoticons are related to the experiment using unbalanced and balanced data via the deep learning-based method, which includes showing the results before and after replacing emojis and emoticons with their meaning, as presented in Figure 1.  
Figure 2 shows an overview of the review's replacement process. The upcoming subsections will cover the details of the algorithms and the ArEmo lexicon. It is worth mentioning that the emoticon disambiguation algorithm is required while preparing the review data and when calculating the emotion scores for the ArEmo lexicon.  
\begin{table}
\begin{tabular}{p{142.3 pt} p{142.3 pt}} \hline \hline
**Preprocessing Step** & **Arabic Text** \\ \hline Original Arabic Text (Before Preprocessing) & Translation: “Disappointing. Had it not been for the hotel’s location, the hotel would not have been worth anything. The water was cut off many times + the electricity also went out for about half an hour \(\overleftarrow{\text{{{}}^{\text{{{}^{\text{{{}^{\text{{{}^{\text{{{}^{ \text{\text{\text{\text{\text{\text{\text{\text{\text{   }}}}}}}}}  
Algorithm 1 represents the algorithm for replacing emojis and emoticons in the reviews. This algorithm considers adding a space next to the word when it does the replacement, as some emojis or emoticons are attached to the text.  
```
Input: a review without uniform resource locators and enclosed brackets that do not belong to emoticons and the ArEmo Lexicon. Output: an updated review after replacing its emojis and emoticons with their estimated equivalent meaning. START
1. der ReplaceEmojEmotionWithMeaning(Review, ArEmoLexicon):
2. {
3. ReviewWords = Review.split()
4. for each key, value in ArEmoLexicon do
5. for each word in ReviewWords do
6. if key in word then
7. UpdatedReview = Review.replace(key, f\" [value] \")
8. UpdatedReview = re.sub(\" + - \", - \", UpdatedReview).strip()
9. return UpdatedReview
10. ]
```  
**END**  
**Algorithm 1**Emoj and Emoticon Replacer Algorithm