Class: Google::Cloud::Vision::Annotation::Web::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/vision/annotation/web.rb

Overview

Entity

Entity deduced from similar images on the Internet.

See Google::Cloud::Vision::Annotation::Web.

Examples:

require "google/cloud/vision"

vision = Google::Cloud::Vision.new

image = vision.image "path/to/landmark.jpg"

web = image.web

entity = web.entities.first
entity.entity_id #=> "/m/019dvv"
entity.score #=> 107.34591674804688
entity.description #=> "Mount Rushmore National Memorial"

Instance Method Summary collapse

Instance Method Details

#descriptionString

Canonical description of the entity, in English.

Returns:

  • (String)


204
205
206
# File 'lib/google/cloud/vision/annotation/web.rb', line 204

def description
  @grpc.description
end

#entity_idString

Opaque entity ID.

Returns:

  • (String)


185
186
187
# File 'lib/google/cloud/vision/annotation/web.rb', line 185

def entity_id
  @grpc.entity_id
end

#scoreFloat

Overall relevancy score for the entity. Not normalized and not comparable across different image queries.

Returns:

  • (Float)


195
196
197
# File 'lib/google/cloud/vision/annotation/web.rb', line 195

def score
  @grpc.score
end

#to_aArray

Returns the object's property values as an array.

Returns:

  • (Array)


213
214
215
# File 'lib/google/cloud/vision/annotation/web.rb', line 213

def to_a
  [entity_id, score, description]
end

#to_hHash

Converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


222
223
224
# File 'lib/google/cloud/vision/annotation/web.rb', line 222

def to_h
  { entity_id: entity_id, score: score, description: description }
end