The Sherlock Plagiarism Detector

What is Sherlock?

Sherlock is a program which finds similarities between textual documents. It uses digital signatures to find similar pieces of text. A digital signature is a number which is formed by turning several words in the input into a series of bits and joining those bits into a number.

Sherlock works on text files such as essays, computer source code files, and other assignments in digital form. It will even work with Tar files, but not compressed archives such as Gzipped or Zipped files (you'll have to unzip those files first).

How do I download it?

There are some files you can download here: Click on those files and choose "Save As..." from the File menu, or right-click in your browser and choose "Save Link As..." from there.

How do I compile it?

If using Unix or Linux, just type "make". If using Windows, consult your compiler's documentation. You simply need to compile the sherlock.c source code file into an executable called sherlock (sherlock.exe for Windows users).

How do I use it?

Sherlock is a command-line program. That is, you run it from an xterm or DOS window. It isn't graphical, and has no graphical user interface. Sorry. Use it like this:
   sherlock *.txt
That will compare all the text files in the current directory and produce a listing of the most similar files, together with a percentage similarity index.

To compare source files, you might use it like this:

   sherlock *.java
Actually, it's a good idea to redirect the output into a file, so you can examine it in detail. Otherwise it'll just flash past very quickly. To redirect the output into a file, you use the > symbol:
   sherlock *.java > results.txt
This creates a file called "results.txt" which contains the results.

What options does the program support?

There are several command-line options to Sherlock: Examples:
   sherlock -t 80% -z 3 -n 2 -o results.txt *.java
   sherlock -t 50% -o results.txt *.txt
   sherlock -t 0% *.java   # reports all similarity indexes

What does the output look like?

Sherlock performs an N2 comparison between all the files, so every file is compared with every other file.

The output lists the similarity indexes between each pair of files. This index is a percentage, where 0% means no similarity and 100% means there is a very high chance of a lot of similarity. 100% does not mean that the files are exactly the same, since the Sherlock program randomly throws away some data in order to perform a faster match.

The output of the program might look like this:

   README and index.html: 5%
   README and makefile: 1%
   README and sherlock: 0%
   README and sherlock.c: 2%
   index.html and makefile: 8%
   index.html and sherlock: 0%
   index.html and sherlock.c: 10%
   makefile and sherlock: 0%
   makefile and sherlock.c: 6%
   sherlock and sherlock.c: 0%
(The threshold is normally 20%, so the above output would not ordinarily be shown. The example used a threshold lowered to 0% in order to see all similarities. The numbers are fake, however, and just for illustrational purposes.)

In the example, the most similar files are index.html and sherlock.c with a rating of 10%. This means that approximately 10% of the material in those two files might be overlapping (i.e. appear in both files).


Rob Pike created the original version of this program. There were actually two programs, called sig and comp. The sig program generated the digital signatures and stored them in a file. The comp program would then be used to compare the signature files and report the similarities.

Loki combined the two programs into a single program, called Sherlock. This has some advantages and disadvantages.

The main advantage is that no intermediate files need be created. Intermediate files require disk space and a management strategy. For example, you need to decide what suffix the signature files will use (e.g. ".sig") and where they will be stored (with the data, in a parallel directory structure, or other place).

Sherlock avoids these issues but requires all files to be compared every time to want a comparison. For example, if you are looking for similarities in essays handed in by students, Sherlock may work well because you should have all the essays handed in before you begin the plagiarism detection.

On the other hand, Sherlock is not see well suited to detecting duplicate email messages, since email arrives continually, and you can never have a finished set of email to work on. Intermediate ".sig" files might reduce the time needed to compare a new email item to older items, since the signatures for old items will already be computed and stored. Sherlock would have to read and compute the signatures for all of those older files, every time you need a comparison, because it does not use ".sig" files.

Can I download sig and comp?

Yes, download them by saving the following files: