Class: Multitagger::Provider::Microsoft

Inherits:
Object
  • Object
show all
Defined in:
lib/multitagger/provider/microsoft.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Microsoft

Returns a new instance of Microsoft.



7
8
9
# File 'lib/multitagger/provider/microsoft.rb', line 7

def initialize(config)
  @client = MicrosoftComputerVision::Client.new(config["key"])
end

Instance Method Details

#tag(image) ⇒ Object



11
12
13
14
15
# File 'lib/multitagger/provider/microsoft.rb', line 11

def tag(image)
  result = @client.analyze image, {visual_features: "Tags"}
  data = JSON.parse result.body
  data["tags"].map { |x| Tag.new(x["name"], x["confidence"]) }
end