<!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>A Language Identi cation Method Applied to Twitter Data</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anil Kumar Singh IIT (BHU)</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Varanasi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>India nlprnd@gmail.com</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Pratya Goyal NIT</institution>
          ,
          <addr-line>Surat</addr-line>
          ,
          <country country="IN">India</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper presents the results of some experiments on using a simple algorithm, aided by a few heuristics, for the purposes of language identi cation on Twitter data. These experiments were a part of a shared task focused on this problem. The core algorithm is an n-gram based distance metric algorithm. This algorithm has previously been shown to work very well on normal text. The distance metric used is symmetric cross entropy.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Language identi cation was perhaps the
rst natural language processing task for
which a statistical method was used
successfully
        <xref ref-type="bibr" rid="ref2">(Beesley, 1988)</xref>
        . Over the years, many
algorithms have become available that work
very well with normal text
        <xref ref-type="bibr" rid="ref1 ref11 ref16 ref4 ref5 ref6 ref8">(Dunning, 1994;
Combrinck and Botha, 1994; Jiang and
Conrath, 1997; Teahan and Harper, 2001;
Martins and Silva, 2005)</xref>
        . However, with the
recent spread of social media globally, the
need for language identi cation algorithms
that work well with the data available on such
media has been felt increasingly. There has
been a special focus on microblogging data,
because of at least two main reasons. The
rst is that microblogs have too little data
for traditional algorithms to work well
directly and the second is that microblogs use
a kind of abbreviated language where, for
example, many words are not fully spelled out.
Some other facts about such data, like
multilinguality of many microbloggers only make
the problem harder.
      </p>
      <p>Our goal was to take one of the algorithms
that has been shown to work very well for
normal text, add some heuristics to it, and
see how far it goes in performing language
identi cation for microblog data.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Architecture and Components of the System</title>
      <p>The system we have used is quite simple.
