Docsity

Similaridad de patrones, Apuntes de Cálculo

Toggle sidebar
bg1
Similarity Patterns in Language
Jonathan
Isaac
Helfman
AT&T
Bell Laboratories
Murray Hill, NJ
07974-0636
ABSTRACT
Dotplot is a technique for visualizing patterns
of
string
matches in millions of lines
of
text and code. Patterns may
be explored interactively or detected automatically. Appli-
cations include text analysis (author identification, plagiar-
ism detection, translation alignment, etc.), sofhvare
engineering (module and version identifcation, subroutine
categorization, redundant code identification, etc.), and
information retrieval (identification of similar records in
results
of
queries). Patterns are interpreted though a visual
language. Squares identify unordered matches (documents
with lots of matching word or subroutines with lots of
matching symbols), while diagonals ia’entifi ordered
matches (copies, versions, and translations). Patterns of
squares and diagonals have more complex interpretations
that identify subtler relationships.
1.
Introduction
to
be
or
not
to
be
Fig.
1
a) Six words, b) A million words of Shakespeare
The dotplot technique is illustrated in Fig. 1 a. A sequence is
tokenized and plotted from left to right and top to bottom
with a dot where the tokens match. Dots off the main diago-
nal indicate similarities. While Fig. la shows six words of
Shakespeare, Fig. lb shows “The Complete Works”
[6].
Grid lines show the boundaries between the concatenated
files. Dark areas show a high density of matches. Unlike
Fig. la, weighting and reconstruction methods are used
to
display matches from more than one pair of tokens in a sin-
gle pixel. Weighting prevents matches between frequent
tokens from saturating the plot. Additional details of the
dotplot technique and associated browser are described else-
where
[2].
Small dark squares along the main diagonal in Fig. lb are
caused by names of characters, which generally match
within a single work, but not across different works. The
exceptions are the European Histones, which share vocabu-
lary and form a large dark cluster near the upper left.
Squares
are
also formed by the character sequence of Fig. 3a
in which the a’s match each other, but not the b’s, and vice
versa. In general, one square indicates a high density of
unordered matches, usually due to common vocabulary,
while
two
squares indicate a change in vocabulary.
Fig.
2
a) Two versions of
xmh
(2oooO
lines of C code)
b) Repeated macros
(5000
lines of manual pages)
Fig. 2a plots two versions of the
xmh
program. The
software examples in this paper use C code from the
XllR5
and
XllR6
Window System
[5].
Software is tokenized into
lines
so
that a dot appears where two entire lines of code
match. In Fig. 2a, diagonals are formed in the grid boxes
that compare the different versions of each file. Diagonals
are
modeled by the character sequence of Fig. 3b.
In
gen-
eral, diagonals indicate ordered matches such as copies or
versions.
aaaaaaaaabbbbbbbbb
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
.........
abcdefghiabcdefghi
. .
. .
. .
. .
.
.
.
.
.
a
.
.
.
.
. .
. .
. .
. .
. .
. .
.
.
.
.
.
.
0-8186-6660-9/94 $04.00
0
1994
IEEE
Fig.
3
a) Squares, b) Diagonals
173
pf3

Vista previa parcial del texto

¡Descarga Similaridad de patrones y más Apuntes en PDF de Cálculo solo en Docsity!

Similarity Patterns in Language

Jonathan Isaac Helfman

AT&T Bell Laboratories

Murray Hill, NJ 07974-

[email protected]

ABSTRACT

Dotplot is a technique for visualizing patterns of string

matches in millions of lines of text and code. Patterns may

be explored interactively or detected automatically. Appli- cations include text analysis (author identification,plagiar- ism detection, translation alignment, etc.), sofhvare engineering (module and version identifcation, subroutine categorization, redundant code identification, etc.), and information retrieval (identification of similar records in results of queries). Patterns are interpreted though a visual language. Squares identify unordered matches (documents with lots of matching w o r d or subroutines with lots of matching symbols), while diagonals ia’entifi ordered matches (copies, versions, and translations). Patterns of squares and diagonals have more complex interpretations that identify subtler relationships.

1. Introduction

to be or

not

to be

Fig. 1 a) Six words, b) A million words of Shakespeare The dotplot technique is illustrated in Fig. 1a. A sequence is tokenized and plotted from left to right and top to bottom with a dot where the tokens match. Dots off the main diago- nal indicate similarities. While Fig. l a shows six words of Shakespeare, Fig. l b shows “The Complete Works” [6]. Grid lines show the boundaries between the concatenated files. Dark areas show a high density of matches. Unlike Fig. la, weighting and reconstruction methods are used to display matches from more than one pair of tokens in a sin- gle pixel. Weighting prevents matches between frequent tokens from saturating the plot. Additional details of the dotplot technique and associated browser are described else- where [2].

