# An Explainable Artificial Intelligence Model for Detecting Xenophobic Tweets
## 4 Our Approach for Detecting Xenophobic Tweets
### A New Feature Representation for Xenophobia Detection  
When we classify data in a text format, and we want to obtain good results, we must have a good machine learning classifier and an appropriate feature representation [78]. The problem with the feature representations based on numeric terms of the frequency of the words is that they are not accessible for human understanding [79]. In this way, our feature representation proposal was created to obtain good classification results and an interpretable model. Figure 3 shows the pipeline to develop our new feature representation proposal. To create our new feature representation proposal and make it interpretable, we decided to base our representation on three main bases: sentiment analysis, syntactic analysis, and the extraction of keywords (semantic analysis) related to the Xenophobia class. The sentimental analysis has been proved to be a good tool for making text classification using interpretable models [84]. The use of sentiment, syntactic and semantic analysis improves the classification results compared to the use of only sentiment analysis [77; 85]. The first step was to perform the sentiment analysis; Figure 3 shows the different cloud services that we use to perform the sentiment analysis. Table 3 shows a summary of the features extracted from the cloud services and the field to which they belong. The second step was to perform the syntactic analysis; we used the spaCy python library [83]. We employ the _en_core_web_lg_ pipeline that is specifically designed for \begin{table}
\begin{tabular}{c c} \hline \hline
**Class** & **Example** \\ \hline Non-venophobic & No wonder why the 4 Chan CHUDs have misunderstood the meaning of this movie and then made it their foundational text. https://tco./96M/CrHy3c \\  & i just received the best text in the world i truly love my friends so fracking much \\ \hline \multirow{4}{*}{Xenophobic} & @[PERSON]@FugginAlex The majority of the illegal alien migrant minors are not being brought by their real relatives anyways. Furthermore, if they are that sickly when they get, do not want them to make it into our cites. \\  & when they get here, do not want them to make it into our cites. \\ \cline{1-1}  & @learnin,as\_i,[EMAIL_ADDRESS] You want a country of criminal foreigners all different \\ \cline{1-1}  & colours smoking through being gay and living in a council block baby machine! \\ \cline{1-1}  & No middle class just poor people! \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Examples of tweets classified as xenophobic, non-xenophobic. Figure 3: The creation of our feature representation proposal consisted of using three NLP APIs (Parallel Dots [80], Meaning Cloud [81], IBM NLU [82]) to perform sentiment analysis and the Python spaCy library [83] for extracting the syntactic features and the keywords of the tweets. blogs, news, and comments. This pipeline is pre-trained on the OntoNotes Release 5.0 data [86]. With this library, we were enabled to extract different linguistic features using the spaCy Part-of-speech tagging implemented on its pipeline. For more information related to Universal POS tags, it can be visited the following document: [[https://universaldependencies.org/docs/u/pos/](https://universaldependencies.org/docs/u/pos/)]([https://universaldependencies.org/docs/u/pos/](https://universaldependencies.org/docs/u/pos/)) (accessed on 15 April 2021). The linguistic features extracted from spaCy are:  
* **ADJ:** (INT) The number of adjectives presented in the tweet. * **AUX:** (INT) The number of auxiliary verbs presented in the tweet. * **NUM:** (INT) The number of numbers presented in the tweet. * **PROPN:** (INT) The number of proper nouns presented in the tweet. * **ALPHAS:** (INT) The number of words presented in the tweet that are not stopwords. * **HASHTAGS:** (INT) The number of hashtags presented in the tweet. * **URLs:** (BOOL) If the tweet has a URL or not. Finally, the third step was to extract the most representative xenophobic words of the database according to their frequency.