## Appendix A
do:  current_hashtag \(\leftarrow\) append the character at position i of tweet  increment i  append current_hashtag to hashtags list else:  increment i for each h in hastags do: if h is in top_hashtags then:  if the sentiment of current row is positive then:  increment the tweet_counts by combining key h with pos  else if the sentiment of current row is negative then:  increment the tweet_counts by combining key h with neg  else:  increment the tweet_counts by combining key h with neut  for each key in tweet_counts do:  update the t value at key and combine month and year with value tweet_counts End of for loop  Plot the sentiment distribution graph per hashtag (using matplotlib) Export_CSV with sentiment labels for each Tweet
```
**Algorithm A7: Data Preprocessing**
```
Input: Dataset Output: Preprocessed Dataset File Path Read data as dataframe English words: nltk.download('words') Stopwords: nltk.download('stopwords') Initialize an empty list to store preprocessed text corpus[]
```
**Algorithm A8: Data Preprocessing**
``` for i from 0 to n do  Obtain Text of the Tweet ('text' column)  text \(\leftarrow\) re.sub(['a=Z-Z], ', string)/RegEx to remove characters that are not alphabets  text \(\leftarrow\) re.sub('http(S+', '', string)//RegEx to remove URLs  text \(\leftarrow\) text.lower()  text \(\leftarrow\) review.split()  ps \(\leftarrow\) PorterStemmer()//stemming  all_stopwords \(\leftarrow\) stopwords.words('english')  text \(\leftarrow\)[ps.stem(word for word in text if not word in set(all_stopwords)]  text \(\leftarrow\) '':join(review) //Regex to remove user mentions and special characters  text \(\leftarrow\) '':join(res.sub(''(#[A-Za-z0-9]+)|(@[A-Za-z0-9]+)|(['0-9A-Za-z \(\backslash\)t])|(\(\backslash\)w+:\(\backslash\)\(\backslash\)  
```
for each keyword in keywords: if keyword is found in text: return True return False End of for loop End of Function remove_duplicates()//function to remove any duplicates based on Tweet ID Export result_potentially_sarcastic_Tweets.csv
```  
**Algorithm A9: Detect Tweets That Contain News**  
Input: Dataset Output: CSV file with Tweets that contained News File Path Read data as dataframe count = 0 for i from 0 to n **do** Obtain Text of the Tweet ('text' column) retrieve element from text_column at position index RegEx to remove characters that are not alphabets RegEx to remove URLs **if** \"news\" in text: count \(\leftarrow\) count + 1 End of for loop Function SubstringAnalysis(text, keywords): text \(\leftarrow\) lowercase(text) for each keyword in keywords: if keyword is found in text: return True return False End of for loop End of Function remove_duplicates()//function to remove any duplicates based on Tweet ID Export result_news_Tweets.csv ```
**Algorithm A10: Fine Grain Sentiment Analysis**
``` Input: Dataset Output: CSV file with a fine grain sentiment label for each tweet File Path Read data as dataframe English words: nltk.download('words') Stopwords: nltk.download('stopwords') Algorithm A7 for Data Preprocessing() Initialize an empty list to store preprocessed text corpus[] for each i from 0 to n **do** Obtain Text of the Tweet ('text' column) Initialize classifier (return_all_scores = True) apply classifier on the text score [] \(\leftarrow\) scores for Anger, Disgust, Fear, Joy, Neutral, Sadness, & Surprise max_value \(\leftarrow\) maximum value in Score[] label \(\leftarrow\) class for max_value append values to corpus End of for loop

## References

* (1) [PERSON]; [PERSON] Mining Social Media: A Brief Introduction. In _2012 TutORials in Operations Research_; INFORMS: Catonsville, MD, USA, 2012; pp. 1-17. * (2) [PERSON]; [PERSON]; [PERSON] Opinion Mining in Online Social Media: A Survey. _Soc. Netw. Anal. Min._**2022**, 12, 25. [CrossRef]
* (3) [PERSON] Definitions, Social Media Types, and Tools. In _Social Media Management_; Springer International Publishing: Cham, Switzerland, 2022; pp. 21-50, ISBN 9783030990930. * (4) [PERSON]; [PERSON]; [PERSON]; [PERSON] Twitter and Research: A Systematic Literature Review through Text Mining.