<!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>
      <journal-title-group>
        <journal-title>Confusion Matrix for Classification of
Ebart Corpus
Categories Economy Politics Sport H&amp;C C&amp;E
Economy</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Serbian Text Categorization Using Byte Level n-Grams</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jelena Graovac</string-name>
          <email>jgraovac@matf.bg.ac.rs</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>2012 by the paper's authors. Copying permitted only for private and academic purposes. This volume is published and copyrighted by its editors. Local Proceedings also appeared in ISBN 978-86-7031-200-5, Faculty of Sciences, University of Novi Sad</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Faculty of Mathematics, University of Belgrade Studentski trg 16 11000 Belgrade</institution>
          ,
          <country country="RS">Serbia</country>
        </aff>
      </contrib-group>
      <volume>140</volume>
      <issue>22</issue>
      <fpage>93</fpage>
      <lpage>96</lpage>
      <abstract>
        <p>This paper presents the results of classifying Serbian text documents using the byte-level n-gram based frequency statistics technique, employing four different dissimilarity measures. Results show that the byte-level n-grams text categorization, although very simple and language independent, achieves very good accuracy.</p>
      </abstract>
      <kwd-group>
        <kwd>N-gram</kwd>
        <kwd>text categorization</kwd>
        <kwd>Serbian</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. INTRODUCTION</title>
      <p>
        Text categorization is the task of classifying unlabelled
natural language documents into a predefined set of
categories. The increasing volume of available documents in the
World Wide Web has turned the document indexing and
searching more and more complex. This issue has motivated
the development of automated text and document
categorization techniques that are capable of automatically
organizing and classifying documents. There are many
different techniques for solving text categorization problem with
very good results, including Naive Bayes classifier,
Decision trees, Decision rule classifiers, Regression methods,
Rocchio’s method, Neural networks, K nearest neighbors,
Support vector machines etc.[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] Most of them have concentrated
on English text documents, and therefore are not
applicable to documents written in some other language such as
Serbian.
      </p>
      <p>
        Serbian language has several properties that significantly
influence text categorization: the use of two alphabets
(Cyrillic or Latin alphabet), phonologically based orthography, the
rich morphological system, free word order of the subject,
predicate, object and other sentence constituents, special
placement of enclitics and complex agreement system.[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] All
these characteristics make the preprocessing steps, such as
feature extraction and feature selection, to be more complex.
There is a need for a dictionaries, finite-state transducers for
the description of the interactions between text and
dictionary and other complex natural language processing tools.[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]
      </p>
      <p>
        This paper presents the results of Serbian text
categorization using a technique which is language independent
and very simple, that overcomes the above difficulties. This
technique is based on byte-level n-gram frequency statistics
method for documents representation and K nearest
neighbors machine learning algorithm for categorization process.
It is derived from Keˇselj’s[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] method to solving the
authorship attribution problem by using n-grams and some
Tomovi´c’s ideas from [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], where the problem of automated
categorization of genome isolates was examined. Keˇselj
defines an author profile as an ordered set of pairs (x1, f1),
(x2, f2),..., (xL, fL) of the L most frequent byte n-grams xi
and their normalized frequencies fi. The authorship is
determined based on the dissimilarity between two profiles,
comparing the most frequent n-grams. Based on this work,
a wide range of dissimilarity measures are introduced in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
This technique, including all these measures and one newly
introduced measure, has been tested in the work [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], to solve
the problem of text categorization in English, Chinese and
Serbian. In this paper is presented results of categorization
only Serbian text documents. The same technique and the
same corpus is used as in the [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] except that the
categorization is carried out at five rather than three classes and only
dissimilarity measures from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] were examined. Since
it is based on byte level n-grams technique do not need any
text preprocessing or higher level processing, such as
tagging, parsing, feature selection, or other language-dependent
and non-trivial natural language processing tasks.[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] The
approach is also tolerant to typing, spelling and grammatical
errors and word stemming is got essentially for free.[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]
Overview of the paper: Some background information
about n-grams are presented in Section 2. Section 3
describes methodology for categorization of text documents
used in this paper. This section also presents several
dissimilarity measures, the data set used for text
categorization and the set of evaluation metrics that are used to
assess the performance of this technique. Section 4 reports on
experimental results and shows comparison of dissimilarity
measures. Finally, Section 5 concludes the paper.
2.
      </p>
    </sec>
    <sec id="sec-2">
      <title>N-GRAMS</title>
      <p>
        Given a sequence of tokens S = (s1, s2, ..., sN+(n−1)) over
