Class: AssemblyAI::Transcripts::ContentSafetyLabelResult
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::ContentSafetyLabelResult
- Defined in:
- lib/assemblyai/transcripts/types/content_safety_label_result.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#labels ⇒ Array<AssemblyAI::Transcripts::ContentSafetyLabel>
readonly
An array of safety labels, one per sensitive topic that was detected in the section.
-
#sentences_idx_end ⇒ Integer
readonly
The sentence index at which the section ends.
-
#sentences_idx_start ⇒ Integer
readonly
The sentence index at which the section begins.
-
#text ⇒ String
readonly
The transcript of the section flagged by the Content Moderation model.
-
#timestamp ⇒ AssemblyAI::Transcripts::Timestamp
readonly
Timestamp information for the section.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult
Deserialize a JSON object to an instance of ContentSafetyLabelResult.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ContentSafetyLabelResult to a JSON object.
Constructor Details
#initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 38 def initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil) @text = text @labels = labels @sentences_idx_start = sentences_idx_start @sentences_idx_end = sentences_idx_end @timestamp = @additional_properties = additional_properties @_field_set = { "text": text, "labels": labels, "sentences_idx_start": sentences_idx_start, "sentences_idx_end": sentences_idx_end, "timestamp": } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
23 24 25 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 23 def additional_properties @additional_properties end |
#labels ⇒ Array<AssemblyAI::Transcripts::ContentSafetyLabel> (readonly)
Returns An array of safety labels, one per sensitive topic that was detected in the section.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 15 def labels @labels end |
#sentences_idx_end ⇒ Integer (readonly)
Returns The sentence index at which the section ends.
19 20 21 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 19 def sentences_idx_end @sentences_idx_end end |
#sentences_idx_start ⇒ Integer (readonly)
Returns The sentence index at which the section begins.
17 18 19 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 17 def sentences_idx_start @sentences_idx_start end |
#text ⇒ String (readonly)
Returns The transcript of the section flagged by the Content Moderation model.
12 13 14 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 12 def text @text end |
#timestamp ⇒ AssemblyAI::Transcripts::Timestamp (readonly)
Returns Timestamp information for the section.
21 22 23 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 21 def @timestamp end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult
Deserialize a JSON object to an instance of ContentSafetyLabelResult
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 58 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) text = struct["text"] labels = parsed_json["labels"]&.map do |v| v = v.to_json AssemblyAI::Transcripts::ContentSafetyLabel.from_json(json_object: v) end sentences_idx_start = struct["sentences_idx_start"] sentences_idx_end = struct["sentences_idx_end"] if parsed_json["timestamp"].nil? = nil else = parsed_json["timestamp"].to_json = AssemblyAI::Transcripts::Timestamp.from_json(json_object: ) end new( text: text, labels: labels, sentences_idx_start: sentences_idx_start, sentences_idx_end: sentences_idx_end, timestamp: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
97 98 99 100 101 102 103 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 97 def self.validate_raw(obj:) obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.labels.is_a?(Array) != false || raise("Passed value for field obj.labels is not the expected type, validation failed.") obj.sentences_idx_start.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_start is not the expected type, validation failed.") obj.sentences_idx_end.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_end is not the expected type, validation failed.") AssemblyAI::Transcripts::Timestamp.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ContentSafetyLabelResult to a JSON object
87 88 89 |
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 87 def to_json(*_args) @_field_set&.to_json end |