Class: Google::Cloud::Language::Annotation::Sentence
- Inherits:
-
Object
- Object
- Google::Cloud::Language::Annotation::Sentence
- Defined in:
- lib/google/cloud/language/annotation.rb
Overview
Represents a piece of text including relative location.
Defined Under Namespace
Classes: Sentiment
Instance Attribute Summary collapse
-
#sentiment ⇒ Sentence::Sentiment
readonly
The sentence sentiment.
-
#text_span ⇒ TextSpan
readonly
The sentence text.
Instance Method Summary collapse
-
#magnitude ⇒ Float
A non-negative number in the [0, +inf] range, which represents the absolute magnitude of sentiment regardless of score (positive or negative).
-
#offset ⇒ Integer
(also: #begin_offset)
The API calculates the beginning offset of the content in the original document according to the
encoding
specified in the API request. -
#score ⇒ Float
Score.
-
#sentiment? ⇒ Boolean
Returns
true
if the Sentence has a Sentiment. -
#text ⇒ String
(also: #content)
The content of the output text.
Instance Attribute Details
#sentiment ⇒ Sentence::Sentiment (readonly)
The sentence sentiment.
362 363 364 |
# File 'lib/google/cloud/language/annotation.rb', line 362 def sentiment @sentiment end |
#text_span ⇒ TextSpan (readonly)
The sentence text.
362 363 364 |
# File 'lib/google/cloud/language/annotation.rb', line 362 def text_span @text_span end |
Instance Method Details
#magnitude ⇒ Float
A non-negative number in the [0, +inf] range, which represents the absolute magnitude of sentiment regardless of score (positive or negative). See Google::Cloud::Language::Annotation::Sentence::Sentiment#magnitude.
419 420 421 422 |
# File 'lib/google/cloud/language/annotation.rb', line 419 def magnitude return nil unless sentiment? sentiment.magnitude end |
#offset ⇒ Integer Also known as: begin_offset
The API calculates the beginning offset of the content in the
original document according to the encoding
specified in the
API request. See TextSpan#offset.
389 390 391 |
# File 'lib/google/cloud/language/annotation.rb', line 389 def offset text_span.offset end |
#score ⇒ Float
407 408 409 410 |
# File 'lib/google/cloud/language/annotation.rb', line 407 def score return nil unless sentiment? sentiment.score end |
#sentiment? ⇒ Boolean
Returns true
if the Sentence has a Sentiment.
398 399 400 |
# File 'lib/google/cloud/language/annotation.rb', line 398 def sentiment? !sentiment.nil? end |
#text ⇒ String Also known as: content
The content of the output text. See TextSpan#text.
377 378 379 |
# File 'lib/google/cloud/language/annotation.rb', line 377 def text text_span.text end |