plagiarism-checker 3.4.0 → 3.6.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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/Gemfile +0 -0
  4. data/LICENSE.txt +0 -0
  5. data/README.md +0 -0
  6. data/Rakefile +0 -0
  7. data/bin/console +0 -0
  8. data/bin/setup +0 -0
  9. data/lib/copyleaks/ai_detection_client.rb +98 -98
  10. data/lib/copyleaks/api.rb +5 -0
  11. data/lib/copyleaks/app.config.rb +0 -0
  12. data/lib/copyleaks/models/auth_token.rb +0 -0
  13. data/lib/copyleaks/models/delete_request_model.rb +0 -0
  14. data/lib/copyleaks/models/exceptions/auth_expired_exception.rb +0 -0
  15. data/lib/copyleaks/models/exceptions/command_exception.rb +0 -0
  16. data/lib/copyleaks/models/exceptions/index.rb +0 -0
  17. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +0 -0
  18. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +0 -0
  19. data/lib/copyleaks/models/exports/export_crawled_version.rb +0 -0
  20. data/lib/copyleaks/models/exports/export_model.rb +0 -0
  21. data/lib/copyleaks/models/exports/export_pdf_report.rb +0 -0
  22. data/lib/copyleaks/models/exports/export_results.rb +0 -0
  23. data/lib/copyleaks/models/exports/index.rb +0 -0
  24. data/lib/copyleaks/models/id_object.rb +0 -0
  25. data/lib/copyleaks/models/index.rb +8 -0
  26. data/lib/copyleaks/models/start_request_model.rb +0 -0
  27. data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +50 -50
  28. data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +52 -52
  29. data/lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb +55 -55
  30. data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +0 -0
  31. data/lib/copyleaks/models/submissions/file_submission_model.rb +0 -0
  32. data/lib/copyleaks/models/submissions/index.rb +1 -0
  33. data/lib/copyleaks/models/submissions/properties/actions.rb +0 -0
  34. data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +0 -0
  35. data/lib/copyleaks/models/submissions/properties/author.rb +0 -0
  36. data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +0 -0
  37. data/lib/copyleaks/models/submissions/properties/cross_languages.rb +0 -0
  38. data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +0 -0
  39. data/lib/copyleaks/models/submissions/properties/domains_mode.rb +0 -0
  40. data/lib/copyleaks/models/submissions/properties/exclude.rb +0 -0
  41. data/lib/copyleaks/models/submissions/properties/exclude_code.rb +0 -0
  42. data/lib/copyleaks/models/submissions/properties/filter.rb +0 -0
  43. data/lib/copyleaks/models/submissions/properties/index.rb +0 -0
  44. data/lib/copyleaks/models/submissions/properties/indexing.rb +0 -0
  45. data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +0 -0
  46. data/lib/copyleaks/models/submissions/properties/language.rb +0 -0
  47. data/lib/copyleaks/models/submissions/properties/masking_policy.rb +0 -0
  48. data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +0 -0
  49. data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +0 -0
  50. data/lib/copyleaks/models/submissions/properties/pdf_version.rb +0 -0
  51. data/lib/copyleaks/models/submissions/properties/repository.rb +0 -0
  52. data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +0 -0
  53. data/lib/copyleaks/models/submissions/properties/scanning.rb +0 -0
  54. data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +0 -0
  55. data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +0 -0
  56. data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +0 -0
  57. data/lib/copyleaks/models/submissions/properties/submission_properties.rb +0 -0
  58. data/lib/copyleaks/models/submissions/properties/webhooks.rb +0 -0
  59. data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +0 -0
  60. data/lib/copyleaks/models/submissions/submission_model.rb +0 -0
  61. data/lib/copyleaks/models/submissions/url_submission_model.rb +0 -0
  62. data/lib/copyleaks/models/submissions/webhooks/CompletedWebhook.rb +46 -0
  63. data/lib/copyleaks/models/submissions/webhooks/CreditsCheckedWebhook.rb +43 -0
  64. data/lib/copyleaks/models/submissions/webhooks/ErrorWebhook.rb +41 -0
  65. data/lib/copyleaks/models/submissions/webhooks/ExportCompletedWebhook.rb +44 -0
  66. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Metadata.rb +89 -0
  67. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/StatusWebhook.rb +42 -0
  68. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Webhook.rb +43 -0
  69. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb +43 -0
  70. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb +68 -0
  71. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/ScannedDocument.rb +61 -0
  72. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ErrorModels/Error.rb +46 -0
  73. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ExportModels/Task.rb +49 -0
  74. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultScore.rb +42 -0
  75. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsInternet.rb +60 -0
  76. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsRepositories.rb +49 -0
  77. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NotificationsModels/Alerts.rb +65 -0
  78. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Batch.rb +46 -0
  79. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Database.rb +46 -0
  80. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Internet.rb +42 -0
  81. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Repositories.rb +57 -0
  82. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/RepositoryMetadata.rb +30 -0
  83. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Score.rb +40 -0
  84. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/SharedResultsModel.rb +46 -0
  85. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Tags.rb +33 -0
  86. data/lib/copyleaks/models/submissions/webhooks/IndexedWebhook.rb +29 -0
  87. data/lib/copyleaks/models/submissions/webhooks/NewResultWebhook.rb +46 -0
  88. data/lib/copyleaks/models/submissions/webhooks/index.rb +34 -0
  89. data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +54 -54
  90. data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +56 -56
  91. data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +43 -0
  92. data/lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb +36 -0
  93. data/lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb +26 -0
  94. data/lib/copyleaks/models/textModeration/responses/submodules/Text.rb +26 -0
  95. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb +35 -0
  96. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb +47 -0
  97. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb +29 -0
  98. data/lib/copyleaks/text_moderation_client.rb +51 -0
  99. data/lib/copyleaks/utils/copyleaks_client.utils.rb +0 -0
  100. data/lib/copyleaks/utils/status-code.utils.rb +0 -0
  101. data/lib/copyleaks/version.rb +1 -1
  102. data/lib/copyleaks/writing_assistant_client.rb +81 -81
  103. data/lib/copyleaks.rb +0 -0
  104. data/lib/index.rb +0 -0
  105. metadata +38 -7
  106. data/.vscode/launch.json +0 -35
