fork(1) download
  1. <?php
  2. //palavras chaves:
  3. //Similarity Detection e Plagiarism Detector
  4.  
  5. //referencia:
  6. //http://stackoverflow.com/questions/1085048/how-would-you-code-an-anti-plagiarism-site
  7.  
  8. function ncd($x, $y) {
  9. $cx = strlen(gzcompress($x));
  10. $cy = strlen(gzcompress($y));
  11. return (strlen(gzcompress($x . $y)) - min($cx, $cy)) / max($cx, $cy);
  12. }
  13.  
  14. print "<br><br>0- ";
  15. print(ncd('this', 'this'));
  16. print "<br><br>1- ";
  17. print(ncd('this is a test', 'this is a test'));
  18. print "<br><br>2- ";
  19. print(ncd('this is a test', 'this was a test'));
  20. print "<br><br>3- ";
  21. print(ncd('this is a test', 'this text is completely different'));
  22. print "<br><br>4- ";
  23. print(ncd('this is a test', 'nao tem nada haver!!!'));
  24.  
  25. print "<br><br>5- ";
  26. print(ncd('this is a test', 'nao tem nada haver!!! nao tem nada haver!!! nao tem nada haver!!! nao
  27.  
  28. tem nada haver!!!nada haver!!! nao tem nada haver!!!nada haver!!! nao tem nada haver!!!'));
  29.  
  30. print "<br>--------------------<br>6- ";
  31. print(ncd('this is a test', 'nao tem nada haver!!! nao tem nada haver!!! nao tem nada haver!!! nao
  32.  
  33. tem nada haver!!! this is a test'));
  34.  
  35.  
  36. print "<br>--------------------<br>7- ";
  37. print(ncd('this is a test', 'this is a test this is a test this is a test this is a test'));
  38.  
  39. print "<br>--------------------<br>8- ";
  40. print(ncd('this is a test', 'a a a a'));
  41.  
  42.  
  43.  
  44. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
<br><br>0- 0.166666666667<br><br>1- 0.15<br><br>2- 0.304347826087<br><br>3- 0.74358974359<br><br>4- 0.689655172414<br><br>5- 0.780487804878<br>--------------------<br>6- 0.625<br>--------------------<br>7- 0.333333333333<br>--------------------<br>8- 0.6