Skip to content

Copyleaks/Java-Plagiarism-Checker

Repository files navigation

Copyleaks SDK

The official Copyleaks Java library, supporting Java versions:Java 11 or higher.

🚀 Getting Started

Before you start, ensure you have the following:

Once you have your account and API key:

Install the SDK:

Download the latest version from Maven Central Repository

📚 Documentation

To learn more about how to use Copyleaks API please check out our Documentation.

💡 Usage Examples

Here are some common usage examples for the Copyleaks SDK. You can also see a comprehensive code example in the example.java file on our GitHub repository: example.java.

Get Authentication Token

This example demonstrates how to log in to the Copyleaks API and obtain an authentication token.

import classes.Copyleaks;
import models.response.CopyleaksAuthToken;

public class ScanExample {
    // --- Your Credentials ---
    private static final String EMAIL_ADDRESS = "YOUR_EMAIL_ADDRESS";
    private static final String KEY = "YOUR_API_KEY";
    private static final String WEBHOOK_URL = "[https://your-server.com/webhook/](https://your-server.com/webhook/){STATUS}";
    // --------------------

    public static void main(String[] args) {
        CopyleaksAuthToken token;

        // Log in to the Copyleaks API
        System.out.println("Authenticating...");
        token = Copyleaks.login(EMAIL_ADDRESS, KEY);
        System.out.println("✅ Logged in successfully!");
    }
}

For a detailed understanding of the authentication process, refer to the Copyleaks Login Endpoint Documentation.

Submit Text for Plagiarism Scan

This example shows how to prepare and submit raw text content for a plagiarism scan.

import classes.Copyleaks;
import models.submissions.CopyleaksFileSubmissionModel;
import models.submissions.properties.SubmissionProperties;
import models.submissions.properties.SubmissionWebhooks;

public class ScanExample {
    // --- Your Credentials ---
    private static final String EMAIL_ADDRESS = "YOUR_EMAIL_ADDRESS";
    private static final String KEY = "YOUR_API_KEY";
    private static final String WEBHOOK_URL = "[https://your-server.com/webhook/](https://your-server.com/webhook/){STATUS}";
    // --------------------

    public static void main(String[] args) {
        String BASE64_FILE_CONTENT = Base64.getEncoder().encodeToString("Hello world".getBytes(StandardCharsets.UTF_8));
        String FILENAME = "hello.txt";
        String scanId = Integer.toString(getRandomNumberInRange(100, 100000));

        // Configure webhooks
        SubmissionWebhooks webhooks = new SubmissionWebhooks("https://your.server/webhook/{STATUS}");
        webhooks.setNewResult("https://your.server/webhook/new-results");

        // Create submission properties with enhanced configuration
        SubmissionProperties submissionProperties = new SubmissionProperties(webhooks);
        submissionProperties.setSandbox(true); // Turn on sandbox mode. Turn off on production.

        // Create the submission model
        CopyleaksFileSubmissionModel model = new CopyleaksFileSubmissionModel(BASE64_FILE_CONTENT, FILENAME, submissionProperties);
        Copyleaks.submitFile(token, scanId, model);
       
    }
}

For a full guide please refer to our step by step Guide

For a detailed understanding of the plagiarism detection process, refer to the Copyleaks Submit Endpoint Documentation

AI-Generated Text Detection

Use the AI detection client to determine if content was generated by artificial intelligence.

import classes.Copyleaks;
import models.submissions.aidetection.CopyleaksNaturalLanguageSubmissionModel;
import models.response.aidetection.AIDetectionResponse;

public class ScanExample {
    // --- Your Credentials ---
    private static final String EMAIL_ADDRESS = "YOUR_EMAIL_ADDRESS";
    private static final String KEY = "YOUR_API_KEY";
    // --------------------

    public static void main(String[] args) {
        // This example is going to scan text for natural language AI detection.
        String sampleText = "Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures.";
        
        CopyleaksNaturalLanguageSubmissionModel naturalLanguageSubmissionModel = new CopyleaksNaturalLanguageSubmissionModel(sampleText);
        naturalLanguageSubmissionModel.setSandbox(true);

        AIDetectionResponse naturalLanguageAiDetectionResponse = Copyleaks.aiDetectionClient.submitNaturalLanguage(token, scanId, naturalLanguageSubmissionModel);

        System.out.println("\nText scanned for AI detection.");
        System.out.println("AI Score: " + naturalLanguageAiDetectionResponse.getSummary().getAi());
    }
}

