Skip to content

This is the official Ruby SDK for the Copyleaks API, a leading platform for ensuring content integrity. This library provides a seamless way to integrate Copyleaks' powerful services directly into your Ruby applications.

License

Notifications You must be signed in to change notification settings

Copyleaks/Ruby-Plagiarism-Checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

130 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copyleaks SDK

The official Copyleaks Ruby library.

🚀 Getting Started

Before you start, ensure you have the following:

Once you have your account and API key:

Install the SDK:

Install using RubyGems

gem install plagiarism-checker

📚 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 demo.rb file on our GitHub repository: demo.rb.

Get Authentication Token

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

require 'copyleaks'
require 'base64'

# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
# --------------------

begin
  # Log in to the Copyleaks API
  puts "Authenticating..."
  copyleaks = Copyleaks::API.new
  auth_token = copyleaks.login(USER_EMAIL, USER_API_KEY)
  puts "âś… Logged in successfully!"

end

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.

require 'copyleaks'
require 'base64'

# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com'
# --------------------

begin
    scanId = DateTime.now.strftime('%Q').to_s
    submisson = Copyleaks::CopyleaksFileSubmissionModel.new(
      'aGVsbG8gd29ybGQ=',
      'ruby.txt',
      Copyleaks::SubmissionProperties.new(
        Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
        true,
        'developer_payloads_test',
        true,
        60,
        1,
        true,
        Copyleaks::SubmissionActions::SCAN,
        Copyleaks::SubmissionAuthor.new('Author_name'),
        Copyleaks::SubmissionFilter.new(true, true, true),
        Copyleaks::SubmissionScanning.new(true, nil, nil, Copyleaks::SubmissionScanningCopyleaksDB.new(true, true)),
        Copyleaks::SubmissionIndexing.new([Copyleaks::SubmissionRepository.new('repo-1')]),
        Copyleaks::SubmissionExclude.new(true, true, true, true, true),
        Copyleaks::SubmissionPDF.new(true, 'pdf-title', BASE64_LOGO, false),
        Copyleaks::SubmissionSensitiveData.new(false)
      )
    )

    @copyleaks.submit_file(_authToken, scanId, submisson)

end

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.

require 'copyleaks'
require 'base64'

# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
# --------------------

begin
    scanId = DateTime.now.strftime('%Q').to_s
    text = "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."
    submission = Copyleaks::NaturalLanguageSubmissionModel.new(
      text,
    )
    submission.sandbox = true
    
    res = @copyleaks.ai_detection_client.submit_natural_language(_authToken, scanId, submission)

end

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.

require 'copyleaks'
require 'base64'

# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
# --------------------

begin
 text = "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."
    scanId = DateTime.now.strftime('%Q').to_s
    score_weights = Copyleaks::ScoreWeights.new(0.1, 0.2, 0.3, 0.4)
    submission = Copyleaks::WritingAssistantSubmissionModel.new(
      text,
    )
    submission.sandbox = true
    submission.score = score_weights
    res = @copyleaks.writing_assistant_client.submit_text(_authToken, scanId, submission)

end

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.

require 'copyleaks'
require 'base64'

# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
# --------------------

begin
    scanId = DateTime.now.strftime('%Q').to_s
    labelsArray=[
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::ADULT_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::TOXIC_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::VIOLENT_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::PROFANITY_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::SELF_HARM_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HARASSMENT_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HATE_SPEECH_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::DRUGS_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::FIREARMS_V1),
      Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::CYBERSECURITY_V1)
    ]
    
    text_moderation_request = Copyleaks::CopyleaksTextModerationRequestModel.new(
      text: "This is some text to scan.",
      sandbox: true,
      language: Copyleaks::CopyleaksTextModerationLanguages::ENGLISH,
      labels: labelsArray
    )
    res = @copyleaks.text_moderation_client.submit_text(_authToken, scanId, text_moderation_request)

    textModerationResponse = Copyleaks::CopyleaksTextModerationResponseModel.new(  
      moderations: res['moderations'],
      legend: res['legend'],
      scanned_document: res['scannedDocument'])

end

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

AI Image Detection

Determine if a given image was generated or partially generated by an AI.

    require 'copyleaks'
    require 'base64'
    # --- Your Credentials ---
    USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
    USER_API_KEY = 'YOUR_API_KEY'
    # --------------------
  begin
      puts "Submitting a new image for AI image detection..."
      
      scanId = DateTime.now.strftime('%Q').to_s
      
      # Read and encode your image file to base64
      image_path = "Path/to/your/image.jpg" # Update this path to your image
      base64_image = Base64.strict_encode64(File.read(image_path))
      
      model = Copyleaks::CopyleaksAiImageDetectionRequestModel.new(
        base64_image,
        "image.jpg",
        Copyleaks::CopyleaksAiImageDetectionModels::AI_IMAGE_1_ULTRA, 
        true # sandbox mode
      )
      
      res = copyleaks.ai_image_detection_client.submit_(authToken, scanId, model)
    rescue StandardError => e
      puts "Error in test_image_detection: #{e.message}"
    end
  end

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

For a detailed understanding of the AI image detection process, refer to the Copyleaks AI image detection 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

This is the official Ruby SDK for the Copyleaks API, a leading platform for ensuring content integrity. This library provides a seamless way to integrate Copyleaks' powerful services directly into your Ruby applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12