plagiarism-checker 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 692f431026f826b2ca580843b76fb78e526a4b33bf130e5baa2733445f52e371
4
- data.tar.gz: d12e8ad811a38051846ed99ab4e2bd04735bc3a06489ac918bc7a16adfce8dc9
3
+ metadata.gz: 39393e80d6d74245563438a02c382e7de87c22acbc425ffd3d4e92a6b96d669f
4
+ data.tar.gz: 170a23529cde53bcc693de8f847200855b03964001c0d33f72af74fe804b6138
5
5
  SHA512:
6
- metadata.gz: 51886d89ac8c1cf8976fcb3fdc25cdbfe6aff4b85752e5d2783a14b8d8b08b71f1c7c2861222bbd3374d7b3bbe114274df9bcccb252d2f2176ebc923768306a6
7
- data.tar.gz: 035e2164be6ed073d7f17eb3e75aa8d6954ffa7028d668a3935ff0fc5540561e6e95df037799eb9554f5b4ee15bddbfd2610bf2294c7fc6d3803d8dc3394c2bd
6
+ metadata.gz: 4efd08769fac76f7f0846835cf977efd8190a91883f76df6e3576909328071cb9fcfcc6f382af6dd7a66dbba5139469045612b0ec2b829348ceea19786d5c316
7
+ data.tar.gz: a6640272ad89bc07d0f99c17562d549dcfc116cac4ddbca10846f066cc94cc702c058197ee99722a1e9136a679ba9207f70095d965b96fe3ff6849751f5e5aca
data/.gitignore CHANGED
@@ -6,3 +6,12 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ # Generated gem files
11
+ *.gem
12
+ plagiarism-checker-3.2.1.gem
13
+ plagiarism-checker-3.5.0.gem
14
+ plagiarism-checker-3.6.0.gem
15
+ plagiarism-checker-3.6.1.gem
16
+ plagiarism-checker-3.7.0.gem
17
+ plagiarism-checker-4.0.0.gem
data/README.md CHANGED
@@ -32,7 +32,6 @@ require 'base64'
32
32
  # --- Your Credentials ---
33
33
  USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
34
34
  USER_API_KEY = 'YOUR_API_KEY'
35
- WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
36
35
  # --------------------
37
36
 
38
37
  begin
@@ -56,7 +55,7 @@ require 'base64'
56
55
  # --- Your Credentials ---
57
56
  USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
58
57
  USER_API_KEY = 'YOUR_API_KEY'
59
- WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
58
+ WEBHOOK_URL = 'https://your-server.com'
60
59
  # --------------------
61
60
 
62
61
  begin
@@ -65,7 +64,7 @@ begin
65
64
  'aGVsbG8gd29ybGQ=',
66
65
  'ruby.txt',
67
66
  Copyleaks::SubmissionProperties.new(
68
- Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/url-webhook/scan/#{scanId}/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
67
+ Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
69
68
  true,
70
69
  'developer_payloads_test',
71
70
  true,
@@ -101,7 +100,6 @@ require 'base64'
101
100
  # --- Your Credentials ---
102
101
  USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
103
102
  USER_API_KEY = 'YOUR_API_KEY'
104
- WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
105
103
  # --------------------
106
104
 
107
105
  begin
@@ -130,7 +128,6 @@ require 'base64'
130
128
  # --- Your Credentials ---
131
129
  USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
132
130
  USER_API_KEY = 'YOUR_API_KEY'
133
- WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
134
131
  # --------------------
135
132
 
136
133
  begin
@@ -160,27 +157,28 @@ require 'base64'
160
157
  # --- Your Credentials ---
161
158
  USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
162
159
  USER_API_KEY = 'YOUR_API_KEY'
163
- WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
164
160
  # --------------------
165
161
 
166
162
  begin
167
- scanId = DateTime.now.strftime('%Q').to_s
163
+ scanId = DateTime.now.strftime('%Q').to_s
164
+ labelsArray=[
165
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::ADULT_V1),
166
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::TOXIC_V1),
167
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::VIOLENT_V1),
168
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::PROFANITY_V1),
169
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::SELF_HARM_V1),
170
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HARASSMENT_V1),
171
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HATE_SPEECH_V1),
172
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::DRUGS_V1),
173
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::FIREARMS_V1),
174
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::CYBERSECURITY_V1)
175
+ ]
176
+
168
177
  text_moderation_request = Copyleaks::CopyleaksTextModerationRequestModel.new(
169
178
  text: "This is some text to scan.",
170
179
  sandbox: true,
171
- language: "en",
172
- labels: [
173
- { id: "adult-v1" },
174
- { id: "toxic-v1" },
175
- { id: "violent-v1" },
176
- { id: "profanity-v1" },
177
- { id: "self-harm-v1" },
178
- { id: "harassment-v1" },
179
- { id: "hate-speech-v1" },
180
- { id: "drugs-v1" },
181
- { id: "firearms-v1" },
182
- { id: "cybersecurity-v1" }
183
- ]
180
+ language: Copyleaks::CopyleaksTextModerationLanguages::ENGLISH,
181
+ labels: labelsArray
184
182
  )
