Plagiarism checker made with PHP that uses DuckDuckGo

Jorge Maldonado Ventura c1aba798d0 Use GPLv3 instead of Lesser GPLv3 7 years ago
LICENSE c1aba798d0 Use GPLv3 instead of Lesser GPLv3 7 years ago
README.md 5bcb1e70b9 Add README, needs some improvement 7 years ago
plagiarismChecker.php c1aba798d0 Use GPLv3 instead of Lesser GPLv3 7 years ago

README.md

Description

This library lets you check for plagiarism using DuckDuckGo. It lets you obtain easily the number of matches a query returns. To use it, just:

require_once 'plagiarismChecker.php';

$text = 'Saturn is the sixth planet from the Sun and the second-largest in the Solar System';
$result = checkPlagiarism($text);

The result variable will contain a list that contains an associative array for every DuckDuckGo result which contains:

  • $results['matches']: number of word matches
  • $results['abstract']: the abstract of the result
  • $results['url']: the URL of the result

With that information you can create a complicated plagiarism detector. Here you find a simple example of what you can do. I just consider some text plagiarism when DuckDuckGo highlight more than 7 words, it's not a very good method, feel free to write a better plagiarism detector:

if ($result === false) {
    echo 'An error has occurred';
} else if($result === 0) {
    echo 'No results.';
} else {
    echo '<h2>Results</h2>';
    echo '<p><em>Your text has been compared with ' . sizeof($result) . ' results.</em></p>';
    echo '<ul>';
    foreach ($result as $val) {
        if ($val['matches'] > 7) {
            echo '<li><strong>'.  $val['matches'] . ' matched words</strong>: ' . $val['abstract'] . ' | URL: ' . $val['url'] . ' <strong> Plagiarism detected</strong></li>';
        } else {
            echo '<li><strong>'.  $val['matches'] . ' matched words</strong>: ' . $val['abstract'] . ' | URL: ' . $val['url'] . ' <strong> No plagiarism detected</strong></li>';
        }
    }
    echo '<ul>';
}

Requirements

PHP with cURL library installed.