<!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>ENCOPLOT: Pairwise Sequence Matching in Linear Time Applied to Plagiarism Detection ∗</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Cristian Grozea</string-name>
          <email>cristian.grozea@first.fraunhofer.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Christian Gehl</string-name>
          <email>christian.gehl@first.fraunhofer.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marius Popescu</string-name>
          <email>popescunmarius@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Fraunhofer FIRST, IDA Group</institution>
          ,
          <addr-line>Kekulestrasse 7, 12489 Berlin</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Bucharest, Faculty of Mathematics and Computer Science</institution>
          ,
          <addr-line>Academiei 14, Sect. 1, Bucharest</addr-line>
          ,
          <country country="RO">Romania</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2009</year>
      </pub-date>
      <fpage>10</fpage>
      <lpage>18</lpage>
      <abstract>
        <p>In this paper we describe a new general plagiarism detection method, that we used in our winning entry to the 1st International Competition on Plagiarism Detection, the external plagiarism detection task, which assumes the source documents are available. In the first phase of our method, a matrix of kernel values is computed, which gives a similarity value based on n-grams between each source and each suspicious document. In the second phase, each promising pair is further investigated, in order to extract the precise positions and lengths of the subtexts that have been copied and maybe obfuscated - using encoplot, a novel linear time pairwise sequence matching technique. We solved the significant computational challenges arising from having to compare millions of document pairs by using a library developed by our group mainly for use in network security tools. The performance achieved is comparing more than 49 million pairs of documents in 12 hours on a single computer. The results in the challenge were very good, we outperformed all other methods.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Many methods have been developed for
plagiarism detection, especially for the
external plagiarism analysis, which consists in
finding passages in the suspicious documents
which have been plagiarized and the
corresponding text passages in the source
documents. Almost all these methods handle
the text at word level. Various
comparison units have been employed in
plagiarism detection methods. Entire documents
are compared in
        <xref ref-type="bibr" rid="ref12 ref22">(Lyon, Barrett, and
Malcolm, 2004)</xref>
        . Sentences from suspicious
documents are compared to sentences from
reference documents in
        <xref ref-type="bibr" rid="ref1 ref17 ref19 ref9">(Kang, Gelbukh, and Han,
2006)</xref>
        . Mixed-length comparisons in which
suspicious sentences are compared with entire
reference documents were used in
        <xref ref-type="bibr" rid="ref24 ref24 ref5 ref5 ref6 ref6">(Barr´onCeden˜o and Rosso, 2009; Barr´on-Ceden˜o,
Rosso, and Bened´ı, 2009)</xref>
        . Irrespective of the
lem of rewording in plagiarism, PPChecker
        <xref ref-type="bibr" rid="ref1 ref17 ref19 ref9">(Kang, Gelbukh, and Han, 2006)</xref>
        is based on
a special designed similarity measure, that
takes into account also the synonyms
(obtained from the WordNet) of the words in the
suspicious sentences. Some of the most
elaborate similarity measures used in plagiarism
detection are described in
        <xref ref-type="bibr" rid="ref2 ref3 ref3 ref4 ref4">(Bao et al., 2003;
Bao et al., 2004a; Bao et al., 2004b)</xref>
        . These
measures are derived from the string kernel,
a kernel type successfully used in text
categorization
        <xref ref-type="bibr" rid="ref11">(Lodhi et al., 2002)</xref>
        . The string
kernel works at character level, although in
        <xref ref-type="bibr" rid="ref2 ref3 ref3 ref4 ref4">(Bao et al., 2003; Bao et al., 2004a; Bao et
al., 2004b)</xref>
        it is extended to work at word
level, comparing two semantic sequences
according to their common words and position
information.
      </p>
      <p>
        Using words is natural in text analysis
tasks like text categorization (by topic),
authorship identification and plagiarism
detection. Perharps surprisingly, recent results
proved that methods that handle the text at
character level can also be very effective in
text analysis tasks. In
        <xref ref-type="bibr" rid="ref11">(Lodhi et al., 2002)</xref>
        string kernels were used for document
categorization with very good results. Trying
to explain why treating documents as
symbol sequences and using string kernels
obtained such good results the authors suppose
that: ”the [string] kernel is performing
something similar to stemming, hence providing
semantic links between words that the word
kernel must view as distinct”. String
kernels were also successfully used in authorship
identification
        <xref ref-type="bibr" rid="ref1 ref15 ref17 ref18 ref19 ref9">(Sanderson and Guenter, 2006;
Popescu and Dinu, 2007)</xref>
        . A possible reason
for the success of string kernels in
authorship identification is given in
        <xref ref-type="bibr" rid="ref15 ref18">(Popescu and
Dinu, 2007)</xref>
        : ”the similarity of two strings as
it is measured by string kernels reflects the
similarity of the two texts as it is given by
the short words (2-5 characters) which
usually are function words, but also takes into
account other morphemes like suffixes (’ing’
for example) which also can be good
indicators of the author’s style”1
      </p>
      <p>
        For plagiarism detection, the only
approach that handles the text at character
level that we are aware of is in
        <xref ref-type="bibr" rid="ref1 ref17 ref19 ref9">(Bao, Lyon,
and Lane, 2006)</xref>
        , for Chinese, and there is
