Class: Copyleaks::NaturalLanguageSubmissionModel

Inherits:
AIDetectionSubmissionModel show all
Defined in:
lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb

Instance Attribute Summary collapse

Attributes inherited from AIDetectionSubmissionModel

#sandbox, #text

Instance Method Summary collapse

Constructor Details

#initialize(text, language = nil, sandbox = false) ⇒ NaturalLanguageSubmissionModel

Returns a new instance of NaturalLanguageSubmissionModel.

Parameters:

  • A (String)

    text string.

  • The (String)

    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.

  • Use (Boolean)

    sandbox mode to test your integration with the Copyleaks API for free.



32
33
34
35
36
37
38
# File 'lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb', line 32

def initialize(text, language = nil, sandbox = false)
  unless text.instance_of?(String)
    raise 'Copyleaks::NaturalLanguageSubmissionModel - text - text must be of type String'
  end
  super(text, sandbox)
  @language = language
end

Instance Attribute Details

#languageObject

Returns the value of attribute language.



27
28
29
# File 'lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb', line 27

def language
  @language
end

Instance Method Details

#as_json(*_args) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb', line 40

def as_json(*_args)
  {
    text: @text,
    sandbox: @sandbox,
    language: @language
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



48
49
50
# File 'lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb', line 48

def to_json(*options)
  as_json(*options).to_json(*options)
end