There are only two components in the
system. At its core there is a language identi er
for normal text. The only other module is
a preprocessing module. This preprocessing
module implements some heuristics. There
are two main heuristics implemented. The
rst one is based on the knowledge that word
boundaries are an important source of
linguistic information that can help a language
processing system perform better. We just
wrap every word (more accurately, a token)
inside two special symbols, one for word
beginning and the other for word ending. The
e ect of this heuristic is that it not only
provides additional information, it also
`expands' the short microblogging text a little
bit, which is statistically important.</p>
      <p>The other heuristic relates to cleaning up
the data. Microblogging text, particularly
Twitter text, contains extra-textual tokens
such as hashtags, mentions, retweet symbols,
URLs etc. This heuristic removes such
extratextual tokens from the data before training
as well as before language identi cation.</p>
      <p>
        The intuitive basis of our algorithm is
similar to the unique n-gram based approach,
which was rst used for human identi
cation
        <xref ref-type="bibr" rid="ref7">(Ingle, 1976)</xref>
        and later for automatic
identi cation
        <xref ref-type="bibr" rid="ref12">(Newman, 1987)</xref>
        . The insight
behind these methods is as old as the time of
Ibn ad-Duraihim who lived in the 14th
century.
      </p>
      <p>It is worth noting that when n-grams
are used for language identi cation, normally
no distinction is made between orders of
ngrams, that is, unigrams, bigrams and
trigrams etc. are all given the same status.
Further, when using vector space based distance
measures, n-grams of all orders are merged
together and a single vector is formed. It is
this vector over which the distance measures
are applied.
3</p>
    </sec>
    <sec id="sec-3">
      <title>The Core Algorithm</title>
      <p>
        The core algorithm that we have used
        <xref ref-type="bibr" rid="ref14">(Singh,
2006)</xref>
        is an adaptation of the one used by
Cavnar and Trenkle
        <xref ref-type="bibr" rid="ref4 ref5">(Cavnar and Trenkle,
1994)</xref>
        . The main di erence is that instead of
using the sum of the di erences of ranks, we
use symmetric cross entropy as the similarity
or distance measure.
      </p>
      <p>The algorithm can be described as follows:
1. Train the system by preparing character
based and word based (optional) n-grams
from the training data.
2. Combine n-grams of all orders (Oc for
characters and Ow for words).
3. Sort them by rank.
4. Prune by selecting only the top Nc
character n-grams and Nw word n-grams for each
language-encoding.
5. For the given test data or string, calculate
the character n-gram based score simc with
every model for which the system has been
trained.
6. Select the t most likely language-encoding
pairs (training models) based on this score.
7. For each of the t best training models,
calculate the score with the test model. The
score is calculated as:
score = simc + a simw
(1)
where c and w represent character based and
word based n-grams, respectively. And a
is the weight given to the word based
ngrams. In our experiment, this weight was
1 for the case when word n-grams were
considered and 0 when they were not.
8. Select the most likely language-encoding
pair out of the t ambiguous pairs, based on
the combined score obtained from word and
character based models.</p>
      <p>The parameters in the above algorithm are:
1. Character based n-gram models Pc and Qc
2. Word based n-gram models Pw and Qw
3. Orders Oc and Ow of n-grams models
4. Number of retained top n-grams Nc and Nw
(pruning ranks for character based and word
based n-grams, respectively)
5. Number t of character based models to be
disambiguated by word based models
6. Weight a of word based models</p>
      <p>In our case, for the twitter data, we have
not used word based n-grams as they do not
seem to help. Adding them does not improve
the results. Perhaps the reason is that there
is too little data in terms of word n-grams.
So the parameters for our case are:
Oc = 7, Ow = 0, Nc = 1000, Nw = 0, a = 0</p>
      <p>We used an existing implementation of
this algorithm which is available as part of
a library called Sanchay1 (version 0.3.0).</p>
      <p>The parameters were selected based on
repeated experiments. The ones selected are
those which gave the best results. The length
of n-grams was selected as 7-grams and we
did nd that increasing n-gram length
improves the results.</p>
      <p>
        In this paper we have used this technique
for monolingual identi cation in accordance
with the task de nition, but it can be used for
multilingual identi cation
        <xref ref-type="bibr" rid="ref15">(Singh and Gorla,
2007)</xref>
        , although the accuracies are not likely
to be high when used directly.
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Resources Employed</title>
      <p>For our experiments reported here we have
only used the training data provided. We
have not used any other resources. We have
also, so far, not used any additional tools
such as a name entity recognizer. We have
implemented some heuristics as described in
the previous section.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Setup and Evaluation</title>
      <p>We evaluated with two di erent setups.
Before the test data for the shared task was
released, we had randomly divided the
training data into two sets by the usual 80-20
split: one for training and one for
evaluation. We also used two evaluation methods.
1http://sanchay.co.in
One was simple precision based on
microaverages, while the other was using the evaluation
script provided by the organizers, which was
based on macroaverages. Under this setup,
on repeated runs, the algorithm described
earlier, out of the box, gave a (microaverages
based) precision of little more than 70%. On
adding the word boundary heuristic to the
data, the precision increased to around 78%.
On further adding the cleaning heuristic, the
precision reached 80.80%. The corresponding
macroaverge based F-score was 68.26%.</p>
      <p>However, once the test data for the shared
task was released and we used it with our
algorithm, along with the heuristics, the
(macroaverage based) F-score was 61.5%.
This increased a little after we slightly
improved the implementation of the
preprocessing module. The corresponding
microaverage based precision was 77.47%. On
looking at the results for each language, we nd
that the performance was best for Spanish
(89.38% F-measure) and worst for Galician
(33.99% F-measure). These results are
presented in table-1.</p>
      <p>
        Tables 2 and 3 list the most frequent
single label errors for the two cases (80-20 split
of the training data and the test set). While
some of the results are as expected, others are
surprising. For example, Galician and
Portuguese are very similar and they are
confused for one another. Similarly for
Spanish and Catalan. But it is surprising that
Catalan is identi ed as English and Basque
as Spanish. Also, Galician and Portuguese
are similar, but the results for them are
different. These discrepancies become a
little clearer if we notice the fact that the
results are quite di erent in many ways for
the two cases: the 80-20 split and the test
set. The most probable reason for these
discrepancies is that since this method is based
purely on distributional similarity, di erences
in training or testing distributions cause
unexpected errors. The fact that there is more
data available for some languages (Spanish
and Portuguese) and less for others
(Galician, Catalan and Basque), the di erence
being very large, contributes to these
discrepancies. It may also be noted that the results
were much better in terms of microaverage
based precision because in that case our
evaluation method took into account multi-label
classi cation such as `en+pt'. In fact, each
multi-label combination was treated as a
single class, both in the case of code switching
and ambiguity. As a result, many (around
half) of the errors were of such as `en' being
identi ed as `en+pt'. This also contributed
to making our results lower as evaluated by
the script provided by the organizers.
We presented the results of our experiments
on using an existing algorithm for language
identi cation on the Twitter data provided
for the shared task. We tried the algorithm
as it is and also with some heuristics. The
two main heuristics were: adding the word
boundaries to the data in the form of
special symbols and cleaning up hashtags,
mentions etc. The results were not state of the
art for Twitter data
        <xref ref-type="bibr" rid="ref17">(Zubiaga et al., 2014)</xref>
        ,