justified by the difficulties of the Chinese
lan1the string kernel used in
        <xref ref-type="bibr" rid="ref15 ref18">(Popescu and Dinu,
2007)</xref>
        takes into account substrings of length up to
5 characters.
guage (word segmentation).
      </p>
      <p>
        There is a strong connection between the
research in NLP and the research in computer
network security. In recent years, network
security research started to approach the
problem of detecting automatically unknown
attacks as soon as they reach the targeted
system. These attacks may follow the syntax
but try to exploit the semantics of the
network communication between the client and
the server applications, in order to gain
access over the attacked computer or at least
to prevent it from working normally. The
communication process defined by the
application layer protocols – e.g. HTTP, FTP,
RPC or IMAP – can also be considered as a
text-based communication in an artificial
language. The idea of payload analysis, which
treats the data as sequences of bytes has
been explored in detail
        <xref ref-type="bibr" rid="ref1 ref1 ref10 ref12 ref15 ref17 ref17 ref18 ref19 ref19 ref21 ref22 ref9 ref9">(Kruegel, Toth, and
Kirda, 2002; Wang and Stolfo, 2004; Rieck
and Laskov, 2006; Wang, Parekh, and Stolfo,
2006; Rieck and Laskov, 2007)</xref>
        . As the focus
in this field shifted towards applying more
advanced machine learning methods,
generalizing the extraction and representation of
the features has increased much the
flexibility in defining similarity measures between
sequential data, in a security context. The
work
        <xref ref-type="bibr" rid="ref16">(Rieck and Laskov, 2008)</xref>
        presents an
efficient way to combine features extracted
from byte sequences, e.g. words or n-grams
with arbitrary n value, for a wide range of
linear and non-linear similarity measures.
      </p>
      <p>
        Graphics methods in comparing sequences
have been used in many fields, mostly
under the name dotplot – see
        <xref ref-type="bibr" rid="ref13">(Maizel and Lenk,
1981)</xref>
        for one of the first uses in biology
and
        <xref ref-type="bibr" rid="ref7">(Church and Helfman, 1993)</xref>
        for uses in
source text comparison. Whereas very
attractive for exploratory data analysis,
building this graphic is potentially quadratic in
time and space. Also it tends to be noisy,
by showing many irrelevant coincidences
between the sequences compared. Even with
these limitations, the method has been
applied to source code, videos, music, protein
and other biological sequences, with various
ways to filter the noisy graphics and to handle
the problem of the potential quadratic size.
We improve on this technique by deriving our
own, linear space, linear time technique, that
we named the encoplot, short for “eN-gram
COincidence PLOT”. It is fully described in
Section 2.3, with code in Appendix 1.
Our plagiarism detection method can be
described as a combination of techniques
from many fields: it is character n-gram
based. It leverages a very efficient network
security software to compute the matrices
of kernel values. It uses the very fast
encoplot algorithm and processes the encoplot
data in a quantitative fashion to solve what
can be seen as a rudimentary machine vision
or a specialized 2-dimensional data
clustering task, in order to identify the matching
text passages for a given document pair, as
explained thoroughly below.
      </p>
      <p>
        In what follows, the dataset specifics and
the time performance figures refer to the
dataset of the 1st International
Competition on Plagiarism Detection, external
plagiarism detection task
        <xref ref-type="bibr" rid="ref24 ref5">(Webis at
BauhausUniversit¨at Weimar and NLEL at
Universidad Polit´ecnica de Valencia, 2009)</xref>
        . The
development corpus of this dataset contained
about 7000 source documents and 7000
suspicious ones, with the plagiarism generated
automatically with various degrees of
obfuscation (permutations, words deleted, inserted
or replaced by synonyms or antonyms) and
annotated. The competition corpus had the
same characteristics (different documents)
and the annotation was missing.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Methods</title>
      <p>Our approach consists of two main phases.
In the first phase, a matrix of string
kernel values is computed, which gives a
similarity value between each source and each
suspicious document. Then, for each source,
the possible “destinations” (suspicious
documents) are ranked based on their similarity
level with the current source, in decreasing
order. In the second phase, each promising
pair is further investigated, in order to
extract the precise positions and lengths of the
subtexts that have been copied and maybe
obfuscated by the random plagiarist. In the
end we do a supplementary filtering that
increases the precision with the price of
decreasing the recall.</p>
      <sec id="sec-2-1">
        <title>2.1 Selecting a kernel and computing the matrix of kernel values for a large set of documents</title>
        <p>
          Based on the work of
          <xref ref-type="bibr" rid="ref16">(Rieck and Laskov,
2008)</xref>
          , a C library for sequential data,
libmindy, has been implemented by our
netdistance function d(x, y)
Minkowski
Canberra
k
ng∈An |φng(x) − φng(y)|k
        </p>
        <p>|φng(x)−φng(y)|
