<!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>Several approaches for tweet topic classi cation in COSET { IberEval 2017</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Carlos Villar Lafuente</string-name>
          <email>carlosbetera3dx@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Goncal Garces D az-Mun o</string-name>
          <email>ggarces@dsic.upv.es</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Universitat Politecnica de Valencia</institution>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2017</year>
      </pub-date>
      <fpage>36</fpage>
      <lpage>42</lpage>
      <abstract>
        <p>These working notes summarize the di erent approaches we have explored in order to classify a corpus of tweets related to the 2015 Spanish General Election (COSET 2017 task from IberEval 2017). Two approaches were tested during the COSET 2017 evaluations: Neural Networks with Sentence Embeddings (based on TensorFlow) and N-gram Language Models (based on SRILM). Our results with these approaches were modest: both ranked above the \Most frequent baseline", but below the \Bag-of-words + SVM" baseline. A third approach was tried after the COSET 2017 evaluation phase was over: Advanced Linear Models (based on fastText). Results measured over the COSET 2017 Dev and Test show that this approach is well above the \TF-IDF+RF" baseline.</p>
      </abstract>
      <kwd-group>
        <kwd>COSET2017</kwd>
        <kwd>text classi cation</kwd>
        <kwd>neural networks</kwd>
        <kwd>sentence embeddings</kwd>
        <kwd>language models</kwd>
        <kwd>linear models</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        In this work we have explored several approaches for text classi cation on
Twitter messages, tackling the COSET 2017 task from IberEval 2017 [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ][
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        The aim of the task was to classify a corpus of tweets in Spanish about the
2015 Spanish General Election into ve categories or topics, namely:
1. Political issues (related to the most abstract electoral confrontation)
2. Policy issues (about sectorial policies)
3. Campaign issues (related with the evolution of the campaign)
4. Personal issues (on the life and activities of the candidates)
5. Other issues
The COSET 2017 organizers provided a corpus split in three sets of tweets, two
of them labelled for training (Train) and development (Dev), and the other one
unlabelled as a Test (which we had to classify, submitting the results for
evaluation). The tweets were provided (password protected) in CSV les containing
the tweet ID, the tweet itself and (only in the Train and Dev les) the label [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>Systems description</title>
      <sec id="sec-2-1">
        <title>Preprocessing</title>
        <p>We carried out the preprocessing of the Train, Dev and Test sets with our own
Python script based on regular expressions (regex library). The aim was to leave
the tweets in the best condition possible in order to make it easier later to extract
meaningful features for the classi cation models that we used in our approaches.</p>
        <p>First of all, as many of the the tweets in the CSV les came divided in several
lines (we can detect the end of a tweet because the next line begins with double
quotation marks + an 18-digit tweet ID), our script converted each tweet to one
string without line breaks (to make it easier to process the les for the rest of
the modelling and classi cation steps).</p>
        <p>Other modi cations were the conversion of hashtags to lower case (as, for
Twitter, the hashtags #COSET2017, #CoSeT2017 and #Coset2017 are the
same), removing redundant quotation marks (when a tweet contained quoted
text, the API used for tweet retrieval had added redundant quotation marks),
removing hyperlinks (URLs are shortened by Twitter and sometimes cut by the
API, and this provides zero information), shortening citations (Twitter added
a lot of text in order to indicate that a tweet cites another tweet), and basic
tokenization (separating punctuation from words).</p>
        <p>
          Apart from the initial preprocessing we just described, in the case of some
of the approaches described below, we also tried converting the full text of the
tweets to lowercase, by using the lowercase.perl script that comes with the Moses
toolkit for statistical machine translation [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
3.2
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>Classi cation approaches</title>
        <p>We faced the task by exploring di erent techniques and solutions instead of
focusing on a single approach, with the aim of achieving better results.</p>
        <p>Two approaches were tested during the COSET 2017 evaluation phase:
Neural Networks with Sentence Embeddings (based on TensorFlow) and N-gram
Language Models (based on SRILM). A third approach was tried after the
COSET 2017 evaluation phase: Advanced Linear Models (based on fastText).
N-gram Language Models (SRILM). The most basic approach we tried was
to train an n-gram language model for each topic. Then, new tweets (the tweets in
the Test set) were compared to these 5 topic n-gram models based on perplexity.
Each tweet was assigned the topic with which it showed less perplexity.</p>
        <p>
          The well-known n-gram language modelling toolkit SRILM [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] was used for
this approach. N-gram models were trained with SRILM's default smoothing
method: Good-Turing smoothing. Di erent n-gram orders were tried (2, 3, 4, 5),
with the best F1-macro result on Dev having been obtained with 3-grams.
        </p>
        <p>SRILM was also used to compute the perplexity of new tweets against each
one of the 5 topic n-gram models trained. As explained before, each tweet was
classi ed as pertaining to the topic with which it showed less perplexity.</p>
        <p>
          In the end, we sent one submission for evaluation in COSET 2017 based on
this approach. The models chosen were 3-grams with Good-Turing smoothing.
Neural Networks with Sentence Embeddings (TensorFlow). In this case,
the aim was to use a TensorFlow-based neural network [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] for tweet classi cation.
        </p>
        <p>
          In order to extract the features of each tweet to train the neural network
(NN) models, we decided to use the Sentence Embeddings approach, by which
each text document (in this case, each tweet) is represented as a feature vector.
To this end, we used the software Doc2vec from the gensim Python library [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ].
Doc2vec is an NLP tool that modi es the Word2vec word embedding algorithm
[
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] to carry out an unsupervised learning of continuous representations for larger
blocks of text, such as sentences, paragraphs or entire documents.
        </p>
        <p>After sentence embeddings were computed with Doc2vec for all of the tweets,
these feature vectors (one per tweet) were used as input to train with TensorFlow
a NN model for tweet classi cation into the task's 5 topics.</p>
        <p>The Doc2vec model for converting tweets into vectors of fty features (a
compromise between having enough representation power and having too many
parameters to train) was built from the train data. The training method of the
model was called ten times, each training step taking ten iterations. While each
training step had a xed learning rate, between each call, the learning rate was
decreased (learning rate annealing, starting at 0.025, decreasing 0.02 per step).</p>
        <p>After the Doc2vec model construction, all tweet data was converted into
feature vectors using it and saved in new les. Each line contained the tweet id
(in the case of test data), the feature vector and the label (in the case of Train
or Dev data), all separated by spaces.</p>
        <p>Finally, we fed the data into a NN with TensorFlow. A traditional
feedforward NN topology was used, with a hidden layer of 1024 nodes (with ReLU
as the activation function), an input layer of 50 nodes (feature vector size), and
an output layer of 5 nodes (number of classes). The labels were converted from a
numerical value to a vector with a component for each class (0,1,2,3,4, following
the order from Section 1), with the vector size being determined by the highest
label's value plus one (in this case, highest value 4, vector size 5).</p>
        <p>The NN was fed with batches of 100 tweets during training. After training,
the NN was fed with the test data and the output vector was converted into a
class label depending on which position of the vector had the highest value.</p>
        <p>
          We sent one submission with this approach for evaluation in COSET 2017.
Advanced Linear Models (fastText). Linear models with bag of n-grams
representation and hierarchical classi ers have been explored by Facebook
Research as a way to develop text classi ers on par with deep learning classi ers
in terms of accuracy and more e cient for training and evaluation [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. Here, we
have worked with Facebook Research's fastText1 tool for word embedding and
text classi cation [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] so as to optimize results over the COSET 2017 Dev set.
        </p>
        <p>In order to predict the labels for the COSET 2017 Test set, a text classi
cation model was trained with fastText from the COSET 2017 Train and Dev
sets. Then, the Test set was classi ed using fastText with this model.</p>
        <p>There are several fastText parameters we can adjust for model training. The
best results on Dev were observed with fastText's defaults for word vector size
(100), word n-gram order (1), loss function (5-negative sampling), and learning
rate (0.05), but increasing the number of epochs (from the default of 5 to 25).</p>
        <p>Finally, regarding preprocessing, with this approach we tried converting to
lowercase the results of our preprocessing described in Section 3.1. Our
measurements showed that using lowercase tweets for system training and for
classi cation improved the results on Dev (from F-1 macro 0.5494 with truecase to
F-1 macro 0.5982 with lowercase); thus, the result for this approach reported in
Section 4 below is based on converting tweets to lowercase during preprocessing.
1 https://github.com/facebookresearch/fastText
4
4.1</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Evaluation and discussion</title>
      <sec id="sec-3-1">
        <title>Evaluation metric</title>
        <p>
          The metric designated for evaluating the participating systems in COSET 2017
[
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] was F-1 macro (which considers the precision and the recall of the system's
predictions, using the macro-averaging method for preventing systems biased
towards the most populated classes):
        </p>
        <p>F1
macro =
As mentioned before, we only were able to submit results before the COSET
2017 competition deadline using the Language Model approach and the Neural
Network approach. After the COSET 2017 submission deadline had passed, we
carried out additional experiments using the Linear Model approach.</p>
        <p>
          In Table 3 we show our results measured in F-1 macro over the Dev and Test
sets of COSET 2017. The COSET 2017 baselines and winning system have also
been included for reference (see [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] for the complete results).
        </p>
        <p>
          As we can see, our results with the N-gram Language Model and Neural
Networks with Sentence Embeddings approaches were modest: both ranked above
the \Most frequent baseline", but below the \Bag-of-words + SVM" baseline.
However, this does not mean that it would not be possible to obtain better
results with these approaches, if more time had been available for experimentation.
For starters, a di erent preprocessing, such as converting all tweets to lowercase,
could improve the results. Then, in the case of N-gram Language Models, trying
n-gram character models instead of n-gram word models could be e ective. As
to the case of Neural Networks, it could be useful to try Word2vec [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] for word
embedding (instead of sentence embedding with Doc2vec), or skipping word
embedding computation altogether, and instead feeding the tweet texts directly into
TensorFlow so that neural networks are used to compute the most appropriate
features for each tweet for the training of the neural network model; additionally,
di erent neural network topologies could be explored to obtain better results.
        </p>
        <p>
          As to the Linear Model approach, results on the COSET 2017 Dev &amp; Test
sets show that this approach ranks well above the \TF-IDF+RF" baseline, being
closer to the winning system [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. In our tests, and with this result, fastText has
proven to be a powerful, e cient, easy-to-use tool for text classi cation.
        </p>
        <p>
          As explained in Section 2, after the COSET 2017 competition was over, a
second phase test on robustness was proposed by the organizers, in which we ran
our best approach on a new, much larger tweet set. As we can see in Table 4, by
running the Advanced Linear Models system described in Section 3.2 (trained
this time on the original COSET 2017 Train, Dev and Test sets), our results
came in second in the list of participants, close to the winning systems [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ].
        </p>
        <p>
          As future work, we can recapitulate here some of the possible ways for
improvement: for preprocessing, trying other techniques on the tweets, such as
lemmatization, or smiley and emoji preprocessing [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]; in the N-gram Language
Model approach, trying n-gram character models instead of word models; and
in the Neural Network approach, trying Word2vec or fastText for word
embedding (instead of sentence embedding with Doc2vec), or skipping word embedding
precomputation and instead feeding the tweet texts directly into TensorFlow.
        </p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>COSET</surname>
          </string-name>
          (IberEval
          <year>2017</year>
          )
          <article-title>: Classi cation of Spanish Election Tweets (</article-title>
          <year>2017</year>
          ). Retrieved from http://media ows.es/coset/
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Gimenez</surname>
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baviera</surname>
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Llorca</surname>
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gamir</surname>
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Calvo</surname>
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rosso</surname>
            <given-names>P.</given-names>
          </string-name>
          , Rangel F.
          <article-title>Overview of the 1st Classi cation of Spanish Election Tweets Task at IberEval 2017</article-title>
          .
          <source>In: Proceedings of the Second Workshop on Evaluation of Human Language Technologies for Iberian Languages (IberEval</source>
          <year>2017</year>
          ), Murcia, Spain, September 19, CEUR Workshop Proceedings, CEUR-WS.org,
          <year>2017</year>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Moses</surname>
          </string-name>
          <article-title>Tokenizer scripts</article-title>
          . Retrieved from https://github.com/moses-smt/mosesdecoder/tree/master/scripts/tokenizer
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. SRILM:
          <article-title>The SRI Language Modeling Toolkit</article-title>
          . Retrieved from http://www.speech.sri.com/projects/srilm/
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. TensorFlow:
          <article-title>An open-source software library for Machine Intelligence</article-title>
          . Retrieved from https://www.tensor ow.org/
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. gensim doc2vec:
          <article-title>Deep learning with paragraph2vec</article-title>
          .
          <source>Retrieved</source>
          from https://radimrehurek.com/gensim/models/doc2vec.html
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Joulin</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grave</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bojanowski</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mikolov</surname>
          </string-name>
          , T.:
          <article-title>\Bag of Tricks for E cient Text Classi cation"</article-title>
          .
          <source>CoRR abs/1607</source>
          .01759 (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8. fastText:
          <article-title>Library for e cient learning of word representations and sentence classication</article-title>
          . Retrieved from https://github.com/facebookresearch/fastText
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. Word2vec:
          <article-title>Tool for computing continuous distributed representations of words</article-title>
          . Retrieved from https://code.google.com/archive/p/word2vec/
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Potts</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Sentiment Symposium Tutorial</surname>
          </string-name>
          (
          <year>2011</year>
          ). Retrieved from http://sentiment.christopherpotts.net/
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>