Class: CognitiveVision::ImageFeature::Description

Inherits:
Object
  • Object
show all
Defined in:
lib/cognitive_vision/image_feature/description.rb

Instance Method Summary collapse

Instance Method Details

#keyObject



4
5
6
# File 'lib/cognitive_vision/image_feature/description.rb', line 4

def key
  'description'
end

#parse(response) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/cognitive_vision/image_feature/description.rb', line 8

def parse(response)
  description_response = response[key]
  captions = description_response['captions'].map do |caption|
    CognitiveVision::DescriptionCaption.new(text: caption['text'], confidence: caption['confidence'])
  end
  CognitiveVision::Description.new(tags: description_response['tags'], captions: captions)
end