# An Explainable Artificial Intelligence Model for Detecting Xenophobic Tweets
## 4 Our Approach for Detecting Xenophobic Tweets
### Creating the Xenophobia Database  
For collecting our xenophobic database, we used the Twitter API [15] using the Tweepy Python library [75] implementation to filter the tweets by language, location, and keywords. The Twitter API offers free access to all Twitter data that the users generate, not only the text of the tweets that each user posts on Twitter, but also the user's information such as the number of followers, the date where the Twitter account was created, among others. Figure 2 shows the pipeline to develop our Xenophobia database. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Author**} & \multirow{2}{*}{**Problem**} & **Database** & **Extracted Features** & **Methods** & **Evaluation** & **Performance** \\  & & & **Origin** & & & **Metrics** & **Performance** \\ \hline \multirow{3}{*}{[PERSON] et al.} & \multirow{3}{*}{\(\star\) Xenophobia} & & \(\star\) Word n-grams & \(\star\) LR & \(\star\) F1 & \(\star\) 0.84 F1 \\  & & & \(\star\) Char n-grams & \(\star\) SVM & \(\star\) Rec & \(\star\) 0.87 Rec \\  & & & \(\star\) TF-IDF & \(\star\) NB & \(\star\) Prec & \(\star\) 0.85 Prec \\ \hline \multirow{3}{*}{[PERSON] et al.} & \multirow{3}{*}{\(\star\) Misogyn and Xenophobia} & & \(\star\) TF-IDF & \(\star\) SVM & \(\star\) F1 & \(\star\) 0.742 F1 \\  & & & \(\star\) FastText & \(\star\) NB & Rec & \(\star\) 0.739 Rec \\  & & & \(\star\) Emotion lexicon & \(\star\) Vote & \(\star\) Prec & \(\star\) 0.747 Prec \\  & & & \(\star\) DT & \(\star\) Acc & \(\star\) 0.754 Acc \\ \hline \multirow{3}{*}{[PERSON] et al.} & \multirow{3}{*}{\(\star\) Hate speech to journalists} & \multirow{3}{*}{\(\star\) Wikipedia  Twitter  Facebook  Other  Other 0  
We decided to keep only the raw text of each tweet to make a Xenophobia classifier based only on text. We made this decision to extrapolate this approach to other platforms because each social network has additional information that could not exist or is difficult to access on other platforms [76]. For example, detailed profile information as geopositioning, account creation date, preferred language; among others, are characteristics challenging to obtain (even not provided) in other social networks. In this way, the exclusion of additional information from the text allows focusing on its classification based solely on natural language processing techniques such as sentiment, semantic and syntactic analysis [77], which is more versatile for applying to any platform containing posts. As an additional configuration for obtaining the analyzed tweets, we used the (geo_search) Tweepy method with the parameters (query= \"USA\", granularity=\"country\"); consequently, it allowed us to collect tweets issued from the USA and using the English language. These data were collected in five weeks, from 27 June to 31 August 2021. The tweets publication date corresponds with the collection's date of the same. Each week 2000 tweets were downloaded. For the labeling process, we were supported by five experts. Two were psychologists, two were experts in international relations, and the last expert was a sociologist. These experts were in charge of labeling the tweets manually. Since a single Twitter API return can return, at most, 100 tweets per looked term, we followed the same scheme used by [PERSON] et al. [59]. We used a set of keywords regarding Xenophobia instead of a single immigration term. Some of our xenophobic keywords were the same as the ones used by [PERSON] et al., such as _immigration_, _migrant_, and _deport them all_. While our experts proposed a new set of keywords, among which are: _illegal aliens_, _backcountry_, and _violent_. Nevertheless, we also used a set of neutral terms to make our database more diversified, such as sports, food, travel, love, money, among others. As a result, a total of 10,073 tweets were annotated.