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/language"

language = Google::Cloud::Language.new

content = "Star Wars is a great movie. The Death Star is fearsome."
document = language.document content
annotation = document.annotate

entities = annotation.entities
entities.count #=> 3
entities.artwork.first.name #=> "Star Wars"

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



674
675
676
# File 'lib/google/cloud/language/annotation.rb', line 674

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:



735
736
737
# File 'lib/google/cloud/language/annotation.rb', line 735

def artwork
  select(&:artwork?)
end

#eventsArray<Entity>

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

Returns:



726
727
728
# File 'lib/google/cloud/language/annotation.rb', line 726

def events
  select(&:event?)
end

#goodsArray<Entity>

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

Returns:



744
745
746
# File 'lib/google/cloud/language/annotation.rb', line 744

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:



707
708
709
# File 'lib/google/cloud/language/annotation.rb', line 707

def locations
  select(&:location?)
end

#organizationsArray<Entity>

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

Returns:



717
718
719
# File 'lib/google/cloud/language/annotation.rb', line 717

def organizations
  select(&:organization?)
end

#otherArray<Entity>

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

Returns:



753
754
755
# File 'lib/google/cloud/language/annotation.rb', line 753

def other
  select(&:other?)
end

#peopleArray<Entity>

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

Returns:



698
699
700
# File 'lib/google/cloud/language/annotation.rb', line 698

def people
  select(&:person?)
end

#unknownArray<Entity>

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

Returns:



689
690
691
# File 'lib/google/cloud/language/annotation.rb', line 689

def unknown
  select(&:unknown?)
end