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 = "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



632
633
634
# File 'lib/google/cloud/language/annotation.rb', line 632

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:



693
694
695
# File 'lib/google/cloud/language/annotation.rb', line 693

def artwork
  select(&:artwork?)
end

#eventsArray<Entity>

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

Returns:



684
685
686
# File 'lib/google/cloud/language/annotation.rb', line 684

def events
  select(&:event?)
end

#goodsArray<Entity>

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

Returns:



702
703
704
# File 'lib/google/cloud/language/annotation.rb', line 702

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:



665
666
667
# File 'lib/google/cloud/language/annotation.rb', line 665

def locations
  select(&:location?)
end

#organizationsArray<Entity>

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

Returns:



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

def organizations
  select(&:organization?)
end

#otherArray<Entity>

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

Returns:



711
712
713
# File 'lib/google/cloud/language/annotation.rb', line 711

def other
  select(&:other?)
end

#peopleArray<Entity>

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

Returns:



656
657
658
# File 'lib/google/cloud/language/annotation.rb', line 656

def people
  select(&:person?)
end

#unknownArray<Entity>

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

Returns:



647
648
649
# File 'lib/google/cloud/language/annotation.rb', line 647

def unknown
  select(&:unknown?)
end