<p>                           (This is a Wiki! <strong>Please edit here</strong> with corrections or enhancings)</p>
<p><strong>For better results on not-so-big strings:</strong></p>
<p>There are problems with the direct uso of the NCD formula on strings or little texts. NCD(X,X) is not zero (!). To remove this artifact subtract the self comparison.</p>
<p>See similar_NCD_gzip() demo at <a href="http://leis.saocarlos.sp.gov.br/SIMILAR.php" rel="nofollow noreferrer">http://leis.saocarlos.sp.gov.br/SIMILAR.php</a></p>
<pre><code>function similar_NCD_gzip($sx, $sy, $prec=0, $MAXLEN=90000) {
# NCD with gzip artifact correctoin and percentual return.
# sx,sy = strings to compare. 
# Use $prec=-1 for result range [0-1], $pres=0 for percentual,
#     $pres=1 or =2,3... for better precision (not a reliable)  
# Use MAXLEN=-1 or a aprox. compress lenght. 
# For NCD definition see http://arxiv.org/abs/0809.2553
# (c) Krauss (2010).
  $x = $min = strlen(gzcompress($sx));
  $y = $max = strlen(gzcompress($sy));
  $xy= strlen(gzcompress($sx.$sy));
  $a = $sx;
  if ($x&gt;$y) { # swap min/max
    $min = $y;
    $max = $x;
    $a = $sy;
  }
  $res = ($xy-$min)/$max; # NCD definition.
  
  # Optional correction (for little strings):
  if ($MAXLEN&lt;0 || $xy&lt;$MAXLEN) {
    $aa= strlen(gzcompress($a.$a));
    $ref = ($aa-$min)/$min;
    $res = $res - $ref; # correction
  }
  return ($prec&lt;0)? $res: 100*round($res,2+$prec);
}
</code></pre>
How would you code an anti plagiarism site?
<p>First, please note, that I am interested in how something like this would work, and am not intending to build it for a client etc, as I'm sure there may already be open source implementations.</p>

<p>How do the algorithms work which detect plagiarism in uploaded text? Does it use regex to send all words to an index, strip out known words like 'the', 'a', etc and then see how many words are the same in different essays? Does it them have a magic number of identical words which flag it as a possible duplicate? Does it use <a href="http://us2.php.net/manual/en/function.levenshtein.php" rel="noreferrer">levenshtein()</a>? </p>

<p>My language of choice is PHP.</p>

<p><strong>UPDATE</strong></p>

<p>I'm thinking of not checking for plagiarism globally, but more say in 30 uploaded essays from a class. In case students have gotten together on a strictly one person assignment.</p>

<p>Here is an online site that claims to do so: <a href="http://www.plagiarism.org/" rel="noreferrer">http://www.plagiarism.org/</a></p>