@@ -0,0 +1,46 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+ module Copyleaks
20
+ class NewResultWebhook < Webhook
21
+ attr_reader :score, :internet, :database, :batch, :repositories
22
+
23
+ def initialize(score: nil, internet: nil, database: nil, batch: nil, repositories: nil, **args)
24
+ super(**args)
25
+ @score = score
26
+ @internet = internet
27
+ @database = database
28
+ @batch = batch
29
+ @repositories = repositories
30
+ end
31
+
32
+ def as_json(*_args)
33
+ {
34
+ score: @score,
35
+ internet: @internet,
36
+ database: @database,
37
+ batch: @batch,
38
+ repositories: @repositories
39
+ }.merge(super)
40
+ end
41
+
42
+ def to_json(*options)
43
+ as_json.to_json(*options)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,34 @@
1
+ module Copyleaks
2
+ require_relative 'HelperModels/baseModels/Metadata.rb'
3
+ require_relative 'HelperModels/baseModels/Webhook.rb'
4
+ require_relative 'HelperModels/baseModels/StatusWebhook.rb'
5
+
6
+ require_relative 'HelperModels/ResultsModels/SharedResultsModel.rb'
7
+ require_relative 'HelperModels/NewResultsModels/NewResultScore.rb'
8
+ require_relative 'HelperModels/NewResultsModels/NewResultsInternet.rb'
9
+ require_relative 'HelperModels/NewResultsModels/NewResultsRepositories.rb'
10
+
11
+ require_relative 'HelperModels/ResultsModels/Batch.rb'
12
+ require_relative 'HelperModels/ResultsModels/Internet.rb'
13
+ require_relative 'HelperModels/ResultsModels/Database.rb'
14
+ require_relative 'HelperModels/ResultsModels/Repositories.rb'
15
+ require_relative 'HelperModels/ResultsModels/RepositoryMetadata.rb'
16
+ require_relative 'HelperModels/ResultsModels/Score.rb'
17
+ require_relative 'HelperModels/ResultsModels/Tags.rb'
18
+
19
+ require_relative 'HelperModels/CompletedModels/Notifications.rb'
20
+ require_relative 'HelperModels/CompletedModels/Results.rb'
21
+ require_relative 'HelperModels/CompletedModels/ScannedDocument.rb'
22
+
23
+ require_relative 'HelperModels/ErrorModels/Error.rb'
24
+ require_relative 'HelperModels/NotificationsModels/Alerts.rb'
25
+ require_relative 'HelperModels/ExportModels/Task.rb'
26
+
27
+ require_relative 'CompletedWebhook.rb'
28
+ require_relative 'CreditsCheckedWebhook.rb'
29
+ require_relative 'ErrorWebhook.rb'
30
+ require_relative 'IndexedWebhook.rb'
31
+ require_relative 'ExportCompletedWebhook.rb'
32
+
33
+ require_relative 'NewResultWebhook.rb'
34
+ end
@@ -1,54 +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
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
@@ -1,56 +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
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,43 @@
1
+ require 'json'
2
+
3
+ module Copyleaks
4
+ class CopyleaksTextModerationRequestModel
5
+ attr_accessor :text, :sandbox, :language, :labels
6
+
7
+ # @param text [String] Text to produce Text Moderation report for.
8
+ # @param sandbox [Boolean] Use sandbox mode to test your integration. Default: false.
9
+ # @param language [String, nil] The language code. Optional; set to nil for auto-detect.
10
+ # @param labels [Array<Object>] A list of label configurations (min 1, max 32 elements).
11
+ def initialize(text: '', sandbox: false, language: nil, labels: [])
12
+
13
+ @text = text
14
+ @sandbox = sandbox
15
+ @language = language
16
+ @labels = labels
17
+
18
+ raise ArgumentError, "String cannot be blank" if @text.nil?
19
+ raise ArgumentError, "Labels must be a non-empty array." unless labels.is_a?(Array) && !labels.empty?
20
+ raise ArgumentError, "Labels cannot have more than 32 elements." if labels.length > 32
21
+
22
+ end
23
+
24
+ def to_json(options = {})
25
+ {
26
+ text: @text,
27
+ sandbox: @sandbox,
28
+ language: @language,
29
+ labels: @labels
30
+ }.to_json(options)
31
+ end
32
+
33
+ def self.from_json(json_string)
34
+ data = JSON.parse(json_string, symbolize_names: true)
35
+ new(
36
+ text: data[:text],
37
+ sandbox: data[:sandbox],
38
+ language: data[:language],
39
+ labels: data[:labels]
40
+ )
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ require 'json'
2
+ module Copyleaks
3
+
4
+ class CopyleaksTextModerationResponseModel
5
+ attr_accessor :moderations, :legend, :scanned_document
6
+
7
+ # @param moderations [ModerationsModel] Moderated text segments detected in the input text.
8
+ # @param legend [Array<TextModerationsLegend>] An array that provides a lookup for the labels referenced by their numerical indices in the `text.chars.labels` array. Each object within this legend array defines a specific label that was used in the scan.
9
+ # @param scanned_document [TextModerationScannedDocument] General information about the scanned document.
10
+ def initialize(moderations: ModerationsModel.new, legend: [], scanned_document: TextModerationScannedDocument.new, **_ignored)
11
+ @moderations = moderations
12
+ @legend = legend
13
+ @scanned_document = scanned_document
14
+ end
15
+
16
+
17
+ def to_json(options = {})
18
+ {
19
+ moderations: @moderations ? JSON.parse(@moderations.to_json) : nil,
20
+ legend: @legend.map(&:to_json).map { |l| JSON.parse(l) },
21
+ scannedDocument: @scanned_document ? JSON.parse(@scanned_document.to_json) : nil
22
+ }.to_json(options)
23
+ end
24
+
25
+
26
+ def self.from_json(json_string)
27
+ data = JSON.parse(json_string, symbolize_names: true)
28
+ new(
29
+ moderations: data[:moderations] ? ModerationsModel.from_json(data[:moderations].to_json) : nil,
30
+ legend: data[:legend].map { |l| TextModerationsLegend.from_json(l.to_json) },
31
+ scanned_document: data[:scannedDocument] ? TextModerationScannedDocument.from_json(data[:scannedDocument].to_json) : nil
32
+ )
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+ module Copyleaks
3
+
4
+ class ModerationsModel
5
+ attr_accessor :text
6
+
7
+ # @param text [Text] Moderated text segments corresponding to the submitted text. Each position in the inner arrays corresponds to a single segment in the textual version.
8
+ def initialize(text: Text.new)
9
+ @text = text
10
+ end
11
+
12
+ def to_json(options = {})
13
+ {
14
+ text: @text ? JSON.parse(@text.to_json) : nil
15
+ }.to_json(options)
16
+ end
17
+
18
+
19
+ def self.from_json(json_string)
20
+ data = JSON.parse(json_string, symbolize_names: true)
21
+ new(
22
+ text: data[:text] ? Text.from_json(data[:text].to_json) : nil
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+
3
+ module Copyleaks
4
+ class Text
5
+ attr_accessor :chars
6
+
7
+ # @param chars [TextModerationChars] An object that groups together several arrays detailing the properties of labelled segments.
8
+ def initialize(chars: TextModerationChars.new)
9
+ @chars = chars
10
+ end
11
+
12
+ def to_json(options = {})
13
+ {
14
+ chars: @chars ? JSON.parse(@chars.to_json) : nil
15
+ }.to_json(options)
16
+ end
17
+
18
+
19
+ def self.from_json(json_string)
20
+ data = JSON.parse(json_string, symbolize_names: true)
21
+ new(
22
+ chars: data[:chars] ? TextModerationChars.from_json(data[:chars].to_json) : nil
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,35 @@
1
+ require 'json'
2
+ module Copyleaks
3
+
4
+ class TextModerationChars
5
+ attr_accessor :labels, :starts, :lengths
6
+
7
+ # @param starts [Array<Integer>] Start character position of the labelled segment.
8
+ # @param labels [Array<Integer>] Predicted label index for the corresponding segment. The index can be resolved to its ID using the supplied legend.
9
+ # @param lengths [Array<Integer>] Labelled segment character length.
10
+ def initialize( starts: [],labels: [], lengths: [])
11
+ @starts = starts
12
+ @labels = labels
13
+ @lengths = lengths
14
+ end
15
+
16
+
17
+ def to_json(options = {})
18
+ {
19
+ labels: @labels,
20
+ starts: @starts,
21
+ lengths: @lengths
22
+ }.to_json(options)
23
+ end
24
+
25
+ def self.from_json(json_string)
26
+ data = JSON.parse(json_string, symbolize_names: true)
27
+ new(
28
+ labels: data[:labels],
29
+ starts: data[:starts],
30
+ lengths: data[:lengths]
31
+ )
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,47 @@
1
+ require 'json'
2
+ require 'date'
3
+ module Copyleaks
4
+
5
+ class TextModerationScannedDocument
6
+ attr_accessor :scan_id, :total_words, :total_excluded, :actual_credits, :expected_credits, :creation_time
7
+
8
+ # @param scan_id [String] The scan id given by the user.
9
+ # @param total_words [Integer] Total number of words found in the scanned text.
10
+ # @param total_excluded [Integer] Total excluded words from the text.
11
+ # @param actual_credits [Integer] The cost of credits for this scan.
12
+ # @param expected_credits [Integer] The amount of credits that was expected to be spent on the scan.
13
+ # @param creation_time [Time] Creation time of the scan.
14
+ def initialize(scan_id: '', total_words: 0, total_excluded: 0, actual_credits: 0, expected_credits: 0, creation_time: Time.utc.now)
15
+ @scan_id = scan_id
16
+ @total_words = total_words
17
+ @total_excluded = total_excluded
18
+ @actual_credits = actual_credits
19
+ @expected_credits = expected_credits
20
+ @creation_time = creation_time
21
+ end
22
+
23
+
24
+ def to_json(options = {})
25
+ {
26
+ scanId: @scan_id,
27
+ totalWords: @total_words,
28
+ totalExcluded: @total_excluded,
29
+ actualCredits: @actual_credits,
30
+ expectedCredits: @expected_credits,
31
+ creationTime: @creation_time.iso8601
32
+ }.to_json(options)
33
+ end
34
+
35
+ def self.from_json(json_string)
36
+ data = JSON.parse(json_string, symbolize_names: true)
37
+ new(
38
+ scan_id: data[:scanId],
39
+ total_words: data[:totalWords],
40
+ total_excluded: data[:totalExcluded],
41
+ actual_credits: data[:actualCredits],
42
+ expected_credits: data[:expectedCredits],
43
+ creation_time: Time.parse(data[:creationTime])
44
+ )
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+ module Copyleaks
3
+
4
+ class TextModerationsLegend
5
+ attr_accessor :index, :id
6
+
7
+ # @param index [integer] The numerical index of the label.
8
+ # @param id [string] A unique string identifier for the label. This ID serves as a machine-readable way to identify the label type.
9
+ def initialize(index: 0, id: '')
10
+ @index = index
11
+ @id = id
12
+ end
13
+
14
+ def to_json(options = {})
15
+ {
16
+ index: @index,
17
+ id: @id
18
+ }.to_json(options)
19
+ end
20
+
21
+ def self.from_json(json_string)
22
+ data = JSON.parse(json_string, symbolize_names: true)
23
+ new(
24
+ index: data[:index],
25
+ id: data[:id]
26
+ )
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,51 @@
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 TextModerationClient
27
+ def initialize(api_client)
28
+ @api_client = api_client
29
+ end
30
+
31
+ def submit_text(authToken, scanId, submission)
32
+ raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
33
+ raise 'submission is invalid, must be an instance of CopyleaksTextModerationRequestModel' if submission.nil? || !submission.instance_of?(Copyleaks::CopyleaksTextModerationRequestModel)
34
+
35
+ ClientUtils.verify_auth_token(authToken)
36
+
37
+ path = "/v1/text-moderation/#{scanId}/check"
38
+
39
+ headers = {
40
+ 'Content-Type' => 'application/json',
41
+ 'User-Agent' => Config.user_agent,
42
+ 'Authorization' => "Bearer #{authToken.accessToken}"
43
+ }
44
+
45
+ request = Net::HTTP::Post.new(path, headers)
46
+ request.body = submission.to_json
47
+
48
+ ClientUtils.handle_response(@api_client.request(request), 'submit_text_moderation')
49
+ end
50
+ end
51
+ end
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Copyleaks
2
- VERSION = '3.4.0'
2
+ VERSION = '3.6.0'
3
3
  end