<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Detecting Hate Speech for Italian Language in Social Media</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Valentino Santucci</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefania Spina</string-name>
          <email>stefania.spinag@unistrapg.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Alfredo Milani University of Perugia</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Giulio Biondi, Gabriele Di Bari University of Florence</institution>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University for Foreigners of Perugia</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>English. In this report we describe the hate speech detection system for the Italian language developed by a joint team of researchers from the two universities of Perugia (University for Foreigners of Perugia and University of Perugia). The experimental results obtained in the HaSpeeDe task of the Evalita 2018 evaluation campaign are analyzed. Finally, a suggestion for future research directions is provided in the conclusion.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Italiano. In questo documento
descriviamo il sistema di hate speech detection
per la lingua Italiana sviluppato da una
squadra di ricercatori dell’Universita` per
Stranieri di Perugia e dell’Universita` degli
Studi di Perugia. I risultati sperimentali
ottenuti nel task HaSpeeDe, organizzato
nell’ambito di Evalita 2018, sono
riportati e analizzati. Infine, una possibile
direzione di ricerca e` fornita nelle
conclusioni.
In the recent years there was an exponential
growth of social media that has revolutionized
communication and content publishing. However,
social media are also increasingly exploited for the
propagation of hate speech. This issue motivates
the recent research on hate speech detection
systems
        <xref ref-type="bibr" rid="ref1 ref12 ref13 ref3 ref6 ref7 ref8">(Zhang and Luo, 2018; Waseem and Hovy,
2016; Del Vigna et al., 2017; Davidson et al.,
2017; Badjatiya et al., 2017; Gitari et al., 2015)</xref>
        .
      </p>
      <p>In this paper, we provide the description of
our hate speech detection system for the
Italian language. The system, namely HSD4I PG,
has been developed by a joint team of
researchers from the University for Foreigners of
Perugia and the University of Perugia. The
code of HSD4I PG is provided online at the url
https://github.com/Gabriele91/HSD4I PG.</p>
      <p>The rest of the paper is organized as follows.
The main system architecture is provided in
Section 2, while the single software components are
described in Sections 3-6. Experimental results
are provided in Section 7, while conclusion and
future lines of research are depicted in Section 8.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Architecture of the Hate Speech</title>
    </sec>
    <sec id="sec-3">
      <title>Detector</title>
      <p>
        The hate speech detector we have developed,
namely HSD4I PG, is composed by several
software components:
a tokenizer for Italian posts from social
media,
the popular FastText tool
        <xref ref-type="bibr" rid="ref3">(Bojanowski et al.,
2016)</xref>
        used to generate a word embedding
model,
a features generator that generates a vector
of numeric features for each post to be
classified,
a (trainable) classifier that, for each post,
predicts its class label.
      </p>
      <p>
        Moreover, the following resources have been
adopted:
the Ita Twitter corpus
        <xref ref-type="bibr" rid="ref11">(Spina, 2016)</xref>
        that includes 1,234,865 tweets extracted
from the Italian timeline in a time
span of seven months (November 2012
- May 2013). The tweets were
extracted randomly, 2,000 per day, using
the R package TwitteR
(https://cran.rproject.org/web/packages/twitteR/);
the Italian Lexicon of Hate Speech
that was collected based on an Italian
monolingual dictionary, Il Nuovo De
Mauro, which is also available online
(https://dizionario.internazionale.it);
the Sentix italian lexicon for sentiment
analysis
        <xref ref-type="bibr" rid="ref1">(Basile and Nissim, 2013)</xref>
        ;
the training sets of 3,000 Facebook posts and
3,000 tweets available for the ”Haspeede”
task of Evalita 2018.
      </p>
      <p>
        As any other supervised classifier system,
HSD4I PG requires a training stage, that is
depicted in Figure 1. The word embedding model
is trained by FastText using the Ita twitter corpus.
Numeric features are obtained by aggregating the
FastText features and by generating some ad-hoc
extra-features. These numeric features are finally
fed to a Support Vector Machine (SVM)
        <xref ref-type="bibr" rid="ref5">(Cortes
and Vapnik, 1995)</xref>
        in order to generate a classifier
model.
      </p>
      <p>After the SVM classifier has been trained, the
prediction of (unlabeled) posts is performed
following the scheme depicted in Figure 2.
3</p>
    </sec>
    <sec id="sec-4">
      <title>The Tokenizer</title>
      <p>
        A tokenizer for the Italian language adopted in
social media has been designed by modifying the
output produced by the ”TweetTokenizer” class
of the popular Python library NLTK
        <xref ref-type="bibr" rid="ref2">(Bird et al.,
2009)</xref>
        .
      </p>
      <p>
        A variety of corrections have been introduced.
The most important ones are:
1. two or more consecutive occurrences of the
same vowel have been replaced by a single
occurrence (e.g., ”ciaooo” is replaced with
”ciao”),
2. alternative spellings of some bad words have
been normalized (e.g., ”vaffa” is replaced
with its most popular form),
3. some common mispellings and abbreviations
have been corrected (e.g., ”cmq” is replaced
with ”comunque”),
4. hashtags have been split into multiple tokens
using the Python library
”compound-wordsplitter”,
5. apostrophes have been considered as token
separators,
6. tokens composed by digits characters have
been replaced with the token NUM,
7. tokens corresponding to Twitter mentions
have been replaced with the token MEN,
8. tokens corresponding to web links have been
replaced with the token URL,
9. emojis have been kept as tokens on their own,
while other punctuation characters have been
removed,
10. all the textual tokens have been replaced with
their stemmed form by using the NLTK
implementation of the Snowball stemming
algorithm for the Italian language
        <xref ref-type="bibr" rid="ref10">(Porter, 1980)</xref>
        .
      </p>
      <p>Moreover, in order to provide additional
experimental results, we have also tried a lighter variant
of the tokenizer that only perform the tasks
numbered from 5 to 10.
4</p>
    </sec>
    <sec id="sec-5">
      <title>The Word Embedding Model</title>
      <p>
        A word embedding model is generated by
FastText
        <xref ref-type="bibr" rid="ref3">(Bojanowski et al., 2016)</xref>
        using the skipgram
technique.
      </p>
      <p>Fed with the Ita Twitter corpus, FastText
produces a numeric vector representation for every
ngram contained in the corpus’ posts in such a way
that the n-grams belonging to tokens appearing in
similar contexts are close to each other in the
continuous numerical space.</p>
      <p>After the model has been generated, a numeric
representation for a given token w can be simply
computed by summing up the numeric
representations of the n-grams that compose w.</p>
      <p>Since out-of-vocabulary words are quite
common in social media texts, we think that the
subwords information contained in the n-grams is
particularly useful in our scenario.</p>
    </sec>
    <sec id="sec-6">
      <title>The Features Generator</title>
      <p>The word embedding model allows to generate a
numeric representation for every token. Therefore,
in order to produce a (constant length) numeric
representation of the whole post, we need to
aggregate the vectors corresponding to the tokens of
the post. Six different aggregation functions have
been considered: average (avg), standard
deviation (std), minimum (min), maximum (max),
median (med), and sum (sum). Any
combination of these aggregators can be adopted, thus the
features generator requires an experimental tuning
(see Section 7).</p>
      <p>
        Moreover, 20 additional extra-features have
been introduced:
number of hateful tokens, computed using
the Italian Lexicon of Hate Speech
        <xref ref-type="bibr" rid="ref11">(Spina,
2016)</xref>
        ,
average sentiment polarity and intensity,
computed using the Sentix lexicon
        <xref ref-type="bibr" rid="ref1">(Basile
and Nissim, 2013)</xref>
        ,
number of web links,
number of mentions,
a boolean flag to indicate if it is a reply tweet
or not,
number of hashtags,
maximum length of an hashtag (in
characters),
a boolean flag to indicate if it is a retweet or
not,
the percentage of capital letters,
the percentage of tokens whose letters are all
in capital case,
number of exclamation marks,
number of tokens composed by three or more
dots,
number of punctutation characters,
number of emojis,
number of repeated consecutive vowels,
percentage of tokens representing a correct
Italian word,
post length in number of characters,
post length in number of tokens.
      </p>
      <p>As an illustrative example, let consider that:
FastText has generated numeric vectors of size 300
for every single token w of a post p, and that
the combination of the three aggregators sum,
min, max has been chosen. Then, the numeric
vector representing p has 300 3 + 20 = 920
dimensions and it is formed by concatenating the
three vectors, each one of size 300, given by
every chosen aggregator together with the 20
extrafeatures.</p>
      <p>Finally, in the case the number of features is too
large for the classifier, during the training phase
we are able to reduce the dimensionality to a
given number k by selecting the features having
the largest mutual information with respect to the
class labels.
6</p>
    </sec>
    <sec id="sec-7">
      <title>The Classifier</title>
      <p>
        After some preliminary experiments, we have
decided to adopt a Support Vector Machine (SVM)
classifier
        <xref ref-type="bibr" rid="ref5">(Cortes and Vapnik, 1995)</xref>
        . SVM is a
supervised technique for training a classifier model
by efficiently computing a separation hyperplane
(between the two classes to be predicted) in a
(implicitly) higher dimensional space (with respect
to the features dimensionality). The SVM
implementation of the Python’s library Scikit-Learn
        <xref ref-type="bibr" rid="ref9">(Pedregosa et al, 2011)</xref>
        has been used.
      </p>
      <p>Compared to the popular neural network model,
the SVM technique has less parameters to be
tuned, it is computationally more efficient, and it
generally obtains comparable performances.</p>
      <p>Finally, it is important to note that, before the
training phase, all the training features have been
standardized in such a way that their means and
variances, across all the training instance, are,
respectively, 0 and 1.
7
7.1</p>
    </sec>
    <sec id="sec-8">
      <title>Experiments</title>
      <sec id="sec-8-1">
        <title>Experimental Setting</title>
        <p>The parameters of the different software
components of HSD4I PG have been tuned using a grid
search approach and a 10-folds cross-validation
scheme.</p>
        <p>FastText parameters have been chosen in the
following ranges: number of epochs epoch 2
f5; 20; 50; 100g, the initial learning rate lr 2
FastText
SVM</p>
      </sec>
      <sec id="sec-8-2">
        <title>Features Generator aggregators</title>
        <p>f0:05; 0:1g, the negative sampling neg 2
f5; 20; 50g, the window size ws 2 f5; 10g.
Moreover, the skipgram model has been
considered, while other FastText parameters that have
been set to constant values are: dim = 300,
minCount = 1, minn = 3, and maxn = 6.</p>
        <p>Regarding the features generator (see Section
5), a combination of the six aggregators has to be
chosen. Importantly, for combinations resulting in
more than 1,000 features, the filtering procedure
described at the end of Section 5 is performed.</p>
        <p>After some preliminary experiments, we have
decided to use the following ranges in order
to tune the SVM parameters: kernel 2
frbf; linearg, C 2 f1:8; 2; 2:2; 2:4g.
Moreover, the gamma and class weight
parameters have been set to, respectively, auto and
balanced.</p>
        <p>The best parameter setting resulting from the
experimental tuning is provided in Table 1.
7.2
Table 2 provides the results obtained by
HSD4I PG in the four proposed tasks. In
particular, the Macro-Average F1 score for each
subtask is shown, along with the difference from
the best competitor in the subtask.</p>
        <p>SubTask</p>
        <p>HSD4I PG
HaSpeeDe-FB</p>
        <p>HaSpeeDe-TW
Cross-HaSpeeDe-FB
Cross-HaSpeeDe-TW
In this paper we have introduced a system for the
hate speech detection of social media texts in
Italian language. The results we have obtained for the
HaSpeeDe task of the Evalita 2018 campaign are
provided.</p>
        <p>It is worth to point out that the results of most
participants are very similar and quite far from
being fully accurate. The question is whether hate
annotation is objective or subjective. Few of the
posts in the datasets looks to be difficult to
annotate even for a human being. Indeed, we think that
different people can produce different annotations.
Therefore, it can be interesting to model the
subjective perception of hatefulness and exploit such
information in the detection task, perhaps, taking
inspiration by recommender system techniques.
Parameter
epoch
lr
ns
ws
kernel
C</p>
        <p>Value
50
0.05
50
5
sum
min
max
rbf
2.2</p>
        <p>This setting has been used to generate the
results submitted as ”run 2” at the Haspeede task
of Evalita 2018 by the team ”Perugia1”. For a
mistake, we have submitted a wrong file as ”run
1”. Anyway, in the following section we also
provide the results of three additional executions of
HSD4I PG:</p>
        <p>Execution A) It uses the same setting of Table
1 except that C = 2,
Execution B) It uses the same setting of Table
1 except that the lighter variant of the
tokenizer (see Section 3) has been adopted,
Execution C) It uses the same setting of
Table 1 except that C = 2 and the lighter
variant of the tokenizer (see Section 3) has been
adopted.</p>
        <p>A
B
C
A
B
C</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <given-names>Pinkesh</given-names>
            <surname>Badjatiya</surname>
          </string-name>
          , Shashank Gupta, Manish Gupta, and
          <string-name>
            <given-names>Vasudeva</given-names>
            <surname>Varma</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <article-title>Deep Learning for Hate Speech Detection in Tweets</article-title>
          .
          <source>In Proceedings of the 26th International Conference on World Wide Web Valerio Basile and Malvina Nissim</source>
          .
          <year>2013</year>
          .
          <article-title>Sentiment Analysis on Italian Tweets</article-title>
          . In
          <source>In Proceedings of the 4th Workshop on Computational Approaches</source>
          to Subjectivity, Sentiment and
          <string-name>
            <surname>Social Media Analysis</surname>
          </string-name>
          , Atlanta, Georgia, 14 June 2013.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>Steven</given-names>
            <surname>Bird</surname>
          </string-name>
          , Ewan Klein, and
          <string-name>
            <given-names>Edward</given-names>
            <surname>Loper</surname>
          </string-name>
          .
          <year>2009</year>
          .
          <string-name>
            <given-names>Natural</given-names>
            <surname>Language Processing with Python. O'Reilly Media</surname>
          </string-name>
          , Inc.,
          <source>1st edition.</source>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>Piotr</given-names>
            <surname>Bojanowski</surname>
          </string-name>
          , Edouard Grave, Armand Joulin, and
          <string-name>
            <given-names>Tomas</given-names>
            <surname>Mikolov</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Enriching Word Vectors with Subword Information</article-title>
          .
          <volume>7</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <given-names>Cristina</given-names>
            <surname>Bosco</surname>
          </string-name>
          , Felice Dell'Orletta, Fabio Poletto, Manuela Sanguinetti, and
          <string-name>
            <given-names>Maurizio</given-names>
            <surname>Tesconi</surname>
          </string-name>
          .
          <year>2018</year>
          .
          <article-title>Overview of the Evalita 2018 Hate Speech Detection Task</article-title>
          . In Tommaso Caselli, Nicole Novielli, Viviana Patti, and Paolo Rosso, editors,
          <source>Proceedings of the 6th evaluation campaign of Natural Language Processing and Speech tools for Italian (EVALITA'18)</source>
          , Turin, Italy. CEUR.org.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <given-names>Corinna</given-names>
            <surname>Cortes</surname>
          </string-name>
          and
          <string-name>
            <given-names>Vladimir</given-names>
            <surname>Vapnik</surname>
          </string-name>
          .
          <year>1995</year>
          .
          <article-title>Supportvector networks</article-title>
          .
          <source>Machine Learning</source>
          ,
          <volume>20</volume>
          (
          <issue>3</issue>
          ):
          <fpage>273</fpage>
          -
          <lpage>297</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <given-names>Thomas</given-names>
            <surname>Davidson</surname>
          </string-name>
          , Dana Warmsley,
          <string-name>
            <given-names>Michael</given-names>
            <surname>Macy</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Ingmar</given-names>
            <surname>Weber</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <source>Automated Hate Speech Detection and the Problem of Offensive Language. 3.</source>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Fabio Del Vigna</surname>
            ,
            <given-names>Andrea</given-names>
          </string-name>
          <string-name>
            <surname>Cimino</surname>
            , Felice Dell'Orletta,
            <given-names>Marinella</given-names>
          </string-name>
          <string-name>
            <surname>Petrocchi</surname>
            , and
            <given-names>Maurizio</given-names>
          </string-name>
          <string-name>
            <surname>Tesconi</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <article-title>Hate me, hate me not: Hate speech detection on Facebook</article-title>
          .
          <source>In CEUR Workshop Proceedings.</source>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <given-names>Njagi</given-names>
            <surname>Dennis Gitari</surname>
          </string-name>
          , Zhang Zuping, Hanyurwimfura Damien, and
          <string-name>
            <given-names>Jun</given-names>
            <surname>Long</surname>
          </string-name>
          .
          <year>2015</year>
          .
          <article-title>A lexicon-based approach for hate speech detection</article-title>
          .
          <source>International Journal of Multimedia and Ubiquitous Engineering.</source>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <given-names>Fabian</given-names>
            <surname>Pedregosa</surname>
          </string-name>
          et al.
          <year>2011</year>
          .
          <article-title>Scikit-learn: Machine Learning in Python</article-title>
          .
          <source>J. Mach. Learn. Res.</source>
          ,
          <volume>12</volume>
          :
          <fpage>2825</fpage>
          -
          <lpage>2830</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <given-names>M.F.</given-names>
            <surname>Porter</surname>
          </string-name>
          .
          <year>1980</year>
          .
          <article-title>An algorithm for suffix stripping</article-title>
          .
          <source>Program</source>
          ,
          <volume>14</volume>
          (
          <issue>3</issue>
          ):
          <fpage>130</fpage>
          -
          <lpage>137</lpage>
          ,
          <fpage>3</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <given-names>Stefania</given-names>
            <surname>Spina</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Fiumi di parole. Discorso e grammatica delle conversazioni scritte in Twitter</article-title>
          . StreetLib, Loreto, Italy.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <given-names>Zeerak</given-names>
            <surname>Waseem</surname>
          </string-name>
          and
          <string-name>
            <given-names>Dirk</given-names>
            <surname>Hovy</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Hateful Symbols or Hateful People? Predictive Features for Hate Speech Detection on Twitter</article-title>
          .
          <source>In Proceedings of the NAACL Student Research Workshop.</source>
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <given-names>Ziqi</given-names>
            <surname>Zhang</surname>
          </string-name>
          and
          <string-name>
            <given-names>Lei</given-names>
            <surname>Luo</surname>
          </string-name>
          .
          <year>2018</year>
          .
          <article-title>Hate Speech Detection: A Solved Problem? The Challenging Case of Long Tail on Twitter. 2</article-title>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>