185
183
  res = @copyleaks.text_moderation_client.submit_text(_authToken, scanId, text_moderation_request)
186
184
 
@@ -195,7 +193,44 @@ For a full guide please refer to our step by step [Guide](https://docs.copyleaks
195
193
 
196
194
  For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/text-moderation/check/)
197
195
  ##
198
- ## Further Resources
196
+ ### AI Image Detection
197
+ Determine if a given image was generated or partially generated by an AI.
198
+
199
+ ```ruby
200
+ require 'copyleaks'
201
+ require 'base64'
202
+ # --- Your Credentials ---
203
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
204
+ USER_API_KEY = 'YOUR_API_KEY'
205
+ # --------------------
206
+ begin
207
+ puts "Submitting a new image for AI image detection..."
208
+
209
+ scanId = DateTime.now.strftime('%Q').to_s
210
+
211
+ # Read and encode your image file to base64
212
+ image_path = "Path/to/your/image.jpg" # Update this path to your image
213
+ base64_image = Base64.strict_encode64(File.read(image_path))
214
+
215
+ model = Copyleaks::CopyleaksAiImageDetectionRequestModel.new(
216
+ base64_image,
217
+ "image.jpg",
218
+ Copyleaks::CopyleaksAiImageDetectionModels::AI_IMAGE_1_ULTRA,
219
+ true # sandbox mode
220
+ )
221
+
222
+ res = copyleaks.ai_image_detection_client.submit_(authToken, scanId, model)
223
+ rescue StandardError => e
224
+ puts "Error in test_image_detection: #{e.message}"
225
+ end
226
+ end
227
+ ```
228
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/ai-detector/ai-image-detection/)
229
+
230
+ For a detailed understanding of the AI image detection process, refer to the Copyleaks AI image detection Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/ai-image-detector/check/)
231
+
232
+ ##
233
+ ### Further Resources
199
234
 
