Class: Google::Cloud::Language::Annotation::Entity::Mention
- Inherits:
-
Object
- Object
- Google::Cloud::Language::Annotation::Entity::Mention
- Defined in:
- lib/google/cloud/language/annotation.rb
Overview
Represents a piece of text including relative location.
Instance Attribute Summary collapse
-
#text_span ⇒ TextSpan
readonly
The entity mention text.
-
#type ⇒ Symbol
readonly
The type of the entity mention.
Instance Method Summary collapse
-
#common? ⇒ Boolean
Returns
true
if #type is:COMMON
. -
#offset ⇒ Integer
(also: #begin_offset)
The beginning offset of the content in the original document.
-
#proper? ⇒ Boolean
Returns
true
if #type is:PROPER
. -
#text ⇒ String
(also: #content)
The content of the output text.
Instance Attribute Details
#text_span ⇒ TextSpan (readonly)
The entity mention text.
959 960 961 |
# File 'lib/google/cloud/language/annotation.rb', line 959 def text_span @text_span end |
#type ⇒ Symbol (readonly)
The type of the entity mention. The
possible return values are :TYPE_UNKNOWN
, :PROPER
(proper
name), and :COMMON
(Common noun or noun compound).
959 960 961 |
# File 'lib/google/cloud/language/annotation.rb', line 959 def type @type end |
Instance Method Details
#common? ⇒ Boolean
Returns true
if #type is :COMMON
.
1014 1015 1016 |
# File 'lib/google/cloud/language/annotation.rb', line 1014 def common? type == :COMMON end |
#offset ⇒ Integer Also known as: begin_offset
The beginning offset of the content in the original document. See TextSpan#offset.
The API calculates the beginning offset according to the client
system's default encoding. In Ruby this defaults to UTF-8. To
change the offset calculation you will need to change Ruby's
default encoding. This is commonly done by setting
Encoding.default_internal
to Encoding::UTF_16
or
Encoding::UTF_32
. If the system is configured to use an encoding
other than UTF-16 or UTF-32 the offset will be calculated using
UTF-8.
995 996 997 |
# File 'lib/google/cloud/language/annotation.rb', line 995 def offset text_span.offset end |
#proper? ⇒ Boolean
Returns true
if #type is :PROPER
.
1005 1006 1007 |
# File 'lib/google/cloud/language/annotation.rb', line 1005 def proper? type == :PROPER end |
#text ⇒ String Also known as: content
The content of the output text. See TextSpan#text.
974 975 976 |
# File 'lib/google/cloud/language/annotation.rb', line 974 def text text_span.text end |