Small dark squares along the main diagonal in Fig. l b are caused by names of characters, which generally match within a single work, but not across different works. The exceptions are the European Histones, which share vocabu- lary and form a large dark cluster near the upper left. Squares are also formed by the character sequence of Fig. 3a in which the a’s match each other, but not the b’s, and vice versa. In general, one square indicates a high density of unordered matches, usually due to common vocabulary, while two squares indicate a change in vocabulary.

Fig. 2 a) Two versions of xmh (2oooO lines of C code)

b) Repeated macros (5000 lines of manual pages)

Fig. 2a plots two versions of the xmh program. The software examples in this paper use C code from the XllR and XllR6 Window System [ 5 ]. Software is tokenized into

lines so that a dot appears where two entire lines of code

match. In Fig. 2a, diagonals are formed in the grid boxes that compare the different versions of each file. Diagonals

are modeled by the character sequence of Fig. 3b. In gen-

eral, diagonals indicate ordered matches such as copies or versions. aaaaaaaaabbbbbbbbb .................. .................. .................. .................. .................. .................. .................. .................. ..................

abcdefghiabcdefghi .. .. .. .. .. ..

.. a. . ..^. .. .. .. .. .. .. .. ..

0-8186-6660-9/94 $04.00 0 1994 IEEE

Fig. 3 a) Squares, b) Diagonals

173

While concatenating two copies creates diagonals, con- catenating multiple copies creates a diagonal texture. Fig.

2b shows a diagonal texture formed by repeated macros in

X11 manual pages. In the following section, additional pat-

terns of squares and diagonals are enumerated and described

in terms of a generalized concatenation operation: shuffling. Similar work is briefly described.

2. Patterns

Fig. 4a shows the manual pages of Fig. 2b along with the C code for two versions of x11 (the dark grid lines show the boundary between the versions). The manual pages appear

as a small dark square centered inside a light cross. This

feature is modeled by the character sequence of Fig. 4b in which a subsequence of b’s is inserted into a larger sequence of a’s. Insertions are also identified by broken diagonals. Fig. 5a shows two versions of the X Toolkit code. The second version is larger than the first. New code is indicated by breaks in the diagonals. Fig. 5b models broken diagonals by inserting extra tokens into an otherwise copied sequence. In general, light crosses indicate insertions into unordered sequences, while broken diagonals indicate insertions into ordered sequences.

Fig. 4 a) Two versions of X

aaaaaaaabbaaaaaaaa ................................ ................................ ................................ ................................ .a m m ................................ ................................ ................................ ................................

19oooOO lines of C Codc

b) Light Cross

abcdefghabcZydefgh I. (^). ..

. a (^). .... .. a ..

a (^).

Fig. 5 a) Two versions of xt (66600 lines of C b) Broken Diagonals

.. a ..

... a (^).

Code)

The two versions of x11 code in Fig. 4a do not plot as diag-

onals due to reordering in XllR6. A portion of the upper

right grid box of Fig. 4a is shown magnified in Fig. 6a. Fig.

6b shows the same sequence that plots diagonals in Fig. 3b, but in a different order. Reordering of versions is typically caused by changes to file pathnames. Reordering is also indicated by square textures. Fig. 7a shows alternating ini-

tializations in the file ram .b i f. Fig. 7b models square tex-

tures with the same sequence that plots squares in Fig. 3a, but in a different order.

In some cases it is useful to automatically reorder sequences. The concatenation order of the files in Fig. l b was determined by a combinatorial optimization algorithm that emphasizes clusters of similar documents. This is use- ful in information retrieval systems for visualizing docu- ment clusters in the results of a query. Image processing algorithms that identify the clearest diagonal on a smp of dotplots are useful for identifying file pairs in reordered ver- sions.

abcdefgh i cdgh i e f a b

. a (^). a .. .. (^0). .. 0 0 .. .^ a^.. . (^) 0.. e (^) *** aa** . a .. .. ..

Fig. 6 a) Reordered versions of dix (8000 lines of C Code) b) Reordered Copies

Fig. 7 a) Reordered Initializations (2500 lines of C Code) b) Reordered Squares Shuffling is a generalization of insertion and reordering. Fig. 8a shows a seemingly contradictory pattem. Dark squares on the main diagonal indicate that each file has unique vocabulary, while the diagonal texture indicates that each file is a copy. Fig. 8b models the combination of squares and diagonals by shuffling together a sequence that forms squares with one that forms diagonals. Fig. 8a is a chapter of a manual in Dutch, French, German, Italian, Spanish, and Swedish. The input is tokenized into 4-grams.

174