For a full guide please refer to our step by step Guide

For a detailed understanding of the Ai detection process, refer to the Copyleaks detect natural language Endpoint Documentation

Writing Assistant

Get intelligent suggestions for improving grammar, spelling, style, and overall writing quality.

import classes.Copyleaks;
import models.submissions.writingassistant.ScoreWeights;
import models.submissions.writingassistant.CopyleaksWritingAssistantSubmissionModel;
import models.response.writingassitant.WritingAssistantResponse;

public class ScanExample {
    // --- Your Credentials ---
    private static final String EMAIL_ADDRESS = "YOUR_EMAIL_ADDRESS";
    private static final String KEY = "YOUR_API_KEY";
    // --------------------

    public static void main(String[] args) {
        // This example is going to text for writing feedback.
        String writingFeedbackText = "Lions are the only cat that live in groups, called pride. A prides typically consists of a few adult males, several feales, and their offspring. This social structure is essential for hunting and raising young cubs. Female lions, or lionesses are the primary hunters of the prid. They work together in cordinated groups to take down prey usually targeting large herbiores like zbras, wildebeest and buffalo. Their teamwork and strategy during hunts highlight the intelligence and coperation that are key to their survival.";
        
        ScoreWeights scoreWeights = new ScoreWeights();
        scoreWeights.setGrammarScoreWeight(0.1);
        scoreWeights.setMechanicsScoreWeight(0.2);
        scoreWeights.setSentenceStructureScoreWeight(0.3);
        scoreWeights.setWordChoiceScoreWeight(0.4);
        
        CopyleaksWritingAssistantSubmissionModel writingAssistantSubmissionModel = new CopyleaksWritingAssistantSubmissionModel(writingFeedbackText);
        writingAssistantSubmissionModel.setScore(scoreWeights);
        writingAssistantSubmissionModel.setSandbox(true);


        WritingAssistantResponse writingAssistantResponse = Copyleaks.writingAssistantClient.submitText(token, scanId, writingAssistantSubmissionModel);

        System.out.println("\nText scanned for AI detection.");
        System.out.println("Grammer Score: " + writingAssistantResponse.getScore().getCorrections().getGrammarCorrectionsScore());
    }
}

For a full guide please refer to our step by step Guide

For a detailed understanding of the Writing assistant process, refer to the Copyleaks writing feedback Endpoint Documentation

Text Moderation

Scan and moderate text content for unsafe, inappropriate, or policy-violating material across various categories.

import classes.Copyleaks;
import models.request.TextModeration.CopyleaksTextModerationRequest;
import models.response.textModeration.CopyleaksTextModerationResponseModel;

public class ScanExample {
    // --- Your Credentials ---
    private static final String EMAIL_ADDRESS = "YOUR_EMAIL_ADDRESS";
    private static final String KEY = "YOUR_API_KEY";
    // --------------------

    public static void main(String[] args) {

        CopyleaksTextModerationLabel[] labelsArray = new CopyleaksTextModerationLabel[] {
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.ADULT_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.TOXIC_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.VIOLENT_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.PROFANITY_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.SELF_HARM_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HARASSMENT_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HATE_SPEECH_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.DRUGS_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.FIREARMS_V1),
                            new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.CYBERSECURITY_V1)
                        };

        CopyleaksTextModerationRequest request = new CopyleaksTextModerationRequest(
                /* text */ "This is some text to moderate.",
                /* sandbox */ true,
                /* language */ CopyleaksTextModerationLanguages.ENGLISH,
                /* labels */ labelsArray
        );
        CopyleaksTextModerationResponseModel    textModerationResponse = Copyleaks.textModerationClient.submitText(token, scanId, request);

        System.out.println("\nText scanned for Text Moderation.");
        System.out.println("Text Moderation Response: " + gson.toJson(textModerationResponse));
    }
}

For a full guide please refer to our step by step Guide

For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint Documentation

Further Resources

  • Copyleaks API Dashboard: Manage your API keys, monitor usage, and view analytics from your personalized dashboard. Access Dashboard
  • Copyleaks SDK Documentation: Explore comprehensive guides, API references, and code examples for seamless integration. Read Documentation

Support

  • If you need assistance, please contact Copyleaks Support via our support portal: Contact Copyleaks Support.
  • To arrange a product demonstration, book a demo here: Booking Link.

About

Java SDK to Copyleaks Plagiarism Checker API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 7

Languages