Class: Google::Cloud::Language::Annotation::Sentiment
- Inherits:
-
Object
- Object
- Google::Cloud::Language::Annotation::Sentiment
- Defined in:
- lib/google/cloud/language/annotation.rb
Overview
Represents the result of sentiment analysis.
Instance Attribute Summary collapse
-
#language ⇒ String
readonly
The language of the document (if not specified, the language is automatically detected).
-
#magnitude ⇒ Float
readonly
A non-negative number in the [0, +inf] range, which represents the absolute magnitude of sentiment regardless of polarity (positive or negative).
-
#polarity ⇒ Float
readonly
Polarity of the sentiment in the [-1.0, 1.0] range.
Class Method Summary collapse
-
.from_grpc(grpc) ⇒ Object
V1beta1::AnalyzeSentimentResponse object.
Instance Method Summary collapse
-
#initialize(polarity, magnitude, language) ⇒ Sentiment
constructor
A new instance of Sentiment.
Constructor Details
#initialize(polarity, magnitude, language) ⇒ Sentiment
Returns a new instance of Sentiment.
602 603 604 605 606 |
# File 'lib/google/cloud/language/annotation.rb', line 602 def initialize polarity, magnitude, language @polarity = polarity @magnitude = magnitude @language = language end |
Instance Attribute Details
#language ⇒ String (readonly)
The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are supported.
597 598 599 |
# File 'lib/google/cloud/language/annotation.rb', line 597 def language @language end |
#magnitude ⇒ Float (readonly)
A non-negative number in the [0, +inf] range, which represents the absolute magnitude of sentiment regardless of polarity (positive or negative).
597 598 599 |
# File 'lib/google/cloud/language/annotation.rb', line 597 def magnitude @magnitude end |
#polarity ⇒ Float (readonly)
Polarity of the sentiment in the
- -1.0, 1.0
-
range. Larger numbers represent more positive
sentiments.
597 598 599 |
# File 'lib/google/cloud/language/annotation.rb', line 597 def polarity @polarity end |
Class Method Details
.from_grpc(grpc) ⇒ Object
V1beta1::AnalyzeSentimentResponse object.
611 612 613 614 |
# File 'lib/google/cloud/language/annotation.rb', line 611 def self.from_grpc grpc new grpc.document_sentiment.polarity, grpc.document_sentiment.magnitude, grpc.language end |