Class: Google::Cloud::Language::Annotation::Entities

Inherits:
Array
  • Object
show all
Defined in:
lib/google/cloud/language/annotation.rb

Overview

The entities returned by entity analysis.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
language = gcloud.language

content = "Darth Vader is the best villain in Star Wars."
document = language.document content
annotation = document.annotate

entities = annotation.entities
entities.count #=> 2
entities.people.count #=> 1
entities.artwork.count #=> 1

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#languageString

The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are supported.

Returns:

  • (String)

    the current value of language



342
343
344
# File 'lib/google/cloud/language/annotation.rb', line 342

def language
  @language
end

Instance Method Details

#artworkArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :WORK_OF_ART.

Returns:



403
404
405
# File 'lib/google/cloud/language/annotation.rb', line 403

def artwork
  select(&:artwork?)
end

#eventsArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :EVENT.

Returns:



394
395
396
# File 'lib/google/cloud/language/annotation.rb', line 394

def events
  select(&:event?)
end

#goodsArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :CONSUMER_GOOD.

Returns:



412
413
414
# File 'lib/google/cloud/language/annotation.rb', line 412

def goods
  select(&:good?)
end

#locationsArray<Entity> Also known as: places

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :LOCATION.

Returns:



375
376
377
# File 'lib/google/cloud/language/annotation.rb', line 375

def locations
  select(&:location?)
end

#organizationsArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :ORGANIZATION.

Returns:



385
386
387
# File 'lib/google/cloud/language/annotation.rb', line 385

def organizations
  select(&:organization?)
end

#otherArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :OTHER.

Returns:



421
422
423
# File 'lib/google/cloud/language/annotation.rb', line 421

def other
  select(&:other?)
end

#peopleArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :PERSON.

Returns:



366
367
368
# File 'lib/google/cloud/language/annotation.rb', line 366

def people
  select(&:person?)
end

#unknownArray<Entity>

Returns the entities for which Google::Cloud::Language::Annotation::Entity#type is :UNKNOWN.

Returns:



357
358
359
# File 'lib/google/cloud/language/annotation.rb', line 357

def unknown
  select(&:unknown?)
end