ng∈An φng(x)+φng(y)
kernel function k(x, y)
linear kernel
RBF kernel
exp(−
ng∈An φng(x) · φng(y)
ng∈An ||φng(x)−φng(y)||2 )
2σ2
work security research group. It has been
developed mainly for being used in
building real-time network analysis tools at packet
level, as part of network intrusion detection
and prevention systems. It can map byte
sequences to a vectorial n-gram
representation, such that the similarity between two
byte sequences can be expressed in terms of
distance and kernel functions on those
representations. The n-gram extraction set of
feasible byte sequences is given by An = Σn,
where Σ is the alphabet (in our case the
whole ASCII–8 set). The n-gram
embedding function φ for a byte sequence x is
then defined as φ(x) = (φng(x))ng∈An with
φng(x) = emb(x, ng), where the dimension
of the vector φ(x) is |An|. The function
emb(x, ng) returns either the frequency, the
count or the presence bit for a n-gram ng in
x. With the embedding function φ fixed, one
can compute a pairwise similarity value for
the vectorial representations of two byte
sequences. Table 1 presents a selection of the
implemented distances and similarity
measures that we could have used (where x and
y are arbitrary byte sequences).</p>
        <p>
          Experiments with a very small subset of
only 5 documents and our previous
experience in string kernels led us to use the linear
kernel over a representation where every
ngram present is marked by 1 and every other
is marked by 0 (ignoring thus the frequencies
of the n-grams). The kernel was normalized,
such as K(x, x) = 1 for any string x. For the
length of the n-grams we used 16 characters.
Although in our estimations 18 should have
been better (closer to three times the average
word length plus two separators), the
speedup of the software used can only be obtained
up to n-grams of length 16, see below and
Appendix 1 for details. Using windows of two
to three words in plagiarism detection was
found to be the best choice by
          <xref ref-type="bibr" rid="ref12 ref22">(Lyon, Barrett,
and Malcolm, 2004)</xref>
          and
          <xref ref-type="bibr" rid="ref24 ref5 ref6">(Barro´n-Ceden˜o and
Rosso, 2009)</xref>
          .
        </p>
        <p>The computation of a matrix of kernel
values with sizes as large as 7000 is
computationally intensive. There are more than 49
million pairs of documents for which the
kernel value has to be computed, in each of
the two datasets, the development and the
competition corpus, accounting for a total of
more than 98 million pairs to consider.
libmindy has had already a tool for building a
(symmetric) kernel matrix for a set of
documents. We extended this tool for being able
to handle asymmetric matrices of kernel
values, where the kernel values are computed for
each x ∈ X and y ∈ Y , where X and Y are
two independent finite sets of files, not
necessarily having the same cardinal. While the
new tool could in principle perform the task
fast enough, it would have needed an amount
of RAM of about 400 GB for a kernel based
on length 16 n-grams. To avoid this issue,
we partitioned the matrix of kernel values in
blocks of sizes up to 1000x1000 (1 million
pairs in most blocks), which required only
8 to 10 GB of RAM for processing. Those
64 blocks per dataset we processed one after
the other, but the processing of each block
was fully parallelized on the 8 cores of the
machine, as a result of internally
distributing the tasks by the means of OpenMP
programming. Processing a full dataset took 12
hours on the machine we used (Dell
Precision T7400). Although we had access to a
cluster, it offered only a 32-bit environment.
This would have slowed the whole
processing by a factor that would almost completely
eliminated the advantage of having 8 to 12
times more computing cores, and this is why
we decided to use a single multi-core
computer.
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Pruning of the pairs</title>
        <p>If the total processing for one pair of
documents (up to book length level) would only
take one second, this would lead to a total
computation time of more than three years!
Even by successfully parallelizing this task
and dividing the time by hopefully 8 (the
number of computing cores), the time needed
would have been more than 4 months. It
was obvious that even with the matrix of
kernel values computed, there is too much
work in comparing the documents in each
pair. Pruning was seen from the start as
a requirement, the question was what effect
will it have on limiting the performance that
can be achieved. We have considered
ranking the pairs such that the ones with most
chances of corresponding to plagiarism come
first. Ranking on the absolute values of the
kernel proved to work worst. Ranking for
each source the suspicious documents proved
to provide a consistent 10% advantage over
ranking for each suspicious document the
sources. Therefore, given also the values that
can be seen in the Figure 1, we decided to
limit our effort to the first 51 most promising
suspicious documents for each given source.
2.3</p>
      </sec>
      <sec id="sec-2-3">
        <title>Comparing two documents</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>The encoplot</title>
      <p>With the maximum effort down to an
estimate of about 100 hours, assuming spending
in average a second per exhaustive document
comparison (with the hope of reducing it to
12 hours by multicore parallelism), we
proceeded to search for a way to identify what
the documents have in common, if anything.
Essential to this was the visualization of the
coincidence pattern of n-grams between two
documents. This is a scatter plot of a
sublist of the positions where both texts have
the same n-gram. We call this plot encoplot.
Plots computed for pairs in the development
corpus can be seen in Figures 2 and 3. All
these plots use documents in the development
dataset.</p>
      <p>Related ideas (the “dotplot” graphs) exist
about visualizing the n-grams that two texts
(or sequences) share. The problem with those</p>
      <p>2 3 4 5 6
