Class: AssemblyAI::Transcripts::TopicDetectionResult
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::TopicDetectionResult
- Defined in:
- lib/assemblyai/transcripts/types/topic_detection_result.rb
Overview
The result of the topic detection model
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::TopicDetectionResultLabelsItem>
readonly
An array of detected topics in the text.
-
#text ⇒ String
readonly
The text in the transcript in which a detected topic occurs.
- #timestamp ⇒ AssemblyAI::Transcripts::Timestamp readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TopicDetectionResult
Deserialize a JSON object to an instance of TopicDetectionResult.
-
.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: OMIT, timestamp: OMIT, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TopicDetectionResult constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TopicDetectionResult to a JSON object.
Constructor Details
#initialize(text:, labels: OMIT, timestamp: OMIT, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TopicDetectionResult
31 32 33 34 35 36 37 38 39 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 31 def initialize(text:, labels: OMIT, timestamp: OMIT, additional_properties: nil) @text = text @labels = labels if labels != OMIT @timestamp = if != OMIT @additional_properties = additional_properties @_field_set = { "text": text, "labels": labels, "timestamp": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 19 def additional_properties @additional_properties end |
#labels ⇒ Array<AssemblyAI::Transcripts::TopicDetectionResultLabelsItem> (readonly)
Returns An array of detected topics in the text.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 15 def labels @labels end |
#text ⇒ String (readonly)
Returns The text in the transcript in which a detected topic occurs.
13 14 15 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 13 def text @text end |
#timestamp ⇒ AssemblyAI::Transcripts::Timestamp (readonly)
17 18 19 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 17 def @timestamp end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TopicDetectionResult
Deserialize a JSON object to an instance of TopicDetectionResult
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 45 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::TopicDetectionResultLabelsItem.from_json(json_object: v) 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, 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.
80 81 82 83 84 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 80 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..nil? || AssemblyAI::Transcripts::Timestamp.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TopicDetectionResult to a JSON object
70 71 72 |
# File 'lib/assemblyai/transcripts/types/topic_detection_result.rb', line 70 def to_json(*_args) @_field_set&.to_json end |