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.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



638
639
640
# File 'lib/google/cloud/language/annotation.rb', line 638

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:



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

def artwork
  select(&:artwork?)
end

#eventsArray<Entity>

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

Returns:



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

def events
  select(&:event?)
end

#goodsArray<Entity>

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

Returns:



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

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:



671
672
673
# File 'lib/google/cloud/language/annotation.rb', line 671

def locations
  select(&:location?)
end

#organizationsArray<Entity>

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

Returns:



681
682
683
# File 'lib/google/cloud/language/annotation.rb', line 681

def organizations
  select(&:organization?)
end

#otherArray<Entity>

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

Returns:



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

def other
  select(&:other?)
end

#peopleArray<Entity>

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

Returns:



662
663
664
# File 'lib/google/cloud/language/annotation.rb', line 662

def people
  select(&:person?)
end

#unknownArray<Entity>

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

Returns:



653
654
655
# File 'lib/google/cloud/language/annotation.rb', line 653

def unknown
  select(&:unknown?)
end