Source Document Position
7
is that the number of pairs can be quadratic
in the size of the documents. For megabytes
long texts, this can easily become
computationally intractable. We solve this issue by
limiting ourselves to a sublist that is
guaranteed to be no longer than the shortest of
the documents, and can be computed in
linear time. The precise procedure we employed
starts by sorting virtually the sets of n-grams
for both documents to be compared. Then
these ordered sets of n-grams are compared
with a procedure that is derived from the
procedure from merging two sorted lists. Every
time the smallest elements of the two lists
differ, the smallest of them is dropped, without
producing any output. Every time the
smallest elements of the lists are equal, the pair of
positions on which this identical n-gram
occurs is being collected by outputting it to the
standard output. Code for this core
procedure is given in Appendix 1. Please note that
encoplot pairs the first instance of an n-gram
in one document with the first instance of the
same in the other document, the second one
with the second one and so on – as opposed
to the dotplot, wich pairs each instance with
each instance.
2.4</p>
      <sec id="sec-3-1">
        <title>Heuristics used for separating the copied subtexts</title>
        <p>Once the encoplot data (the list of pairs of
indexes) is obtained, it is sorted by the value
of the first index in each pair, which
corresponds to the position in source of the
common n-gram. From this list a local
“contiguity” score is derived by computing whether
there is simultaneously a small jump on both
indexes (sum of absolute jumps less than 4)
when going from a pair to the next pair,
followed by a smoothing by a convolution with
a constant vector of length 16. The
contiguity score for an encoplot is displayed in red in
Figures 2 and 2. Then a Monte Carlo
optimization procedure is called, not more than
30 times for each document pair, which in
10 attempts tries to find the largest group
from the current encoplot data. The start of
the group is decided randomly with uniform
distribution over the list of available pairs,
then the group is extended to left and right
such that the average contiguity score stays
above 0.5 and there are no jumps (skipped
portions) longer than 512 in any 16 steps.
After a group is obtained, it is checked to
have an average contiguity score of over 0.75
and a length of at least 256 characters. If
not, it is rejected as insignificant. If kept, it
is projected to the dimension of the indexes
that correspond to the suspicious document,
and only the compact core of it is preserved.
The compact core is obtained by sorting on
the suspicious document axis and eliminating
the outliers by starting from the group center
and extending it to left and right while the
skips are less than 256 positions. What
remains is projected back onto the source
document axis, obtaining thus an estimate of
the indexes whose convex hull define the two
subtexts corresponding to each other. This
candidate of a plagiarism instance is checked
once again, this time for a final length of at
least 256, for not having shrinked to less than
half with respect to the initial group length
and for the two subtexts not having sizes too
different (the absolute difference more than
half of the mean of the two lengths). This
subset of the encoplot data is removed, the
plagiarism instance is outputted if all tests
succeeded, and the procedure is repeated in
the search for more groups. If the group
found fails to satisfy the checks, it is deemed
as a failure. At three consecutive failures the
search is abandoned and the treatment of the
pair of documents is considered completed.
This decision may be risky, but accelerates
substantially this phase, as on very
complicated document pairs it can take minutes to
completely examine an involved pair. On the
other hand, for the actually unrelated
documents this ends the investigation rapidly.
Technically, we have accelerated this
processing phase even more by running
simultaneously up to 10 detailed examinations of
document pairs at a time, trying to balance the
processing power required and the disk
latency.
3</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Results</title>
      <p>We combined the best F-measure – the
harmonic mean of precision and recall – 0.6976
(the next competitor had 0.6192) with the
best granularity – lack of fragmentation in
detection of the plagiated passages – 1.0027
(the next best value was 1.0164), winning
thus the competition.
4</p>
    </sec>
    <sec id="sec-5">
      <title>Discussion and Conclusions</title>
      <p>
        The first question is whether our choice to
compare the documents in pairs was optimal.
Indexing based methods could be faster, by
eliminating the need for exhaustive pairwise
comparison of documents in a large corpus.
They function by first indexing the collection
of source documents and then searching for
parts of the suspicious documents in the
index, as the system MOSS
        <xref ref-type="bibr" rid="ref20">(Schleimer,
Wilkerson, and Aiken, 2003)</xref>
        does. Such an
inflexible approach cannot handle well
obfuscation, as opposed to our approach. On the
other hand, flexible matching is an
alwayscurrent research topic in information retrieval
systems
        <xref ref-type="bibr" rid="ref14">(Navarro, 2001)</xref>
        , and this eventually
improves plagiarism detection as well. We
think that, whereas needing more
computational effort, our approach had the chance
of producing better results. And, as a
consequence of using highly optimized network
analysis code, it did so in a reasonable time,
even when run on a single contemporary
computer, as opposed to a full cluster. One could
say that it was closer to being optimal in
terms of quality of the results, while still
being acceptable in terms of running time.
      </p>
      <p>A second question of interest is whether
our values for the hyperparameters of the
method are optimal for this dataset. The
answer is probably no, but maybe not far from
that. They have been chosen by educated
guess guided by the exploratory data
analysis, as opposed to blindly optimizing a
crossvalidation towards the best (over)fitting.</p>
      <p>
        The third interesting issue is the claim
of some experts that only the humans can
have very good results at spotting plagiarism
        <xref ref-type="bibr" rid="ref23">(Weber-Wulff, 2008)</xref>
        . We think that, as far
as the ethics is concerned, a human must
look at the evidence before claiming a case
as one of plagiarism. And of course, text
understanding is still not within the reach
of artificial intelligence yet. On the other
hand, the claim that the only automatization
in plagiarism detection should limit to using
the one’s favorite search engine and searching
for paragraphs selected based on one’s
intuition is questionable. How would such an
expert deal with 7000 documents up to a book
length? How long would it take to process
those by hand, even using a public search
engine? How long does it take one to read 7000
works/books? The need for automatization
seems evident, as it was to
        <xref ref-type="bibr" rid="ref8">(Grozea, 2004)</xref>
        when he had to grade 400 projects from 60