but they might show how far an out of the
box well-performing algorithm can go for this
purpose. Also, the results were signi cantly
worse for the test data than they were for
the 80-20 split on the provided training data.
This means either the algorithm lacks
robustness when it comes to microblogging data,
or there is a data shift between the training
and test data. Perhaps one important
conclusion from the experiments is that adding
word boundary markers to the data can
signi cantly improve the performance.
      </p>
      <p>
        For future work, we plan to experiment
with techniques along the lines suggested
in recent work
        <xref ref-type="bibr" rid="ref10 ref3 ref9">(Kiciman, 2010; Carter,
Weerkamp, and Tsagkias, 2013; Lui and
Baldwin, 2014)</xref>
        on language identi cation for
Twitter data.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <surname>Adams</surname>
            , Gary and
            <given-names>Philip</given-names>
          </string-name>
          <string-name>
            <surname>Resnik</surname>
          </string-name>
          .
          <year>1997</year>
          .
          <article-title>A language identi cation application built on the Java client-server platform</article-title>
          .
          <source>In Jill Burstein and Claudia Leacock</source>
          , editors, From Research to Commercial Applications:
          <article-title>Making NLP Work in Practice. Association for Computational Linguistics</article-title>
          , pages
          <volume>43</volume>
          {
          <fpage>47</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <surname>Beesley</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          <year>1988</year>
          .
          <article-title>Language identi er: A computer program for automatic natural-language identi cation on on-line text</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <surname>Carter</surname>
            , Simon,
            <given-names>Wouter</given-names>
          </string-name>
          <string-name>
            <surname>Weerkamp</surname>
            , and
            <given-names>Manos</given-names>
          </string-name>
          <string-name>
            <surname>Tsagkias</surname>
          </string-name>
          .
          <year>2013</year>
          .
          <article-title>Microblog language identication: overcoming the limitations of short, unedited and idiomatic text</article-title>
          .
          <source>Language Resources and Evaluation</source>
          ,
          <volume>47</volume>
          (
          <issue>1</issue>
          ):
          <volume>195</volume>
          {
          <fpage>215</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Cavnar</surname>
            ,
            <given-names>William B.</given-names>
          </string-name>
          and
          <string-name>
            <surname>John M. Trenkle</surname>
          </string-name>
          .
          <year>1994</year>
          .
          <article-title>N-gram-based text categorization</article-title>
          .
          <source>In Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis and Information Retrieval</source>
          , pages
          <volume>161</volume>
          {
          <fpage>175</fpage>
          ,
          <string-name>
            <surname>Las</surname>
            <given-names>Vegas</given-names>
          </string-name>
          , US.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <surname>Combrinck</surname>
            , H. and
            <given-names>E.</given-names>
          </string-name>
          <string-name>
            <surname>Botha</surname>
          </string-name>
          .
          <year>1994</year>
          .
          <article-title>Automatic language identi cation: Performance vs. complexity</article-title>
          .
          <source>In Proceedings of the Sixth Annual South Africa Workshop on Pattern Recognition.</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>Dunning</surname>
          </string-name>
          , Ted.
          <year>1994</year>
          .
          <article-title>Statistical identi cation of language</article-title>
          .
          <source>Technical Report CRL MCCS-94- 273</source>
          , Computing Research Lab, New Mexico State University, March.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Ingle</surname>
            ,
            <given-names>Norman C.</given-names>
          </string-name>
          <year>1976</year>
          .
          <article-title>A language identi cation table</article-title>
          .
          <source>In The Incorporated Linguist</source>
          ,
          <volume>15</volume>
          (
          <issue>4</issue>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <surname>Jiang</surname>
            ,
            <given-names>Jay J. and David W.</given-names>
          </string-name>
          <string-name>
            <surname>Conrath</surname>
          </string-name>
          .
          <year>1997</year>
          .
          <article-title>Semantic similarity based on corpus statistics and lexical taxonomy</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <surname>Kiciman</surname>
          </string-name>
          , Emre.
          <year>2010</year>
          .
          <article-title>Language di erences and metadata features on twitter</article-title>
          .
          <source>In Web N-gram Workshop at SIGIR</source>
          <year>2010</year>
          . ACM,
          <year>July</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <surname>Lui</surname>
            , Marco and
            <given-names>Timothy</given-names>
          </string-name>
          <string-name>
            <surname>Baldwin</surname>
          </string-name>
          .
          <year>2014</year>
          .
          <article-title>Accurate language identi cation of twitter messages</article-title>
          .
          <source>In Proceedings of the 5th Workshop on Language Analysis for Social Media (LASM)</source>
          , pages
          <fpage>17</fpage>
          {
          <fpage>25</fpage>
          ,
          <string-name>
            <surname>Gothenburg</surname>
          </string-name>
          , Sweden, April. Association for Computational Linguistics.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <surname>Martins</surname>
            , Bruno and
            <given-names>Mario J.</given-names>
          </string-name>
          <string-name>
            <surname>Silva</surname>
          </string-name>
          .
          <year>2005</year>
          .
          <article-title>Language identi cation in web pages</article-title>
          .
          <source>In Proceedings of ACM-SAC-DE, the Document Engeneering Track of the 20th ACM Symposium on Applied Computing.</source>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <surname>Newman</surname>
          </string-name>
          , Patricia.
          <year>1987</year>
          .
          <article-title>Foreign language identi cation - rst step in the translation process</article-title>
          .
          <source>In Proceedings of the 28th Annual Conference of the American Translators Association</source>
          . pages
          <fpage>509</fpage>
          {
          <fpage>516</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <surname>Simon</surname>
          </string-name>
          , Kranig.
          <year>2005</year>
          .
          <article-title>Evaluation of language identi cation methods</article-title>
          .
          <source>In BA Thesis</source>
          . Universitt Tbingens.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          <string-name>
            <surname>Singh</surname>
            ,
            <given-names>Anil</given-names>
          </string-name>
          <string-name>
            <surname>Kumar</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Study of some distance measures for language and encoding identi cation</article-title>
          .
          <source>In Proceeding of ACL 2006 Workshop on Linguistic Distances. Sydney</source>
          , Australia, Sydney, Australia. Association for Computational Linguistics.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          <string-name>
            <surname>Singh</surname>
            ,
            <given-names>Anil</given-names>
          </string-name>
          <string-name>
            <surname>Kumar</surname>
            and
            <given-names>Jagadeesh</given-names>
          </string-name>
          <string-name>
            <surname>Gorla</surname>
          </string-name>
          .
          <year>2007</year>
          .
          <article-title>Identi cation of languages and encodings in a multilingual document</article-title>
          .
          <source>In Proceedings of the 3rd ACL SIGWAC Workshop on Web As Corpus</source>
          ,
          <article-title>Louvain-la-</article-title>
          <string-name>
            <surname>Neuve</surname>
          </string-name>
          , Belgium.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          <string-name>
            <surname>Teahan</surname>
            , W. J. and
            <given-names>D. J.</given-names>
          </string-name>
          <string-name>
            <surname>Harper</surname>
          </string-name>
          .
          <year>2001</year>
          .
          <article-title>Using compression based language models for text categorization</article-title>
          . In J.
          <string-name>
            <surname>Callan</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Croft</surname>
          </string-name>
          and J. La erty (eds.),
          <source>Workshop on Language Modeling and Information Retrieval. ARDA</source>
          , Carnegie Mellon University, pages
          <volume>83</volume>
          {
          <fpage>88</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          <string-name>
            <surname>Zubiaga</surname>
            , Arkaitz, Iaki San Vicente, Pablo Gamallo, Jos Ramom Pichel, Iaki Alegria, Nora Aranberri, Aitzol Ezeiza, and
            <given-names>Vctor</given-names>
          </string-name>
          <string-name>
            <surname>Fresno</surname>
          </string-name>
          .
          <year>2014</year>
          .
          <article-title>Overview of TweetLID: Tweet Language Identi cation at SEPLN 2014</article-title>
          .
          <source>In Proceedings of TweetLID @ SEPLN</source>
          <year>2014</year>
          , Girona, Spain.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>