200
235
  * **Copyleaks API Dashboard:** Manage your API keys, monitor usage, and view analytics from your personalized dashboard. [Access Dashboard](https://api.copyleaks.com/dashboard)
201
236
  * **Copyleaks SDK Documentation:** Explore comprehensive guides, API references, and code examples for seamless integration. [Read Documentation](https://docs.copyleaks.com/resources/sdks/overview/)
@@ -0,0 +1,54 @@
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+
25
+ module Copyleaks
26
+ class AIImageDetectionClient
27
+ def initialize(api_client)
28
+ @api_client = api_client
29
+ end
30
+
31
+ def submit_(authToken, scanId, submission)
32
+ raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
33
+ if submission.nil? || !submission.instance_of?(Copyleaks::CopyleaksAiImageDetectionRequestModel)
34
+ raise 'submission is Invalid, must be instance of type Copyleaks::CopyleaksAiImageDetectionRequestModel'
35
+ end
36
+
37
+ ClientUtils.verify_auth_token(authToken)
38
+
39
+ path = "/v1/ai-image-detector/#{scanId}/check"
40
+
41
+ headers = {
42
+ 'Content-Type' => 'application/json',
43
+ 'User-Agent' => Config.user_agent,
44
+ 'Authorization' => "Bearer #{authToken.accessToken}"
45
+ }
46
+
47
+ request = Net::HTTP::Post.new(path, headers)
48
+ request.body = submission.to_json
49
+
50
+ res = ClientUtils.handle_response(@api_client.request(request), 'submit_image_detection')
51
+ res
52
+ end
53
+ end
54
+ end
data/lib/copyleaks/api.rb CHANGED
@@ -27,6 +27,7 @@ require 'date'
27
27
  require_relative 'ai_detection_client.rb'
28
28
  require_relative 'writing_assistant_client.rb'
29
29
  require_relative 'text_moderation_client.rb'
30
+ require_relative 'ai_image_detection_client.rb'
30
31
  require_relative 'utils/copyleaks_client.utils'
31
32
 
32
33
  module Copyleaks
@@ -45,6 +46,7 @@ module Copyleaks
45
46
  @ai_detection_client = AIDetectionClient.new(@api_client)
46
47
  @writing_assistant_client = WritingAssistantClient.new(@api_client)
47
48
  @text_moderation_client = TextModerationClient.new(@api_client)
49
+ @ai_image_detection_client = AIImageDetectionClient.new(@api_client)
48
50
  end
49
51
 
50
52
  # Login to Copyleaks authentication server.
@@ -461,5 +463,9 @@ module Copyleaks
461
463
  def text_moderation_client
462
464
  @text_moderation_client
463
465
  end
466
+
467
+ def ai_image_detection_client
468
+ @ai_image_detection_client
469
+ end
464
470
  end
465
471
  end
@@ -0,0 +1,28 @@
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+ module Copyleaks
25
+ class CopyleaksAiImageDetectionModels
26
+ AI_IMAGE_1_ULTRA = "ai-image-1-ultra"
27
+ end
28
+ end
@@ -24,6 +24,8 @@
24
24
 
25
25
  require_relative 'CopyleaksTextModerationConstants.rb'
26
26
  require_relative 'CopyleaksTextModerationLanguages.rb'
27
+ require_relative 'CopyleaksAiImageDetectionModels.rb'
28
+
27
29
 
28
30
  module Copyleaks
29
31
  end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Copyleaks
4
+
5
+ # Request model for Copyleaks AI image detection.
6
+ # The request body is a JSON object containing the image to analyze.
7
+ class CopyleaksAiImageDetectionRequestModel
8
+ attr_accessor :base64, :file_name, :model, :sandbox
9
+
10
+ # Initialize a new CopyleaksAiImageDetectionRequestModel
11
+ #
12
+ # @param base64 [String] The base64-encoded image data to be analyzed for AI generation
13
+ # @param file_name [String] The name of the image file including its extension
14
+ # @param model [String] The AI detection model to use for analysis
15
+ # @param sandbox [Boolean] Use sandbox mode to test integration (default: false)
16
+ def initialize(base64, file_name, model, sandbox = false)
17
+ @base64 = base64
18
+ @file_name = file_name
19
+ @model = model
20
+ @sandbox = sandbox
21
+ end
22
+
23
+ # The base64-encoded image data to be analyzed for AI generation.
24
+ #
25
+ # Requirements:
26
+ # - Minimum 512×512px, maximum 16 megapixels, less than 32MB
27
+ # - Supported formats: PNG, JPEG, BMP, WebP, HEIC/HEIF
28
+ #
29
+ # @example "aGVsbG8gd29ybGQ="
30
+ # @return [String] Base64-encoded image data
31
+ attr_reader :base64
32
+
33
+ # The name of the image file including its extension.
34
+ #
35
+ # Requirements:
36
+ # - Supported extensions: .png, .bmp, .jpg, .jpeg, .webp, .heic, .heif
37
+ # - Maximum 255 characters
38
+ #
39
+ # @example "my-image.png"
40
+ # @return [String] Image file name
41
+ attr_reader :file_name
42
+
43
+ # The AI detection model to use for analysis.
44
+ # You can use either the full model name or its alias.
45
+ #
46
+ # Available models:
47
+ # - AI Image 1 Ultra: "ai-image-1-ultra-01-09-2025" (full name) or "ai-image-1-ultra" (alias)
48
+ # AI image detection model. Produces an overlay of the detected AI segments.
49
+ #
50
+ # @example "ai-image-1-ultra-01-09-2025" or "ai-image-1-ultra"
51
+ # @return [String] Model name or alias
52
+ attr_reader :model
53
+
54
+ # Use sandbox mode to test your integration with the Copyleaks API without consuming any credits.
55
+ #
56
+ # Submit images for AI detection and get returned mock results, simulating Copyleaks' API functionality
57
+ # to ensure you have successfully integrated the API.
58
+ # This feature is intended to be used for development purposes only.
59
+ # Default value is false.
60
+ #
61
+ # @example false
62
+ # @return [Boolean] Sandbox mode flag
63
+ attr_reader :sandbox
64
+
65
+ # Convert the model to a hash for JSON serialization
66
+ #
67
+ # @return [Hash] Hash representation of the model
68
+ def to_hash
69
+ {
70
+ base64: @base64,
71
+ fileName: @file_name,
72
+ model: @model,
73
+ sandbox: @sandbox
74
+ }
75
+ end
76
+
77
+ # Convert the model to JSON
78
+ #
79
+ # @return [String] JSON representation of the model
80
+ def to_json(*args)
81
+ to_hash.to_json(*args)
82
+ end
83
+
84
+ # Validate the model data
85
+ #
86
+ # @raise [ArgumentError] If required fields are missing or invalid
87
+ def validate!
88
+ raise ArgumentError, 'base64 is required' if @base64.nil? || @base64.empty?
89
+ raise ArgumentError, 'file_name is required' if @file_name.nil? || @file_name.empty?
90
+ raise ArgumentError, 'model is required' if @model.nil? || @model.empty?
91
+
92
+ validate_file_name!
93
+ validate_file_size!
94
+ end
95
+
96
+ private
97
+
98
+ # Validate file name format and extension
99
+ def validate_file_name!
100
+ raise ArgumentError, 'file_name exceeds maximum length of 255 characters' if @file_name.length > 255
101
+
102
+ valid_extensions = %w[.png .bmp .jpg .jpeg .webp .heic .heif]
103
+ extension = File.extname(@file_name.downcase)
104
+
105
+ unless valid_extensions.include?(extension)
106
+ raise ArgumentError, "Unsupported file extension: #{extension}. Supported: #{valid_extensions.join(', ')}"
107
+ end
108
+ end
109
+
110
+ # Validate base64 data size (basic check)
111
+ def validate_file_size!
112
+ # Basic size check - base64 data should not exceed ~42MB (32MB * 4/3 base64 overhead)
113
+ max_base64_size = 44_000_000 # Approximately 32MB when decoded
114
+
115
+ if @base64.length > max_base64_size
116
+ raise ArgumentError, 'Image size exceeds maximum limit of 32MB'
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Information about the analyzed image.
29
+ class CopyleaksAiImageDetectionImageInfoModel
30
+ # Dimensions of the analyzed image.
31
+ attr_accessor :shape
32
+
33
+ # Optional metadata extracted from the image.
34
+ attr_accessor :metadata
35
+
36
+ # Initialize a new CopyleaksAiImageDetectionImageInfoModel
37
+ #
38
+ # @param shape [CopyleaksImageShapeModel] Dimensions of the analyzed image
39
+ # @param metadata [CopyleaksImageMetadataModel] Optional metadata extracted from the image
40
+ def initialize(shape: nil, metadata: nil)
41
+ @shape = shape
42
+ @metadata = metadata
43
+ end
44
+
45
+ # Create instance from JSON hash
46
+ def self.from_json(json_hash)
47
+ return nil if json_hash.nil?
48
+
49
+ shape = CopyleaksImageShapeModel.from_json(json_hash['shape']) if json_hash['shape']
50
+ metadata = CopyleaksImageMetadataModel.from_json(json_hash['metadata']) if json_hash['metadata']
51
+
52
+ new(shape: shape, metadata: metadata)
53
+ end
54
+
55
+ # Convert to JSON
56
+ def to_json(*args)
57
+ {
58
+ 'shape' => @shape ? JSON.parse(@shape.to_json) : nil,
59
+ 'metadata' => @metadata ? JSON.parse(@metadata.to_json) : nil
60
+ }.to_json(*args)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Response model for Copyleaks AI image detection analysis.
29
+ # Contains the AI detection results, image information, and scan metadata.
30
+ class CopyleaksAiImageDetectionResponseModel
31
+ # The version of the AI detection model used for analysis.
32
+ attr_accessor :model
33
+
34
+ # RLE-encoded mask data containing arrays of start positions and lengths for AI-detected regions.
35
+ attr_accessor :result
36
+
37
+ # Summary statistics of the AI detection analysis.
38
+ attr_accessor :summary
39
+
40
+ # Information about the analyzed image.
41
+ attr_accessor :image_info
42
+
43
+ # Metadata about the scan operation.
44
+ attr_accessor :scanned_document
45
+
46
+ # Initialize a new CopyleaksAiImageDetectionResponseModel
47
+ #
48
+ # @param model [String] The version of the AI detection model used for analysis
49
+ # @param result [CopyleaksAiImageDetectionResultModel] RLE-encoded mask data containing arrays of start positions and lengths for AI-detected regions
50
+ # @param summary [CopyleaksAiImageDetectionSummaryModel] Summary statistics of the AI detection analysis
51
+ # @param image_info [CopyleaksAiImageDetectionImageInfoModel] Information about the analyzed image
52
+ # @param scanned_document [CopyleaksAiImageDetectionScannedDocumentModel] Metadata about the scan operation
53
+ def initialize(model: nil, result: nil, summary: nil, image_info: nil, scanned_document: nil)
54
+ @model = model
55
+ @result = result
56
+ @summary = summary
57
+ @image_info = image_info
58
+ @scanned_document = scanned_document
59
+ end
60
+
61
+ # Create instance from JSON hash
62
+ def self.from_json(json_hash)
63
+ return nil if json_hash.nil?
64
+
65
+ result = CopyleaksAiImageDetectionResultModel.from_json(json_hash['result']) if json_hash['result']
66
+ summary = CopyleaksAiImageDetectionSummaryModel.from_json(json_hash['summary']) if json_hash['summary']
67
+ image_info = CopyleaksAiImageDetectionImageInfoModel.from_json(json_hash['imageInfo']) if json_hash['imageInfo']
68
+ scanned_document = CopyleaksAiImageDetectionScannedDocumentModel.from_json(json_hash['scannedDocument']) if json_hash['scannedDocument']
69
+
70
+ new(
71
+ model: json_hash['model'],
72
+ result: result,
73
+ summary: summary,
74
+ image_info: image_info,
75
+ scanned_document: scanned_document
76
+ )
77
+ end
78
+
79
+ # Convert to JSON
80
+ def to_json(*args)
81
+ {
82
+ 'model' => @model,
83
+ 'result' => @result ? JSON.parse(@result.to_json) : nil,
84
+ 'summary' => @summary ? JSON.parse(@summary.to_json) : nil,
85
+ 'imageInfo' => @image_info ? JSON.parse(@image_info.to_json) : nil,
86
+ 'scannedDocument' => @scanned_document ? JSON.parse(@scanned_document.to_json) : nil
87
+ }.to_json(*args)
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # RLE-encoded mask data for AI-detected regions.
29
+ class CopyleaksAiImageDetectionResultModel
30
+ # Start positions of AI-detected segments in the flattened image array.
31
+ attr_accessor :starts
32
+
33
+ # Lengths of AI-detected segments corresponding to each start position.
34
+ attr_accessor :lengths
35
+
36
+ # Initialize a new CopyleaksAiImageDetectionResultModel
37
+ #
38
+ # @param starts [Array<Integer>] Start positions of AI-detected segments in the flattened image array
39
+ # @param lengths [Array<Integer>] Lengths of AI-detected segments corresponding to each start position
40
+ def initialize(starts: nil, lengths: nil)
41
+ @starts = starts
42
+ @lengths = lengths
43
+ end
44
+
45
+ # Create instance from JSON hash
46
+ def self.from_json(json_hash)
47
+ return nil if json_hash.nil?
48
+
49
+ new(
50
+ starts: json_hash['starts'],
51
+ lengths: json_hash['lengths']
52
+ )
53
+ end
54
+
55
+ # Convert to JSON
56
+ def to_json(*args)
57
+ {
58
+ 'starts' => @starts,
59
+ 'lengths' => @lengths
60
+ }.to_json(*args)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Metadata about the AI image detection scan operation.
29
+ class CopyleaksAiImageDetectionScannedDocumentModel
30
+ # The unique identifier for this scan.
31
+ attr_accessor :scan_id
32
+
33
+ # The actual number of credits consumed by this scan.
34
+ attr_accessor :actual_credits
35
+
36
+ # The expected number of credits for this scan.
37
+ attr_accessor :expected_credits
38
+
39
+ # ISO 8601 timestamp of when the scan was created.
40
+ attr_accessor :creation_time
41
+
42
+ # Initialize a new CopyleaksAiImageDetectionScannedDocumentModel
43
+ #
44
+ # @param scan_id [String] The unique identifier for this scan
45
+ # @param actual_credits [Integer] The actual number of credits consumed by this scan
46
+ # @param expected_credits [Integer] The expected number of credits for this scan
47
+ # @param creation_time [String] ISO 8601 timestamp of when the scan was created
48
+ def initialize(scan_id: nil, actual_credits: nil, expected_credits: nil, creation_time: nil)
49
+ @scan_id = scan_id
50
+ @actual_credits = actual_credits
51
+ @expected_credits = expected_credits
52
+ @creation_time = creation_time
53
+ end
54
+
55
+ # Create instance from JSON hash
56
+ def self.from_json(json_hash)
57
+ return nil if json_hash.nil?
58
+
59
+ new(
60
+ scan_id: json_hash['scanId'],
61
+ actual_credits: json_hash['actualCredits'],
62
+ expected_credits: json_hash['expectedCredits'],
63
+ creation_time: json_hash['creationTime']
64
+ )
65
+ end
66
+
67
+ # Convert to JSON
68
+ def to_json(*args)
69
+ {
70
+ 'scanId' => @scan_id,
71
+ 'actualCredits' => @actual_credits,
72
+ 'expectedCredits' => @expected_credits,
73
+ 'creationTime' => @creation_time
74
+ }.to_json(*args)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Summary statistics of the AI detection analysis.
29
+ class CopyleaksAiImageDetectionSummaryModel
30
+ # Percentage of pixels suspected to be human-created.
31
+ # Range: 0.0-1.0
32
+ attr_accessor :human
33
+
34
+ # Percentage of pixels suspected to be AI-generated.
35
+ # Range: 0.0-1.0
36
+ attr_accessor :ai
37
+
38
+ # Initialize a new CopyleaksAiImageDetectionSummaryModel
39
+ #
40
+ # @param human [Float] Percentage of pixels suspected to be human-created (0.0-1.0)
41
+ # @param ai [Float] Percentage of pixels suspected to be AI-generated (0.0-1.0)
42
+ def initialize(human: nil, ai: nil)
43
+ @human = human
44
+ @ai = ai
45
+ end
46
+
47
+ # Create instance from JSON hash
48
+ def self.from_json(json_hash)
49
+ return nil if json_hash.nil?
50
+
51
+ new(
52
+ human: json_hash['human'],
53
+ ai: json_hash['ai']
54
+ )
55
+ end
56
+
57
+ # Convert to JSON
58
+ def to_json(*args)
59
+ {
60
+ 'human' => @human,
61
+ 'ai' => @ai
62
+ }.to_json(*args)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Optional metadata extracted from the image.
29
+ class CopyleaksImageMetadataModel
30
+ # Timestamp when the image was created (if available).
31
+ attr_accessor :issued_time
32
+
33
+ # The AI service or tool that created the image (if detected).
34
+ attr_accessor :issued_by
35
+
36
+ # The application or device used to create the image.
37
+ attr_accessor :app_or_device_used
38
+
39
+ # Initialize a new CopyleaksImageMetadataModel
40
+ #
41
+ # @param issued_time [String] Timestamp when the image was created (if available)
42
+ # @param issued_by [String] The AI service or tool that created the image (if detected)
43
+ # @param app_or_device_used [String] The application or device used to create the image
44
+ def initialize(issued_time: nil, issued_by: nil, app_or_device_used: nil)
45
+ @issued_time = issued_time
46
+ @issued_by = issued_by
47
+ @app_or_device_used = app_or_device_used
48
+ end
49
+
50
+ # Create instance from JSON hash
51
+ def self.from_json(json_hash)
52
+ return nil if json_hash.nil?
53
+
54
+ new(
55
+ issued_time: json_hash['issuedTime'],
56
+ issued_by: json_hash['issuedBy'],
57
+ app_or_device_used: json_hash['appOrDeviceUsed']
58
+ )
59
+ end
60
+
61
+ # Convert to JSON
62
+ def to_json(*args)
63
+ {
64
+ 'issuedTime' => @issued_time,
65
+ 'issuedBy' => @issued_by,
66
+ 'appOrDeviceUsed' => @app_or_device_used
67
+ }.to_json(*args)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ********************************************************************************
4
+ # The MIT License(MIT)
5
+ #
6
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # ********************************************************************************
26
+
27
+ module Copyleaks
28
+ # Dimensions of the analyzed image.
29
+ class CopyleaksImageShapeModel
30
+ # Height of the image in pixels.
31
+ attr_accessor :height
32
+
33
+ # Width of the image in pixels.
34
+ attr_accessor :width
35
+
36
+ # Initialize a new CopyleaksImageShapeModel
37
+ #
38
+ # @param height [Integer] Height of the image in pixels
39
+ # @param width [Integer] Width of the image in pixels
40
+ def initialize(height: nil, width: nil)
41
+ @height = height
42
+ @width = width
43
+ end
44
+
45
+ # Create instance from JSON hash
46
+ def self.from_json(json_hash)
47
+ return nil if json_hash.nil?
48
+
49
+ new(
50
+ height: json_hash['height'],
51
+ width: json_hash['width']
52
+ )
53
+ end
54
+
55
+ # Convert to JSON
56
+ def to_json(*args)
57
+ {
58
+ 'height' => @height,
59
+ 'width' => @width
60
+ }.to_json(*args)
61
+ end
62
+ end
63
+ end
@@ -40,5 +40,14 @@ require_relative 'textModeration/responses/submodules/TextModerationScannedDocum
40
40
  require_relative 'textModeration/responses/submodules/TextModerationsLegend.rb'
41
41
  require_relative 'textModeration/responses/CopyleaksTextModerationResponseModel.rb'
42
42
 
43
+ require_relative 'imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb'
44
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb'
45
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb'
46
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb'
47
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb'
48
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb'
49
+ require_relative 'imageDetection/responses/CopyleaksImageMetadataModel.rb'
50
+ require_relative 'imageDetection/responses/CopyleaksImageShapeModel.rb'
51
+
43
52
  module Copyleaks
44
53
  end
@@ -1,3 +1,3 @@
1
1
  module Copyleaks
2
- VERSION = '4.0.0'
2
+ VERSION = '4.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plagiarism-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Copyleaks ltd
@@ -30,9 +30,11 @@ files:
30
30
  - bin/setup
31
31
  - lib/copyleaks.rb
32
32
  - lib/copyleaks/ai_detection_client.rb
33
+ - lib/copyleaks/ai_image_detection_client.rb
33
34
  - lib/copyleaks/api.rb
34
35
  - lib/copyleaks/app.config.rb
35
36
  - lib/copyleaks/models/auth_token.rb
37
+ - lib/copyleaks/models/constants/CopyleaksAiImageDetectionModels.rb
36
38
  - lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb
37
39
  - lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb
38
40
  - lib/copyleaks/models/constants/index.rb
@@ -48,6 +50,14 @@ files:
48
50
  - lib/copyleaks/models/exports/export_results.rb
49
51
  - lib/copyleaks/models/exports/index.rb
50
52
  - lib/copyleaks/models/id_object.rb
53
+ - lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb
54
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb
55
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb
56
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb
57
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb
58
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb
59
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksImageMetadataModel.rb
60
+ - lib/copyleaks/models/imageDetection/responses/CopyleaksImageShapeModel.rb
51
61
  - lib/copyleaks/models/index.rb
52
62
  - lib/copyleaks/models/start_request_model.rb
53
63
  - lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb