Class: Google::Cloud::Language::Annotation::Entity
- Inherits:
-
Object
- Object
- Google::Cloud::Language::Annotation::Entity
- Defined in:
- lib/google/cloud/language/annotation.rb
Overview
Represents a phrase in the text that is a known entity, such as a person, an organization, or location. The API associates information, such as salience and mentions, with entities.
Defined Under Namespace
Classes: Mention
Instance Attribute Summary collapse
-
#mentions ⇒ Array<Entity::Mention>
readonly
The mentions of this entity in the input document.
-
#metadata ⇒ Hash<String,String>
readonly
Metadata associated with the entity.
-
#name ⇒ String
readonly
The representative name for the entity.
-
#salience ⇒ Float
readonly
The salience score associated with the entity in the [0, 1.0] range.
-
#type ⇒ Symbol
readonly
The type of the entity.
Instance Method Summary collapse
-
#artwork? ⇒ Boolean
Returns
true
if #type is:WORK_OF_ART
. -
#event? ⇒ Boolean
Returns
true
if #type is:EVENT
. -
#good? ⇒ Boolean
Returns
true
if #type is:CONSUMER_GOOD
. -
#location? ⇒ Boolean
(also: #place?)
Returns
true
if #type is:LOCATION
. -
#mid ⇒ String
Returns the
mid
property of the #metadata. -
#organization? ⇒ Boolean
Returns
true
if #type is:ORGANIZATION
. -
#other? ⇒ Boolean
Returns
true
if #type is:OTHER
. -
#person? ⇒ Boolean
Returns
true
if #type is:PERSON
. -
#unknown? ⇒ Boolean
Returns
true
if #type is:UNKNOWN
. -
#wikipedia_url ⇒ String
Returns the
wikipedia_url
property of the #metadata.
Instance Attribute Details
#mentions ⇒ Array<Entity::Mention> (readonly)
The mentions of this entity in the input document. The API currently supports proper noun mentions.
764 765 766 |
# File 'lib/google/cloud/language/annotation.rb', line 764 def mentions @mentions end |
#metadata ⇒ Hash<String,String> (readonly)
Metadata associated with the entity. Currently, only Wikipedia URLs are provided, if available. The associated key is "wikipedia_url".
764 765 766 |
# File 'lib/google/cloud/language/annotation.rb', line 764 def @metadata end |
#name ⇒ String (readonly)
The representative name for the entity.
764 765 766 |
# File 'lib/google/cloud/language/annotation.rb', line 764 def name @name end |
#salience ⇒ Float (readonly)
The salience score associated with the entity in the [0, 1.0] range. The salience score for an entity provides information about the importance or centrality of that entity to the entire document text. Scores closer to 0 are less salient, while scores closer to 1.0 are highly salient.
764 765 766 |
# File 'lib/google/cloud/language/annotation.rb', line 764 def salience @salience end |
#type ⇒ Symbol (readonly)
The type of the entity.
764 765 766 |
# File 'lib/google/cloud/language/annotation.rb', line 764 def type @type end |
Instance Method Details
#artwork? ⇒ Boolean
Returns true
if #type is :WORK_OF_ART
.
828 829 830 |
# File 'lib/google/cloud/language/annotation.rb', line 828 def artwork? type == :WORK_OF_ART end |
#event? ⇒ Boolean
Returns true
if #type is :EVENT
.
819 820 821 |
# File 'lib/google/cloud/language/annotation.rb', line 819 def event? type == :EVENT end |
#good? ⇒ Boolean
Returns true
if #type is :CONSUMER_GOOD
.
837 838 839 |
# File 'lib/google/cloud/language/annotation.rb', line 837 def good? type == :CONSUMER_GOOD end |
#location? ⇒ Boolean Also known as: place?
Returns true
if #type is :LOCATION
.
800 801 802 |
# File 'lib/google/cloud/language/annotation.rb', line 800 def location? type == :LOCATION end |
#mid ⇒ String
Returns the mid
property of the #metadata. The MID
(machine-generated identifier) (MID) correspods to the entity's
Google Knowledge Graph
entry. Note that MID values remain unique across different
languages, so you can use such values to tie entities together from
different languages. For programmatically inspecting these MID
values, please consult the Google Knowledge Graph Search
API documentation.
871 872 873 |
# File 'lib/google/cloud/language/annotation.rb', line 871 def mid ["mid"] end |
#organization? ⇒ Boolean
Returns true
if #type is :ORGANIZATION
.
810 811 812 |
# File 'lib/google/cloud/language/annotation.rb', line 810 def organization? type == :ORGANIZATION end |
#other? ⇒ Boolean
Returns true
if #type is :OTHER
.
846 847 848 |
# File 'lib/google/cloud/language/annotation.rb', line 846 def other? type == :OTHER end |
#person? ⇒ Boolean
Returns true
if #type is :PERSON
.
791 792 793 |
# File 'lib/google/cloud/language/annotation.rb', line 791 def person? type == :PERSON end |
#unknown? ⇒ Boolean
Returns true
if #type is :UNKNOWN
.
782 783 784 |
# File 'lib/google/cloud/language/annotation.rb', line 782 def unknown? type == :UNKNOWN end |
#wikipedia_url ⇒ String
Returns the wikipedia_url
property of the #metadata.
855 856 857 |
# File 'lib/google/cloud/language/annotation.rb', line 855 def wikipedia_url ["wikipedia_url"] end |