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



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

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:



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

def artwork
  select(&:artwork?)
end

#eventsArray<Entity>

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

Returns:



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

def events
  select(&:event?)
end

#goodsArray<Entity>

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

Returns:



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

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:



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

def locations
  select(&:location?)
end

#organizationsArray<Entity>

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

Returns:



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

def organizations
  select(&:organization?)
end

#otherArray<Entity>

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

Returns:



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

def other
  select(&:other?)
end

#peopleArray<Entity>

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

Returns:



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

def people
  select(&:person?)
end

#unknownArray<Entity>

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

Returns:



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

def unknown
  select(&:unknown?)
end