the token alphabet A, where N and n are positive integers,
an n-gram of the sequence S is any n-long subsequence of
consecutive tokens. The ith n-gram of S is the sequence
(si, si+1, ..., si+n−1).[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
      </p>
      <p>
        For example, if A is the English alphabet, and l string
on alphabet A, l = ”life is a miracle” then 1-grams are:
l,i,f,e, ,s,a,m,r,c; 2-grams are: li,if, fe, e , i, is, s , a, ...;
3-grams are: lif, ife, fe , e i, ...; 4-grams are: life, ife , fe i,
... and so on. The underscore character (” ”) is used here to
represent blanks. For n ≤ 5 Latin names are commonly used
for n-grams (e.g., trigrams) and for n &gt; 5 numeric prefixes
are common (e.g., 6-grams).[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
      </p>
      <p>
        The use of n-gram models and techniques based on
ngram probability distribution in natural language
processing is a relatively simple idea, but it turned out to be
effective in many applications.[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] Some of them are text
compression, spelling error detection and correction,
information retrieval, language identification, authorship
attribution. It also proved useful in domains not related to language
processing such as music representation, computational
immunology, protein classification etc.
      </p>
      <p>
        The term n-gram could be defined on word, character or
byte level. In the case of Latin-alphabet languages,
characterlevel and byte-level n-gram models are quite similar
according to the fact that one character is usually represented by
one byte. The only difference is that character-level n-grams
use letters only and typically ignore digits, punctuation, and
whitespace while byte-level n-grams use all printing and
nonprinting characters.[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
3.
      </p>
    </sec>
    <sec id="sec-3">
      <title>METHODOLOGY AND DATA</title>
      <p>
        The technique used in this paper is based on calculating
and comparing profiles of N-gram frequencies. First, profiles
on training set data that represent the various categories are
computed. Then the profile for a particular testing
document that is to be classified is computed. Finally, a
dissimilarity measure between the document’s profile and each of
the category profiles is computed. The category whose
profile has the smallest value of dissimilarity measure with the
document’s profile is selected. Detailed text categorization
procedure is presented in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        Dissimilarity measures: Dissimilarity measure d is a
function that maps the Cartesian product of two sets of
sequences P1 and P2 (defining specific profiles) into the set
of positive real numbers. It should reflect the dissimilarity
between these two profiles and it should meet the following
conditions:[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
• d(P, P) = 0;
• d(P1, P2) = d(P2, P1);
• the value d(P1, P2) should be small if P1 and P2 are
similar ;
• the value d(P1, P2) should be large if P1 and P2 are
not similar.
      </p>
      <p>The last two conditions are informal as the notion of
similarity (and thus the dissimilarity) is not strictly defined.</p>
      <p>
        In this paper is used four dissimilarity measures. First
of them is measure used by Keˇselj[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and it has a form of
relative distance:
d(P1, P2) =
      </p>
      <p>X
n∈profile
2 · (f1(n) − f2(n)) 2
f1(n) + f2(n)
where f1(n) and f2(n) are frequencies of an n-gram n in the
author profile P1 and the document profile P2.</p>
      <p>
        Other three measures are measures from [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] that
performed best on considered data set:
d1(P1, P2) =
      </p>
      <p>X
n∈profile
2 · (f1(n) − f2(n))
f1(n) + f2(n)
(1)
(2)
√
√
(3)
(4)
d2(P1, P2) =</p>
      <p>X
n∈profile
2 · |f1(n) − f2(n)| 2
pf1(n)2 + f2(n)2
d3(P1, P2) =</p>
      <p>X
n∈profile
2 · |f1(n) − f2(n)|
pf1(n)2 + f2(n)2</p>
      <p>
        In this paper is presented categorization of text documents
in Serbian. For this purpose, Ebart corpus is used.
Ebart: Ebart1 is the largest digital media corpus in
Serbia with almost one million news articles from daily and
weekly newspapers archived by early 2003 onwards. The
current archive is classified into thematic sections following
the model of regular newspaper columns. In this paper a
subset of the Ebart corpus is taken into consideration -
articles from the Serbian daily newspaper ”Politika” that belong
to columns Sport, Economics, Politics, Chronicle &amp; Crime
and Culture &amp; Entertainment published from 2003 to 2006.
There are 5235 such articles. This data set was split into
the training and testing set in the ratio 2 : 1. Fig. 1 shows
the distribution of this corpus.2
Performance evaluation: The standard metrics for the
categorization performance evaluation is considered, namely
micro- and macro-averaged F1 measures. As usual,
microaveraged F1 measure is computed for all documents over
all document categories. Macro-averaged F1 measure
represents the averaged value determined from F1 values
computed for each classification category separately. The
standard definition of these measures and measures of precision
and recall can be found, e.g., in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
4.
      </p>
    </sec>
    <sec id="sec-4">
      <title>RESULTS</title>
      <p>
        This section presents the experimental results of text
categorization obtained for Ebart corpus on five categories:
Sport, Economics, Politics, Chronicle &amp; Crime and Culture
&amp; Entertainment. No preprocessing is done on texts, and
a simple byte n-grams representation is used, treating text
documents simply as byte sequences. Only the measures
selected from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] that give the best results on the
Ebart corpus are considered: d, d1, d2 and d3 (see Sec. 3).
For producing n-grams and their normalized frequencies the
software package Ngrams written by Keˇselj[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] is used. In
1Ebart current archive is available at http://www.arhiv.rs
2All experimental data can be obtained on request from the
author.
1degF .578
a
r
e
v
a
−
o
ircM .70
      </p>
      <p>8
1
gedF .865
a
r
e
v
a
−
o
r
c
aM .860
0
.
8
8
1deF .578
g
a
r
e
v
coa− .870
ir
M
1
F
d
raege .865
v
a
−
o
r
c
aM .60
8
the process of separating testing from training documents
and in the process of categorization, the software package
NgramsClassification3 is used.</p>
      <p>One of the most important question in the byte n-gram
categorization is what are the values of n and L that produce
the best results. To give an answer to this question, the
accuracy (micro- and macro-averaged F1) of the technique
was tested for all values of n-gram size n and the profile
length L that makes sense to do.</p>
      <p>Fig. 2 and 3 shows graphical representation of this
extensive set of experiments taking into account only a few values
of n for which the highest accuracy is achieved and only
dissimilarity measure d (all other measures achieve the
maximum accuracy for the same value of n as d). It can be seen
that the maximum values for micro- and macro-averaged F1
measures are reached for n = 7. For that particulary value
3Source code can be obtained on request from the author.
of n, comparison between measures d, d1, d2 and d3 is
performed. The results of these experiments are shown in Fig.
4 and 5.</p>
      <p>Additionally, Fig. 6 presents micro- and macro-averaged
F1 values for the best results for each measure. All these
results show that the all introduced measures achieves
comparable results.</p>
      <p>Quality of classification is assessed also using a confusion
matrix, i.e., records of correctly and incorrectly recognized
documents for each category. Table 1 give the confusion
matrix for the experiments using the 70000 most frequent
7-grams and dissimilarity measure d. It shows the
information about actual and predicted categorizations done by our
system. Each column of the matrix represents the number of
documents in a predicted class, while each row represents the
number of documents in an actual class. The diagonal
elements show the number of correct classified documents, and
the off-diagonal elements show the number of wrongly
classified documents. The main reason for some wrongly classified
documents comes from the similarities between categories in
real world. For example, the category ”Chronicle &amp; Crime”
and the category ”Politics” are close to each other. The
same stands for ”Politics” and ”Economy”. In the Table 1,
the numbers with a label of ”*” are the numbers of
documents wrongly classified in a category that is close to the
correct category.
5.</p>
    </sec>
    <sec id="sec-5">
      <title>CONCLUSION AND FUTURE WORK</title>
      <p>In this paper is presented the results of classifying Serbian
data set using a new variant of a document categorization
approach based on byte-level n-grams, including all printing
and non-printing characters. The approach relies on a profile
document representation of restricted size and a very simple
algorithm for comparing profiles. It provides an inexpensive
and effective way of classifying documents.</p>
      <p>Dissimilarity measures are subject to further
investigation and improvement, as well as categorization methods
themselves. The plan is to compare the results obtained
by presented method with results of other supervised
methods on the same data sets. This method, being based on
a sequence of bytes, is applicable to different domains and
problems and will be further tested on specific corpora such
as bioinformatics and multi-lingual corpora and on tuning
Internet search engines.</p>
    </sec>
    <sec id="sec-6">
      <title>ACKNOWLEDGEMENTS</title>
      <p>The work presented has been financially supported by the
Ministry of Science and Technological Development,
Republic of Serbia, through Projects No. III47003 and No. 174021.
The author is grateful to prof. Gordana Pavlovi´c-Laˇzeti´c for
her unfailing support and supervision of my research.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>W. B.</given-names>
            <surname>Cavnar</surname>
          </string-name>
          and
          <string-name>
            <given-names>J. M.</given-names>
            <surname>Trenkle</surname>
          </string-name>
          .
          <article-title>N-gram-based text categorization</article-title>
          .
          <source>In In Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis and Information Retrieval</source>
          , pages
          <fpage>161</fpage>
          -
          <lpage>175</lpage>
          ,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>J.</given-names>
            <surname>Graovac</surname>
          </string-name>
          .
          <article-title>A variant of n-gram based language-independent text categorization</article-title>
          .
          <source>Submitted</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>V.</given-names>
            <surname>Keselj</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Peng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Cercone</surname>
          </string-name>
          , and
          <string-name>
            <given-names>C.</given-names>
            <surname>Thomas</surname>
          </string-name>
          .
          <article-title>N-gram-based author profiles for authorship attribution</article-title>
          .
          <source>In In Proceedings of the Pacific Association for Computational Linguistics</source>
          , pages
          <fpage>255</fpage>
          -
          <lpage>264</lpage>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>F.</given-names>
            <surname>Sebastiani</surname>
          </string-name>
          and
          <string-name>
            <given-names>C. N. D.</given-names>
            <surname>Ricerche</surname>
          </string-name>
          .
          <source>Machine learning in automated text categorization. ACM Computing Surveys</source>
          ,
          <volume>34</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>47</lpage>
          ,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A.</given-names>
            <surname>Tomovic</surname>
          </string-name>
          and et al.
          <article-title>N-gram-based classification and unsupervised hierarchical clustering of genome sequences</article-title>
          .
          <source>In Computer Methods and Programs in Biomedicine</source>
          , pages
          <fpage>137</fpage>
          -
          <lpage>153</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D.</given-names>
            <surname>Vitas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Krstev</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Obradovic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Popovic</surname>
          </string-name>
          , and
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Pavlovic-lazetic. An overview of resources and basic tools for processing of serbian written texts</article-title>
          .
          <source>In In Proc. of the Workshop on Balkan Language Resources</source>
          , 1st Balkan Conference in Informatics, pages
          <fpage>97</fpage>
          -
          <lpage>104</lpage>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>