# Developing Analytical Tools for Arabic Sentiment Analysis of COVID-19 Data
## 3 Research Methodology
### Lexicon Construction
#### 3.1.2 Constructing a Lexicon Using the Trained Data
```
Input :Preprocessed annotated corpus Output :positive,negative, and neutral words // Step 1: Data Loading; Preprocessed_Annotated_tweets \(\leftarrow\)Dataset.get_AnnotatedTweets(); // Step 2: create matrix of unique words; foreachrow \(\in\)Preprocessed_Annotated_tweetsdo \(\textit{tweet\_words}\)\(\leftarrow\)\(\textit{row}(\textit{tweet\_text}).split(\"\")\) ; \(\textit{matrix\_add}(\textit{tweet\_words})\) ; // Step 3: Calculate the number of occurance of positive,negative,and neutral; foreachword w in matrixdo \(\#pos=0\), \(\#neg=0\), \(\#neu=0\); ifw in Positive tweetthen \(\#pos=\#pos+1\);  end foreach ifw in negative tweetthen \(\#neg=\#neg+1\); else \(\#neu=\#neu+1\);  end foreach // Step 4: calculate the score of positive,negative,and neutral; \(\textit{PositiveScore}=\frac{\sum_{i=1}^{L}\#pos(w,i)}{\sum_{i=1}^{L}\#pos(w,i)+ \sum_{i=1}^{L}\#neg(w,i)+\sum_{i=1}^{L}\#neu(w,i)}\) \(\textit{NegativeScore}=\frac{\sum_{i=1}^{L}\#neg(w,i)}{\sum_{i=1}^{L}\#pos(w,i)+ \sum_{i=1}^{L}\#neg(w,i)+\sum_{i=1}^{L}\#neu(w,i)}\) \(\textit{NeutralScore}=\frac{\sum_{i=1}^{L}\#neu(w,i)}{\sum_{i=1}^{L}\#pos(w,i)+ \sum_{i=1}^{L}\#neg(w,i)+\sum_{i=1}^{L}\#neu(w,i)}\) // Step 5: Decide the sentiment polarity of every word ; ifpositiveScore \(>\) NegativeScore &G positiveScore \(>\) NeutralScorethen  Word polarity \(\leftarrow\) Positive;  end if ifNegativeScore \(>\) PositiveScore &G NegativeScore \(>\) NeutralScorethen  Word polarity \(\leftarrow\) Negative;  else  Word polarity \(\leftarrow\) Neutral;  end if  end if  end for
```  
**Algorithm 1**Constructing a lexicon using the trained data. ``` Input :\(\textit{Preprocessed\_Annotated\_tweets}\) Output :positive,negative, and neutral words // Step 1: Data Loading; Preprocessed_Annotated_tweets \(\leftarrow\)Dataset.get_AnnotatedTweets(); // Step 2: create matrix of unique words; foreachrow \(\in\)Preprocessed_Annotated_tweetsdo \(\textit{tweet\_words}\)\(\leftarrow\)\(\textit{row}(\textit{tweet\_text}).split(\"\")\) ; \(\textit{matrix\_add}(\textit{tweet\_words})\) ; // Step 3: Calculate the number of occurance of positive,negative,and neutral; foreachword w in matrixdo \(\#pos=0\), \(\#neg=0\), \(\#neg=0\), \(\#neu=0\); ifw in Positive tweetthen \(\#pos=\#pos+1\);  end if \(\textit{tweetWe check the sentiment score of some words and presented the results in Table 5. For example, we found that the word \"\(\blacktriangle\)j\"/ crisis\" appeared 140 times in the negative tweets, 98 times in neutral tweets, and 104 times in the positive tweets. In accordance with the formula, the negative score of the word \"\(\blacktriangle\)j\"/ crisis is: \(140/(104+140+98)=0.4\), the neutral score is 0.2 while the positive score is 0.3. Based on the negative, positive, and neutral scores of the word, we can decide about its polarity. Thus, the word \"\(\blacktriangle\)j\"/ crisis carries a negative sentiment. we found that the word \"\(\blacktriangle\)j\"/ world\" appeared 5 times in the negative tweets, 67 times in neutral tweets, and 27 times in the positive tweets. In accordance with the formula, the neutral score of the word \"\(\blacktriangle\)j\"/ world \" is: \(67/\ (5+27+67)=0.67\), the negative score is 0.05 while the positive score is 0.27. We can decide the word's polarity by looking at its negative, positive, and neutral scores. So that, the word \"\(\blacktriangle\)j\"/ world\" holds a neutral sentiment. We found that the word \"\(\blacktriangle\)j\"/ patience\" appeared 130 times in the positive tweets, 5 times in negative tweets, and 48 times in the neutral tweets. In accordance with the formula, the positive score of the word \"\(\blacktriangle\)j\"/ patience\" is: \(130/\ (130+5+48)=0.67\), the negative score is 0.05 while the neutral score is 0.26. Based on the negative, positive, and neutral score of the word we can decide about its polarity. Thus, the word \"\(\blacktriangle\)j\" patience\" carries a positive sentiment. #### 3.1.3 Reforming and Revision

The tasks performed in this step are two-fold, duplicate checking as well as manual checking.