students in less than 24 hours.
Crowdsourcing could also be a possibility, but one needs
very big crowds for that (optimally quadratic
size, if using the same choice in the
tradeoff between speed and quality as we chose).
Time is the key factor in plagiarism
detection.
      </p>
      <p>Given the very good results obtained by
our method it is worth asking – and
further investigating – whether using character
n-grams offers any advantage over using word
n-grams. First, let us note that our method
uses n-grams of 16 characters which in
average2 correspond to word trigrams (the
standard approach in plagiarism detection). It
may seem that (on average) the same
information is brought by 16 characters n-grams
and word trigrams. What differentiates the
two types of n-grams is in our opinion the fact
that character n-grams favor long words over
short ones, and when people copy text they
do that for the content words of the copied
text that tend to be longer than the
functional words (stop words) which are short.
For example: a common syntagmatic
expression3 like ”as far as” will contribute with one
word trigram, but with none character
16gram. On the other hand, a sequence of
content words (worth being copied) like
”educated guess guided” will contribute again
with only one word trigram, but with 6
character 16-grams.</p>
      <p>Another item to discuss is how to balance
precision and recall in automatic plagiarism
detection systems. Given that a human is in
many cases the final link in the chain that
leads to the proof of plagiarism, the effort of
that human must be spared as much as
possible. The accuse of plagiarism is so strong,
that it needs strong evidence. Both these
aspects recommend to balance the precision
and recall towards a high precision, even at
2The average word length in the corpus is 5.2
3Frequently and systematically co-occurring
lexical items.
the expense of lowering the recall. This is
how we tuned our system’s parameters,
including but not limited to the last
checking phase. Of course, accurate comparison
of systems should take into account the
entire precision-recall curve. By plotting on the
same graph these curves for more systems,
one could easily see where is the best
performance region for each system and whether or
not one of the systems is overall better than
another system.</p>
      <p>Related to the maximum achievable
precision while keeping a fair recall is the
issue of the documents independence and of
the automatic plagiarism. The dataset
contains plagiarism built automatically and
randomly and only these borrowings between the
source documents and the suspicious
documents had to be found. But the documents
were not independent enough: there are pairs
of documents with the same or almost the
same content, such as independent
translations of “One Thousand and One Night” or
several Bible editions, authors doing heavy
reuse from their previous works (the so-called
self-plagiarism). These are interesting in two
ways: they are better examples of what the
human plagiarism is, so spotting those as
related is very good. On the other hand, this
can be seen as unintended (by the organizers)
plagiarism, so any such pair reported will
actually lower the precision score.</p>
      <p>A very interesting issue is the asymmetry
of the ranking quality. Why is it 10%
better to rank all suspicious documents for any
fixed source instead of ranking all possible
sources for every fixed suspicious document,
as clearly seen in Figure 1? A possible source
of this asymmetry is that while it was
guaranteed for each suspicious document that the
areas plagiated do not overlap, this was not
the case for the source documents, where the
areas plagiated could overlap. This
asymmetry deserves more investigation, being one of
the few glints of hope so far to tackling what
could be the biggest open problem in
automatic plagiarism detection, that is
determining the direction of plagiarism in a pair of
documents – being able to indicate with
confidence which is the copy and which is the
original.</p>
      <p>To conclude, by combining advanced
software engineering and effort-sparing heuristics
tuned using the novel visualization technique
encoplot, we have been able to achieve the top
placement in the final results, proving that
the interaction of NLP researchers with
networks security researchers can lead to
highperformance NLP systems.</p>
      <sec id="sec-5-1">
        <title>4.1 Acknowledgment</title>
        <p>We thank Dr. Andreas Ziehe and the
anonymous reviewers for the thorough review of our
paper and for the useful suggestions.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>A Appendix 1: Encoplot code</title>
      <p>This appendix provides the listing of the
