plagiarism-checker 3.7.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 +4 -4
- data/.gitignore +9 -0
- data/README.md +225 -31
- data/lib/copyleaks/ai_detection_client.rb +1 -35
- data/lib/copyleaks/{models/submissions/ai_detection/source_code_submission_model.rb → ai_image_detection_client.rb} +22 -23
- data/lib/copyleaks/api.rb +6 -9
- data/lib/copyleaks/models/constants/CopyleaksAiImageDetectionModels.rb +28 -0
- data/lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb +39 -0
- data/lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb +29 -0
- data/lib/copyleaks/models/constants/index.rb +4 -1
- data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb +120 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb +63 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb +90 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb +63 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb +77 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb +65 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageMetadataModel.rb +70 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageShapeModel.rb +63 -0
- data/lib/copyleaks/models/index.rb +10 -0
- data/lib/copyleaks/models/submissions/index.rb +0 -1
- data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +1 -1
- data/lib/copyleaks/{deprecationService.rb → models/textModeration/requests/CopyleaksTextModerationLabel.rb} +18 -12
- data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +23 -0
- data/lib/copyleaks/version.rb +1 -1
- data/lib/copyleaks/writing_assistant_client.rb +1 -1
- metadata +14 -4
- data/lib/copyleaks/models/constants/supportedFilesTypes.rb +0 -31
@@ -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
|
data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb
ADDED
@@ -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
|
@@ -32,6 +32,7 @@ require_relative 'delete_request_model.rb'
|
|
32
32
|
require_relative 'start_request_model.rb'
|
33
33
|
|
34
34
|
require_relative 'textModeration/requests/CopyleaksTextModerationRequestModel.rb'
|
35
|
+
require_relative 'textModeration/requests/CopyleaksTextModerationLabel.rb'
|
35
36
|
require_relative 'textModeration/responses/submodules/ModerationsModel.rb'
|
36
37
|
require_relative 'textModeration/responses/submodules/Text.rb'
|
37
38
|
require_relative 'textModeration/responses/submodules/TextModerationChars.rb'
|
@@ -39,5 +40,14 @@ require_relative 'textModeration/responses/submodules/TextModerationScannedDocum
|
|
39
40
|
require_relative 'textModeration/responses/submodules/TextModerationsLegend.rb'
|
40
41
|
require_relative 'textModeration/responses/CopyleaksTextModerationResponseModel.rb'
|
41
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
|
+
|
42
52
|
module Copyleaks
|
43
53
|
end
|
@@ -30,7 +30,6 @@ require_relative 'url_submission_model.rb'
|
|
30
30
|
|
31
31
|
require_relative 'ai_detection/ai_detection_submission_model.rb'
|
32
32
|
require_relative 'ai_detection/natural_language_submission_model.rb'
|
33
|
-
require_relative 'ai_detection/source_code_submission_model.rb'
|
34
33
|
require_relative 'Webhooks/index.rb'
|
35
34
|
|
36
35
|
require_relative 'writing_assistant/score_weights.rb'
|
data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb
CHANGED
@@ -32,7 +32,7 @@ module Copyleaks
|
|
32
32
|
# @param [ScoreWeights] an object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.
|
33
33
|
def initialize(text, sandbox = false, language = nil, score = nil)
|
34
34
|
unless text.instance_of?(String)
|
35
|
-
raise 'Copyleaks::
|
35
|
+
raise 'Copyleaks::WritingAssistantSubmissionModel - text - text must be of type String'
|
36
36
|
end
|
37
37
|
@text = text
|
38
38
|
@sandbox = sandbox
|