plagiarism-checker 3.2.1 → 3.3.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/lib/copyleaks/ai_detection_client.rb +98 -0
- data/lib/copyleaks/api.rb +14 -0
- data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +50 -0
- data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +52 -0
- data/lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb +55 -0
- data/lib/copyleaks/models/submissions/index.rb +7 -0
- data/lib/copyleaks/models/submissions/properties/filter.rb +6 -2
- data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +54 -0
- data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +56 -0
- data/lib/copyleaks/utils/copyleaks_client.utils.rb +64 -0
- data/lib/copyleaks/version.rb +1 -1
- data/lib/copyleaks/writing_assistant_client.rb +81 -0
- data/lib/copyleaks.rb +1 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d4f3bce521d3c812846efd48a7806dbf34d22ba8f7067f70512009bcb5d22b
|
4
|
+
data.tar.gz: 8ab487b30508f22efafdfce4f23135f0f246a7cfaa4913627ab891a6d8e4f642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af4659d3ae1c2fe98d28a58198dc8f50943352bd9a6cf316618a25e1715f588f261dbae11af4fbb1935696a2dfd8c193676fe860db2c6cfdbfc65fe7fbe2d198
|
7
|
+
data.tar.gz: eb1ea926eddd84f1d65f8991d9d14e6e582afef63088c2ec7c1b2c32949aa83b7f92e9e3e36e393e3ef472fe73daf1380b90f527800681bc50f0451fc70e3b70
|
@@ -0,0 +1,98 @@
|
|
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 AIDetectionClient
|
27
|
+
def initialize(api_client)
|
28
|
+
@api_client = api_client
|
29
|
+
end
|
30
|
+
|
31
|
+
# Use Copyleaks AI Content Detection to differentiate between human source code and AI written source code.
|
32
|
+
# * Exceptions:
|
33
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
34
|
+
# headers and content for more info.
|
35
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
36
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
37
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
38
|
+
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
39
|
+
# @param [String] scanId Attach your own scan Id
|
40
|
+
# @param [SourceCodeSubmissionModel] submission document
|
41
|
+
def submit_source_code(authToken, scanId, submission)
|
42
|
+
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
43
|
+
if submission.nil? || !submission.instance_of?(Copyleaks::SourceCodeSubmissionModel)
|
44
|
+
raise 'submission is Invalid, must be instance of type Copyleaks::SourceCodeSubmissionModel'
|
45
|
+
end
|
46
|
+
|
47
|
+
ClientUtils.verify_auth_token(authToken)
|
48
|
+
|
49
|
+
path = "/v2/writer-detector/source-code/#{scanId}/check"
|
50
|
+
|
51
|
+
headers = {
|
52
|
+
'Content-Type' => 'application/json',
|
53
|
+
'User-Agent' => Config.user_agent,
|
54
|
+
'Authorization' => "Bearer #{authToken.accessToken}"
|
55
|
+
}
|
56
|
+
|
57
|
+
request = Net::HTTP::Post.new(path, headers)
|
58
|
+
request.body = submission.to_json
|
59
|
+
|
60
|
+
ClientUtils.handle_response(@api_client.request(request), 'submit_source_code')
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
|
65
|
+
# * Exceptions:
|
66
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
67
|
+
# headers and content for more info.
|
68
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
69
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
70
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
71
|
+
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
72
|
+
# @param [String] scanId Attach your own scan Id
|
73
|
+
# @param [SourceCodeSubmissionModel] submission document
|
74
|
+
def submit_natural_language(authToken, scanId, submission)
|
75
|
+
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
76
|
+
if submission.nil? || !submission.instance_of?(Copyleaks::NaturalLanguageSubmissionModel)
|
77
|
+
raise 'submission is Invalid, must be instance of type Copyleaks::NaturalLanguageSubmissionModel'
|
78
|
+
end
|
79
|
+
|
80
|
+
ClientUtils.verify_auth_token(authToken)
|
81
|
+
|
82
|
+
path = "/v2/writer-detector/#{scanId}/check"
|
83
|
+
|
84
|
+
headers = {
|
85
|
+
'Content-Type' => 'application/json',
|
86
|
+
'User-Agent' => Config.user_agent,
|
87
|
+
'Authorization' => "Bearer #{authToken.accessToken}"
|
88
|
+
}
|
89
|
+
|
90
|
+
request = Net::HTTP::Post.new(path, headers)
|
91
|
+
request.body = submission.to_json
|
92
|
+
|
93
|
+
res = ClientUtils.handle_response(@api_client.request(request), 'submit_natural_language')
|
94
|
+
puts "RES: #{res}"
|
95
|
+
res
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/copyleaks/api.rb
CHANGED
@@ -24,6 +24,8 @@
|
|
24
24
|
require 'net/http'
|
25
25
|
require 'json'
|
26
26
|
require 'date'
|
27
|
+
require_relative 'ai_detection_client.rb'
|
28
|
+
require_relative 'writing_assistant_client.rb'
|
27
29
|
|
28
30
|
module Copyleaks
|
29
31
|
class API
|
@@ -36,6 +38,10 @@ module Copyleaks
|
|
36
38
|
_api_server_uri = URI.parse(Config.api_server_uri)
|
37
39
|
@api_client = Net::HTTP.new(_api_server_uri.host, _api_server_uri.port)
|
38
40
|
@api_client.use_ssl = true
|
41
|
+
|
42
|
+
# Initialize clients
|
43
|
+
@ai_detection_client = AIDetectionClient.new(@api_client)
|
44
|
+
@writing_assistant_client = WritingAssistantClient.new(@api_client)
|
39
45
|
end
|
40
46
|
|
41
47
|
# Login to Copyleaks authentication server.
|
@@ -459,5 +465,13 @@ module Copyleaks
|
|
459
465
|
raise CommandException.new(_err_message).reason + "\n"
|
460
466
|
end
|
461
467
|
end
|
468
|
+
|
469
|
+
def ai_detection_client
|
470
|
+
@ai_detection_client
|
471
|
+
end
|
472
|
+
|
473
|
+
def writing_assistant_client
|
474
|
+
@writing_assistant_client
|
475
|
+
end
|
462
476
|
end
|
463
477
|
end
|
@@ -0,0 +1,50 @@
|
|
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 AIDetectionSubmissionModel
|
27
|
+
attr_accessor :text, :sandbox
|
28
|
+
|
29
|
+
# @param [String] A text string.
|
30
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
31
|
+
def initialize(text, sandbox = false)
|
32
|
+
unless text.instance_of?(String)
|
33
|
+
raise 'Copyleaks::AIDetectionSubmissionModel - text - text must be of type String'
|
34
|
+
end
|
35
|
+
@text = text
|
36
|
+
@sandbox = sandbox
|
37
|
+
end
|
38
|
+
|
39
|
+
def as_json(*_args)
|
40
|
+
{
|
41
|
+
'text' => @text,
|
42
|
+
'sandbox' => @sandbox
|
43
|
+
}.reject { |_, v| v.nil? }
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_json(*options)
|
47
|
+
as_json(*options).to_json(*options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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 NaturalLanguageSubmissionModel < AIDetectionSubmissionModel
|
27
|
+
attr_accessor :language
|
28
|
+
|
29
|
+
# @param [String] A text string.
|
30
|
+
# @param [String] The language code of your content. The selected language should be on the Supported Languages list above. If the 'language' field is not supplied , our system will automatically detect the language of the content.
|
31
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
32
|
+
def initialize(text, language = nil, sandbox = false)
|
33
|
+
unless text.instance_of?(String)
|
34
|
+
raise 'Copyleaks::NaturalLanguageSubmissionModel - text - text must be of type String'
|
35
|
+
end
|
36
|
+
super(text, sandbox)
|
37
|
+
@language = language
|
38
|
+
end
|
39
|
+
|
40
|
+
def as_json(*_args)
|
41
|
+
{
|
42
|
+
text: @text,
|
43
|
+
sandbox: @sandbox,
|
44
|
+
language: @language
|
45
|
+
}.select { |_k, v| !v.nil? }
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_json(*options)
|
49
|
+
as_json(*options).to_json(*options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,55 @@
|
|
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 SourceCodeSubmissionModel < AIDetectionSubmissionModel
|
27
|
+
attr_accessor :filename
|
28
|
+
|
29
|
+
# @param [String] A text string.
|
30
|
+
# @param [String] The name of the file. Make sure to include the right extension for your file type.
|
31
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
32
|
+
def initialize(text, filename, sandbox = false)
|
33
|
+
unless text.instance_of?(String)
|
34
|
+
raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
|
35
|
+
end
|
36
|
+
unless filename.instance_of?(String)
|
37
|
+
raise 'Copyleaks::SourceCodeSubmissionModel - filename - filename must be of type String'
|
38
|
+
end
|
39
|
+
super(text, sandbox)
|
40
|
+
@filename = filename
|
41
|
+
end
|
42
|
+
|
43
|
+
def as_json(*_args)
|
44
|
+
{
|
45
|
+
text: @text,
|
46
|
+
sandbox: @sandbox,
|
47
|
+
filename: @filename
|
48
|
+
}.select { |_k, v| !v.nil? }
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json(*options)
|
52
|
+
as_json(*options).to_json(*options)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -28,5 +28,12 @@ require_relative 'file_submission_model.rb'
|
|
28
28
|
require_relative 'file_ocr_submission_model.rb'
|
29
29
|
require_relative 'url_submission_model.rb'
|
30
30
|
|
31
|
+
require_relative 'ai_detection/ai_detection_submission_model.rb'
|
32
|
+
require_relative 'ai_detection/natural_language_submission_model.rb'
|
33
|
+
require_relative 'ai_detection/source_code_submission_model.rb'
|
34
|
+
|
35
|
+
require_relative 'writing_assistant/score_weights.rb'
|
36
|
+
require_relative 'writing_assistant/writing_assistant_submission_model.rb'
|
37
|
+
|
31
38
|
module Copyleaks
|
32
39
|
end
|
@@ -30,6 +30,7 @@ module Copyleaks
|
|
30
30
|
# @param [Boolean] safeSearch Block explicit adult content from the scan results such as web pages containing inappropriate images and videos. SafeSearch is not 100% effective with all websites.
|
31
31
|
# @param [String[]] domains list of domains to either include or exclude from the scan - depending on the value of domainsMode.
|
32
32
|
# @param [SubmissionFilterDomainsMode] domainsMode Include or Exclude the list of domains you specified under the domains property
|
33
|
+
# @param [Boolean] allowSameDomain when set to true it will allow results from the same domain as the submitted url.
|
33
34
|
def initialize(
|
34
35
|
identicalEnabled = true,
|
35
36
|
minorChangesEnabled = false,
|
@@ -37,7 +38,8 @@ module Copyleaks
|
|
37
38
|
minCopiedWords = nil,
|
38
39
|
safeSearch = false,
|
39
40
|
domains = [],
|
40
|
-
domainsMode = SubmissionFilterDomainsMode::EXCLUDE
|
41
|
+
domainsMode = SubmissionFilterDomainsMode::EXCLUDE,
|
42
|
+
allowSameDomain = false
|
41
43
|
)
|
42
44
|
@identicalEnabled = identicalEnabled
|
43
45
|
@minorChangesEnabled = minorChangesEnabled
|
@@ -46,6 +48,7 @@ module Copyleaks
|
|
46
48
|
@safeSearch = safeSearch
|
47
49
|
@domains = domains
|
48
50
|
@domainsMode = domainsMode
|
51
|
+
@allowSameDomain = allowSameDomain
|
49
52
|
end
|
50
53
|
|
51
54
|
def as_json(*_args)
|
@@ -56,7 +59,8 @@ module Copyleaks
|
|
56
59
|
minCopiedWords: @minCopiedWords,
|
57
60
|
safeSearch: @safeSearch,
|
58
61
|
domains: @domains,
|
59
|
-
domainsMode: @domainsMode
|
62
|
+
domainsMode: @domainsMode,
|
63
|
+
allowSameDomain: @allowSameDomain
|
60
64
|
}.select { |_k, v| !v.nil? }
|
61
65
|
end
|
62
66
|
|
@@ -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 ScoreWeights
|
27
|
+
# @param [Float] Grammar correction category weight in the overall score. 0.0 >= weight <= 1.0
|
28
|
+
# @param [Float] Mechanics correction category weight in the overall score. 0.0 >= weight <= 1.0
|
29
|
+
# @param [Float] Sentence structure correction category weight in the overall score. 0.0 >= weight <= 1.0
|
30
|
+
# @param [Float] Word choice correction category weight in the overall score. 0.0 >= weight <= 1.0
|
31
|
+
|
32
|
+
attr_accessor :grammar_score_weight, :mechanics_score_weight, :sentence_structure_score_weight, :word_choice_score_weight
|
33
|
+
|
34
|
+
def initialize(grammar_score_weight, mechanics_score_weight, sentence_structure_score_weight, word_choice_score_weight)
|
35
|
+
@grammar_score_weight = grammar_score_weight
|
36
|
+
@mechanics_score_weight = mechanics_score_weight
|
37
|
+
@sentence_structure_score_weight = sentence_structure_score_weight
|
38
|
+
@word_choice_score_weight = word_choice_score_weight
|
39
|
+
end
|
40
|
+
|
41
|
+
def as_json(*_args)
|
42
|
+
{
|
43
|
+
grammarScoreWeight: @grammar_score_weight,
|
44
|
+
mechanicsScoreWeight: @mechanics_score_weight,
|
45
|
+
sentenceStructureScoreWeight: @sentence_structure_score_weight,
|
46
|
+
wordChoiceScoreWeight: @word_choice_score_weight
|
47
|
+
}.reject { |_k, v| v.nil? }
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_json(*options)
|
51
|
+
as_json(*options).to_json(*options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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 WritingAssistantSubmissionModel
|
27
|
+
attr_accessor :text, :sandbox, :language, :score
|
28
|
+
|
29
|
+
# @param [String] Text to produce Writing Assistant report for. 1 >= characters <= 25000
|
30
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API without consuming any credits.
|
31
|
+
# @param [String] language The language code of your content. Optional; if not provided, the system will attempt to auto-detect the language.
|
32
|
+
# @param [ScoreWeights] an object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.
|
33
|
+
def initialize(text, sandbox = false, language = nil, score = nil)
|
34
|
+
unless text.instance_of?(String)
|
35
|
+
raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
|
36
|
+
end
|
37
|
+
@text = text
|
38
|
+
@sandbox = sandbox
|
39
|
+
@language = language
|
40
|
+
@score = score
|
41
|
+
end
|
42
|
+
|
43
|
+
def as_json(*_args)
|
44
|
+
{
|
45
|
+
text: @text,
|
46
|
+
sandbox: @sandbox,
|
47
|
+
language: @language,
|
48
|
+
score: @score
|
49
|
+
}.reject { |_k, v| v.nil? }
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_json(*options)
|
53
|
+
as_json(*options).to_json(*options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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 ClientUtils
|
27
|
+
def self.handle_response(response, used_by)
|
28
|
+
if Utils.is_success_status_code(response.code)
|
29
|
+
if response.body.nil? || response.body == ''
|
30
|
+
nil
|
31
|
+
else
|
32
|
+
parsed_response = JSON.parse(response.body)
|
33
|
+
puts "Parsed response: #{parsed_response.inspect}"
|
34
|
+
parsed_response
|
35
|
+
end
|
36
|
+
elsif Utils.is_under_maintenance_response(response.code)
|
37
|
+
raise UnderMaintenanceException.new.reason
|
38
|
+
elsif Utils.is_rate_limit_response(response.code)
|
39
|
+
raise RateLimitException.new.reason
|
40
|
+
else
|
41
|
+
_err_message = '---------Copyleaks SDK Error (' + used_by + ')---------' + "\n\n"
|
42
|
+
_err_message += 'status code: ' + response.code + "\n\n"
|
43
|
+
|
44
|
+
_err_message += 'response body:' + "\n" + response.body.to_json + "\n\n" unless response.body.nil?
|
45
|
+
|
46
|
+
_err_message += '-------------------------------------'
|
47
|
+
raise CommandException.new(_err_message).reason + "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.verify_auth_token(authToken)
|
52
|
+
if authToken.nil? || !authToken.instance_of?(CopyleaksAuthToken)
|
53
|
+
raise 'authToken is Invalid, must be instance of CopyleaksAuthToken'
|
54
|
+
end
|
55
|
+
|
56
|
+
_time = DateTime.now
|
57
|
+
_expiresTime = DateTime.parse(authToken.expires)
|
58
|
+
|
59
|
+
if _expiresTime <= _time
|
60
|
+
raise AuthExipredException.new.reason # expired
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/copyleaks/version.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
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 WritingAssistantClient
|
27
|
+
def initialize(api_client)
|
28
|
+
@api_client = api_client
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get a list of correction types supported within the Writing Assistant API. Correction types apply to all supported languages. The supplied language code for this request is used to determine the language of the texts returned.
|
32
|
+
# * Exceptions:
|
33
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
34
|
+
# headers and content for more info.
|
35
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
36
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
37
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
38
|
+
# @param [languageCode] The language for the returned texts to be in. Language codes are in ISO 639-1 standard. Supported Values: en - English
|
39
|
+
def get_correction_types(language_code)
|
40
|
+
path = "/v1/writing-feedback/correction-types/#{language_code}"
|
41
|
+
|
42
|
+
headers = {
|
43
|
+
'Content-Type' => 'application/json',
|
44
|
+
'User-Agent' => Config.user_agent
|
45
|
+
}
|
46
|
+
|
47
|
+
request = Net::HTTP::Get.new(path, headers)
|
48
|
+
ClientUtils.handle_response(@api_client.request(request), 'get_correction_types')
|
49
|
+
end
|
50
|
+
|
51
|
+
# Use Copyleaks Writing Assistant to generate grammar, spelling and sentence corrections for a given text.
|
52
|
+
# * Exceptions:
|
53
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
54
|
+
# headers and content for more info.
|
55
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
56
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
57
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
58
|
+
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
59
|
+
# @param [String] scanId Attach your own scan Id
|
60
|
+
# @param [SourceCodeSubmissionModel] submission document
|
61
|
+
def submit_text(authToken, scanId, submission)
|
62
|
+
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
63
|
+
raise 'submission is invalid, must be an instance of WritingAssistantSubmissionModel' if submission.nil? || !submission.instance_of?(Copyleaks::WritingAssistantSubmissionModel)
|
64
|
+
|
65
|
+
ClientUtils.verify_auth_token(authToken)
|
66
|
+
|
67
|
+
path = "/v1/writing-feedback/#{scanId}/check"
|
68
|
+
|
69
|
+
headers = {
|
70
|
+
'Content-Type' => 'application/json',
|
71
|
+
'User-Agent' => Config.user_agent,
|
72
|
+
'Authorization' => "Bearer #{authToken.accessToken}"
|
73
|
+
}
|
74
|
+
|
75
|
+
request = Net::HTTP::Post.new(path, headers)
|
76
|
+
request.body = submission.to_json
|
77
|
+
|
78
|
+
ClientUtils.handle_response(@api_client.request(request), 'submit_writing_assistant')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/copyleaks.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative './copyleaks/version.rb'
|
|
27
27
|
require_relative './copyleaks/app.config.rb'
|
28
28
|
require_relative './copyleaks/models/index.rb'
|
29
29
|
require_relative './copyleaks/utils/status-code.utils.rb'
|
30
|
+
require_relative './copyleaks/utils/copyleaks_client.utils.rb'
|
30
31
|
|
31
32
|
module Copyleaks
|
32
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plagiarism-checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Copyleaks ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Copyleaks detects plagiarism and checks content distribution online.
|
14
14
|
Use Copyleaks to find out if textual content is original and if it has been used
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- bin/console
|
31
31
|
- bin/setup
|
32
32
|
- lib/copyleaks.rb
|
33
|
+
- lib/copyleaks/ai_detection_client.rb
|
33
34
|
- lib/copyleaks/api.rb
|
34
35
|
- lib/copyleaks/app.config.rb
|
35
36
|
- lib/copyleaks/models/auth_token.rb
|
@@ -47,6 +48,9 @@ files:
|
|
47
48
|
- lib/copyleaks/models/id_object.rb
|
48
49
|
- lib/copyleaks/models/index.rb
|
49
50
|
- lib/copyleaks/models/start_request_model.rb
|
51
|
+
- lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb
|
52
|
+
- lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb
|
53
|
+
- lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb
|
50
54
|
- lib/copyleaks/models/submissions/file_ocr_submission_model.rb
|
51
55
|
- lib/copyleaks/models/submissions/file_submission_model.rb
|
52
56
|
- lib/copyleaks/models/submissions/index.rb
|
@@ -78,8 +82,12 @@ files:
|
|
78
82
|
- lib/copyleaks/models/submissions/properties/webhooks.rb
|
79
83
|
- lib/copyleaks/models/submissions/submission_model.rb
|
80
84
|
- lib/copyleaks/models/submissions/url_submission_model.rb
|
85
|
+
- lib/copyleaks/models/submissions/writing_assistant/score_weights.rb
|
86
|
+
- lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb
|
87
|
+
- lib/copyleaks/utils/copyleaks_client.utils.rb
|
81
88
|
- lib/copyleaks/utils/status-code.utils.rb
|
82
89
|
- lib/copyleaks/version.rb
|
90
|
+
- lib/copyleaks/writing_assistant_client.rb
|
83
91
|
- lib/index.rb
|
84
92
|
homepage: https://api.copyleaks.com
|
85
93
|
licenses:
|
@@ -103,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
111
|
- !ruby/object:Gem::Version
|
104
112
|
version: '0'
|
105
113
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.1.6
|
107
115
|
signing_key:
|
108
116
|
specification_version: 4
|
109
117
|
summary: Detects plagiarism and checks content distribution online.
|