# A Web Interface for Analyzing Hate Speech
## 2 Materials and Methods
### Data Analysis  
The most notable analysis methods that are used in the PHARM software concern date, time, and geolocation estimation, language detection, hate speech detection, and sentiment analysis. Various software libraries have been deployed for implementing the supported analysis methods, along with custom algorithms that have been developed specifically for the PHARM software. A brief description of these methods follows. Language Detection: The PHARM software mainly processes text produced in Greek, Italian, and Spanish languages but many of the sources may contain texts in other languages or local dialects [53]. To work with these three national languages, a procedure to detect the language of the media text when it is not properly declared has been specified. An ensemble approach for improved robustness is adopted, querying various language detection libraries simultaneously. Amongst the used libraries are the textblob and googletrans Python libraries [54; 55]. Geolocation Estimation: Geolocation identification of the collected texts is considered useful for analysis [53]. Therefore, a method for detecting geolocation from text data has been implemented. Named entities are extracted from texts and geocoded i.e., the geographical coordinates are retrieved for the found entities. The named entities include geopolitical entities (GPE) (i.e., countries, cities, states), locations (LOC) (i.e., mountains, bodies of water), faculties (FAC) (buildings, airports, highways, etc. ), organizations (ORG) (companies, agencies, institutions, etc.). For this method, the Nominatim geocoder, along with openstreetmap data are used [56]. \begin{table}
\begin{tabular}{c c} \hline \hline
**Field** & **Description** \\ \hline id & unique identifier \\ text & content \\ annotations & hate speech and sentiment annotations \\ meta/type & type of text (tweet, article, post, comment, etc.) \\ meta/plang & language detection via PHARM Scripts \\ meta/pdate & datetime estimation via PHARM Scripts \\ meta/phate & hate speech detection via PHARM Scripts \\ meta/psent & sentiment analysis via PHARM Scripts \\ meta/pterms & frequent terms collection via PHARM Scripts \\ meta/ploc & geolocation estimation via PHARM Scripts \\ meta/meta & unsorted metadata \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The common fields of the specified data format. \begin{table}
\begin{tabular}{c c} \hline \hline
**Twitter** & **YouTube** \\ \hline tweet id & comment id \\ is retweet & reply count \\ is quote & like count \\ user id & video id \\ username & video title \\ screenname & channel \\ location & video description \\ follower count & author id \\ friend count & author name \\ date & date \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The metadata fields that are exploited for the YouTube and Twitter records. Datetime Estimation: Besides location and language, when metadata is available, relevant extra information for hate speech analysis can be used. Some of this extra information, such as date or time, may be available in different formats, introducing the necessity of standardization. Therefore, a method for detecting and standardizing date and time information from meta- and text- data has been implemented. A couple of Python libraries (e.g., dateparser, datefinder, and parsedatetime) are exploited for detecting datetime objects in texts. This is based on metadata analysis, where date information is commonly present. If datetime detection fails for the metadata, the same workflow is applied to the text data. Hate Speech Detection: Undoubtedly, hate speech detection is a core algorithmic asset for the project. Therefore, a couple of methods for detecting hate speech have been implemented, based on both an unsupervised and a supervised approach. The former concerns a lexicon-based method relying on a dictionary containing static phrases, along with dynamic term combinations (i.e., adjectives with nouns), while the latter refers to a machine learning procedure.