Class: Copyleaks::TextModerationChars

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(starts: [], labels: [], lengths: []) ⇒ TextModerationChars

Returns a new instance of TextModerationChars.

Parameters:

  • starts (Array<Integer>) (defaults to: [])

    Start character position of the labelled segment.

  • labels (Array<Integer>) (defaults to: [])

    Predicted label index for the corresponding segment. The index can be resolved to its ID using the supplied legend.

  • lengths (Array<Integer>) (defaults to: [])

    Labelled segment character length.



10
11
12
13
14
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 10

def initialize( starts: [],labels: [], lengths: [])
  @starts = starts
  @labels = labels
  @lengths = lengths
end

Instance Attribute Details

#labelsObject

Returns the value of attribute labels.



5
6
7
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 5

def labels
  @labels
end

#lengthsObject

Returns the value of attribute lengths.



5
6
7
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 5

def lengths
  @lengths
end

#startsObject

Returns the value of attribute starts.



5
6
7
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 5

def starts
  @starts
end

Class Method Details

.from_json(json_string) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 25

def self.from_json(json_string)
  data = JSON.parse(json_string, symbolize_names: true)
  new(
    labels: data[:labels],
    starts: data[:starts],
    lengths: data[:lengths]
  )
end

Instance Method Details

#to_json(options = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb', line 17

def to_json(options = {})
  {
    labels: @labels,
    starts: @starts,
    lengths: @lengths
  }.to_json(options)
end