implementation of the encoplot algorithm. At
its core is a very fast implementation of
the radix sort algorithm for virtually
sorting the n-grams in a text without swapping
any memory blocks. It is a specialization of
the general radix sort algorithm. The key
part is avoiding to recompute the
frequencies at each step in the radix sort algorithm,
and relying instead on updating those
incrementally. Another key technical aspect is
the use of the 128 bit unsigned integer type
uint128 t, possible with the gcc compiler on
certain platforms, which allows for very good
speeds up to n-grams of length 16, on
64bit architectures, such as the common x86-64.
The main code uses this virtual sorting of the
n-grams sets to compute the encoplot data of
two given files, a central part of our
plagiarism detection method, as explained above.
// computes the encoplot data of a p a i r of f i l e s
#i n c l u d e ” s t d i o . h”
#i n c l u d e ” s t d l i b . h”
#i n c l u d e ” s t r i n g . h”
#i n c l u d e &lt;sys / types . h&gt;
#i n c l u d e &lt;sys / s t a t . h&gt;
#i n c l u d e &lt;unistd . h&gt;
typedef u i n t 1 2 8 t tngram ;
//CrG r s o r t
#d e f i n e f r (x , y ) f o r ( i n t x=0;x&lt;y ; x++)
i n t ∗ index rsort ngrams (</p>
      <p>unsigned char ∗x , i n t l , i n t DEPTH){
i n t NN=l−DEPTH+1; i f (NN&gt;0){
unsigned char ∗ pin=x+NN;
unsigned char ∗pout=x ;
i n t ∗ ix =( i n t ∗) malloc (NN∗ s i z e o f ( i n t ) ) ;
i n t ∗ox=( i n t ∗) malloc (NN∗ s i z e o f ( i n t ) ) ;
const i n t RANGE=256;
i n t counters [RANGE] ; i n t s t a r t p o s [RANGE] ;
f r ( i ,NN) ix [ i ]= i ;
// radix sort , the input i s x ,
// the output rank i s ix
f r (k ,RANGE) counters [ k ]=0;
f r ( i ,NN) counters [ ∗ ( x+i )]++;
f r ( j ,DEPTH){ i n t o f s=j ;// low endian
i n t sp =0;
f r (k ,RANGE){ s t a r t p o s [ k]= sp ;</p>
      <p>sp+=counters [ k ] ; }
f r ( i ,NN){ unsigned char c=x [ o f s+ix [ i ] ] ;</p>
      <p>ox [ s t a r t p o s [ c]++]= ix [ i ] ; }
memcpy( ix , ox ,NN∗ s i z e o f ( ix [ 0 ] ) ) ;
// update counters
counters [i∗f p(jo&lt;uDt+EP+T]−H−−1;c){ounters [ ∗ pin++]++;}}
#f rdeeef i(noex ) M;rAeXtBuUrFnSIZix 8;}0}00123
unsigned char f i l e 1 [MAXBUFSIZ ] ;
unsigned char f i l e 2 [MAXBUFSIZ ] ;
i n t l1 , l 2 ;
i n l i n e tngram readat (
const unsigned char ∗buf , i n t poz ){
return ∗( tngram ∗)( buf+poz ) ; }
i n t main ( i n t argc , char ∗∗ argv ){
i n t depth=s i z e o f ( tngram ) ;
FILE ∗ f1=fopen ( argv [ 1 ] , ” rb ” ) ;
l 1=f r e a d ( f i l e 1 , 1 ,MAXBUFSIZ, f1 ) ; f c l o s e ( f1 ) ;
FILE ∗ f2=fopen ( argv [ 2 ] , ” rb ” ) ;
l 2=f r e a d ( f i l e 2 , 1 ,MAXBUFSIZ, f2 ) ; f c l o s e ( f2 ) ;
// index the ngrams
i n t ∗ ix1=in dex rsort ngr ams ( f i l e 1 , l1 , depth ) ;
i n t ∗ ix2=in dex rsort ngr ams ( f i l e 2 , l2 , depth ) ;
i n t i 1 =0; i n t i 2 =0;// merge
tngram s1=readat ( f i l e 1 , ix1 [ i 1 ] ) ;
tngram s2=readat ( f i l e 2 , ix2 [ i 2 ] ) ;
l1 −=(depth −1); l2 −=(depth −1);
while ( i1&lt;l 1 &amp;&amp; i2&lt;l 2 ){
i f ( s1==s2 ){
p r i n t f (”%d %d\n” , ix1 [ i 1 ] , ix2 [ i 2 ] ) ;
i 1 ++; i f ( i1&lt;l 1 ) s1=readat ( f i l e 1 , ix1 [ i 1 ] ) ;
i 2 ++; i f ( i2&lt;l 2 ) s2=readat ( f i l e 2 , ix2 [ i 2 ] ) ; }
e l s e i f ( s1&lt;s2 ){</p>
      <p>i 1 ++; i f ( i1&lt;l 1 ) s1=readat ( f i l e 1 , ix1 [ i 1 ] ) ; }
e l s e i f ( s2&lt;s1 ){</p>
      <p>i 2 ++; i f ( i2&lt;l 2 ) s2=readat ( f i l e 2 , ix2 [ i 2 ] ) ; } }
f r e e ( ix2 ) ; f r e e ( ix1 ) ; return 0;}</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <surname>Bao</surname>
          </string-name>
          , Jun Peng, Caroline Lyon, and
          <string-name>
            <surname>Peter</surname>
            <given-names>C. R.</given-names>
          </string-name>
          <string-name>
            <surname>Lane</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Copy detection in chinese documents using ferret</article-title>
          .
          <source>Language Resources and Evaluation</source>
          ,
          <volume>40</volume>
          (
          <issue>3-4</issue>
          ):
          <fpage>357</fpage>
          -
          <lpage>365</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <surname>Bao</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Peng</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Yi</surname>
            <given-names>Shen</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao-Dong</surname>
            <given-names>Liu</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hai-Yan Liu</surname>
          </string-name>
          , and
          <string-name>
            <surname>Xiao-Di Zhang</surname>
          </string-name>
          .
          <year>2003</year>
          .
          <article-title>Document copy detection based on kernel method</article-title>
          .
          <source>In Proceedings of Natural Language Processing and Knowledge Engineering Conference (IEEE)</source>
          , pages
          <fpage>250</fpage>
          -
          <lpage>255</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <surname>Bao</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Peng</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Yi</surname>
            <given-names>Shen</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao-Dong</surname>
            <given-names>Liu</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hai-Yan Liu</surname>
          </string-name>
          , and
          <string-name>
            <surname>Xiao-Di Zhang</surname>
          </string-name>
          . 2004a.
          <article-title>Finding plagiarism based on common semantic sequence model</article-title>
          .
          <source>In Qing Li</source>
          ,
          <string-name>
            <given-names>Guoren</given-names>
            <surname>Wang</surname>
          </string-name>
          , and Ling Feng, editors,
          <source>WAIM</source>
          , volume
          <volume>3129</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>640</fpage>
          -
          <lpage>645</lpage>
          . Springer.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Bao</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Peng</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jun-Yi</surname>
            <given-names>Shen</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao-Dong</surname>
            <given-names>Liu</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hai-Yan Liu</surname>
          </string-name>
          , and
          <string-name>
            <surname>Xiao-Di Zhang</surname>
          </string-name>
          . 2004b.
          <article-title>Semantic sequence kin: A method of document copy detection</article-title>
          . In Honghua Dai, Ramakrishnan Srikant, and Chengqi Zhang, editors,
          <source>PAKDD</source>
          , volume
          <volume>3056</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>529</fpage>
          -
          <lpage>538</lpage>
          . Springer.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>Barro´n-Ceden˜o, Alberto</article-title>
          and
          <string-name>
            <given-names>Paolo</given-names>
            <surname>Rosso</surname>
          </string-name>
          .
          <year>2009</year>
          .
          <article-title>On Automatic Plagiarism Detection based on n-grams Comparison</article-title>
          . In Mohand Boughanem, Catherine Berrut, Josiane Mothe, and Chantal Soul´e-Dupuy, editors,
          <source>ECIR</source>
          <year>2009</year>
          , volume
          <volume>5478</volume>
          <source>of LNCS</source>
          , pages
          <fpage>696</fpage>
          -
          <lpage>700</lpage>
          , Toulouse, France. Springer.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>Barro´</surname>
            n-Ceden˜o, Alberto,
            <given-names>Paolo</given-names>
          </string-name>
          <string-name>
            <surname>Rosso</surname>
          </string-name>
          , and Jos´e-Miguel Bened´ı.
          <year>2009</year>
          .
          <article-title>Reducing the Plagiarism Detection Search Space on the Basis of the Kullback-Leibler Distance</article-title>
          . In Alexander F. Gelbukh, editor,
          <source>CICLing</source>
          <year>2009</year>
          , volume
          <volume>5449</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>523</fpage>
          -
          <lpage>534</lpage>
          , Mexico, Mexico. Springer.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Church</surname>
            ,
            <given-names>K.W.</given-names>
          </string-name>
          and
          <string-name>
            <given-names>J.I.</given-names>
            <surname>Helfman</surname>
          </string-name>
          .
          <year>1993</year>
          .
          <article-title>Dotplot: A program for exploring selfsimilarity in millions of lines of text and code</article-title>
          .
          <source>Journal of Computational and Graphical Statistics</source>
          , pages
          <fpage>153</fpage>
          -
          <lpage>174</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <surname>Grozea</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <year>2004</year>
          .
          <article-title>Plagiarism detection with state of the art compression programs</article-title>
          .
          <source>Report CDMTCS-247, Centre for Discrete Mathematics and Theoretical Computer Science</source>
          , University of Auckland, Auckland, New Zealand,
          <year>August</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <surname>Kang</surname>
            ,
            <given-names>NamOh</given-names>
          </string-name>
          , Alexander F. Gelbukh, and
          <string-name>
            <surname>Sang-Yong Han</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Ppchecker: Plagiarism pattern checker in document copy detection</article-title>
          . In Petr Sojka, Ivan Kopecek, and Karel Pala, editors,
          <source>TSD</source>
          , volume
          <volume>4188</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>661</fpage>
          -
          <lpage>667</lpage>
          . Springer.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <surname>Kruegel</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Toth</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E.</given-names>
            <surname>Kirda</surname>
          </string-name>
          .
          <year>2002</year>
          .
          <article-title>Service specific anomaly detection for network intrusion detection</article-title>
          .
          <source>In Proc. of ACM Symposium on Applied Computing</source>
          , pages
          <fpage>201</fpage>
          -
          <lpage>208</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <surname>Lodhi</surname>
            , Huma, Craig Saunders, John ShaweTaylor, Nello Cristianini, and
            <given-names>Christopher J. C. H.</given-names>
          </string-name>
          <string-name>
            <surname>Watkins</surname>
          </string-name>
          .
          <year>2002</year>
          .
          <article-title>Text classification using string kernels</article-title>
          .
          <source>Journal of Machine Learning Research</source>
          ,
          <volume>2</volume>
          :
          <fpage>419</fpage>
          -
          <lpage>444</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <surname>Lyon</surname>
            , Caroline,
            <given-names>Ruth</given-names>
          </string-name>
          <string-name>
            <surname>Barrett</surname>
            , and
            <given-names>James</given-names>
          </string-name>
          <string-name>
            <surname>Malcolm</surname>
          </string-name>
          .
          <year>2004</year>
          .
          <article-title>A theoretical basis to the automated detection of copying between texts, and its practical implementation in the ferret plagiarism and collusion detector</article-title>
          .
          <source>In Plagiarism: Prevention, Practice and Policies Conference.</source>
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <surname>Maizel</surname>
            ,
            <given-names>J.V.</given-names>
          </string-name>
          and
          <string-name>
            <given-names>R.P.</given-names>
            <surname>Lenk</surname>
          </string-name>
          .
          <year>1981</year>
          .
          <article-title>Enhanced graphic matrix analysis of nucleic acid and protein sequences</article-title>
          .
          <source>Proceedings of the National Academy of Sciences</source>
          ,
          <volume>78</volume>
          (
          <issue>12</issue>
          ):
          <fpage>7665</fpage>
          -
          <lpage>7669</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          <string-name>
            <surname>Navarro</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <year>2001</year>
          .
          <article-title>A guided tour to approximate string matching</article-title>
          .
          <source>ACM Computing Surveys (CSUR)</source>
          ,
          <volume>33</volume>
          (
          <issue>1</issue>
          ):
          <fpage>31</fpage>
          -
          <lpage>88</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          <string-name>
            <surname>Popescu</surname>
            , Marius and
            <given-names>Liviu P.</given-names>
          </string-name>
          <string-name>
            <surname>Dinu</surname>
          </string-name>
          .
          <year>2007</year>
          .
          <article-title>Kernel methods and string kernels for authorship identification: The federalist papers case</article-title>
          .
          <source>In Proceedings of the International Conference on Recent Advances in Natural Language Processing (RANLP07)</source>
          , Borovets, Bulgaria, September.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          <string-name>
            <surname>Rieck</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Laskov</surname>
          </string-name>
          .
          <year>2008</year>
          .
          <article-title>Linear-time computation of similarity measures for sequential data</article-title>
          .
          <source>The Journal of Machine Learning Research</source>
          ,
          <volume>9</volume>
          :
          <fpage>23</fpage>
          -
          <lpage>48</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          <string-name>
            <surname>Rieck</surname>
            , Konrad and
            <given-names>Pavel</given-names>
          </string-name>
          <string-name>
            <surname>Laskov</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Detecting unknown network attacks using language models</article-title>
          .
          <source>In Detection of Intrusions and Malware, and Vulnerability Assessment, Proc. of 3rd DIMVA Conference</source>
          , LNCS, pages
          <fpage>74</fpage>
          -
          <lpage>90</lpage>
          ,
          <year>July</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          <string-name>
            <surname>Rieck</surname>
            , Konrad and
            <given-names>Pavel</given-names>
          </string-name>
          <string-name>
            <surname>Laskov</surname>
          </string-name>
          .
          <year>2007</year>
          .
          <article-title>Language models for detection of unknown attacks in network traffic</article-title>
          .
          <source>Journal in Computer Virology</source>
          ,
          <volume>2</volume>
          (
          <issue>4</issue>
          ):
          <fpage>243</fpage>
          -
          <lpage>256</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          <string-name>
            <surname>Sanderson</surname>
            , Conrad and
            <given-names>Simon</given-names>
          </string-name>
          <string-name>
            <surname>Guenter</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Short text authorship attribution via sequence kernels, markov chains and author unmasking: An investigation</article-title>
          .
          <source>In Proceedings of the 2006 Conference on Empirical Methods in Natural Language Processing</source>
          , pages
          <fpage>482</fpage>
          -
          <lpage>491</lpage>
          , Sydney, Australia, July. Association for Computational Linguistics.
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          <string-name>
            <surname>Schleimer</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>D.S.</given-names>
            <surname>Wilkerson</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Aiken</surname>
          </string-name>
          .
          <year>2003</year>
          .
          <article-title>Winnowing: local algorithms for document fingerprinting</article-title>
          .
          <source>In Proceedings of the 2003 ACM SIGMOD international conference on Management of data</source>
          , pages
          <fpage>76</fpage>
          -
          <lpage>85</lpage>
          . ACM New York, NY, USA.
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>J.J.</given-names>
            <surname>Parekh</surname>
          </string-name>
          , and
          <string-name>
            <given-names>S.J.</given-names>
            <surname>Stolfo</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Anagram: A content anomaly detector resistant to mimicry attack</article-title>
          . pages
          <fpage>226</fpage>
          -
          <lpage>248</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          and
          <string-name>
            <given-names>S.J.</given-names>
            <surname>Stolfo</surname>
          </string-name>
          .
          <year>2004</year>
          .
          <article-title>Anomalous payload-based network intrusion detection</article-title>
          . pages
          <fpage>203</fpage>
          -
          <lpage>222</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          <string-name>
            <surname>Weber-Wulff</surname>
          </string-name>
          ,
          <year>Debora</year>
          .
          <year>2008</year>
          . Softwaretest, http://plagiat.htwberlin.de/software/2008/.
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          <string-name>
            <surname>Webis at</surname>
          </string-name>
          Bauhaus-Universita¨
          <article-title>t Weimar and</article-title>
          NLEL at Universidad Polit´ecnica de Valencia.
          <year>2009</year>
          .
          <article-title>PAN Plagiarism Corpus PAN-PC-09</article-title>
          . http://www.webis.de/research/corpora. Martin Potthast, Andreas Eiselt, Benno Stein, Alberto Barrn´ Ceden˜o, and Paolo Rosso (editors).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>