Reference documentation and code samples for the Natural Language V1beta2 API class Google::Cloud::Language::V1beta2::LanguageService::Client.
Client for the LanguageService service.
Provides text analysis operations such as sentiment analysis and entity recognition.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the LanguageService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all LanguageService clients ::Google::Cloud::Language::V1beta2::LanguageService::Client.configure do |config| config.timeout = 10.0 end
#analyze_entities
def analyze_entities(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse
def analyze_entities(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse
Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.
def analyze_entities(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse
analyze_entities
via a request object, either of type
AnalyzeEntitiesRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def analyze_entities(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse
analyze_entities
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- encoding_type (::Google::Cloud::Language::V1beta2::EncodingType) — The encoding type used by the API to calculate offsets.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest.new # Call the analyze_entities method. result = client.analyze_entities request # The returned object is of type Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse. p result
#analyze_entity_sentiment
def analyze_entity_sentiment(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse
def analyze_entity_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse
Finds entities, similar to AnalyzeEntities in the text and analyzes sentiment associated with each entity and its mentions.
def analyze_entity_sentiment(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse
analyze_entity_sentiment
via a request object, either of type
AnalyzeEntitySentimentRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def analyze_entity_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse
analyze_entity_sentiment
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- encoding_type (::Google::Cloud::Language::V1beta2::EncodingType) — The encoding type used by the API to calculate offsets.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest.new # Call the analyze_entity_sentiment method. result = client.analyze_entity_sentiment request # The returned object is of type Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse. p result
#analyze_sentiment
def analyze_sentiment(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse
def analyze_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse
Analyzes the sentiment of the provided text.
def analyze_sentiment(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse
analyze_sentiment
via a request object, either of type
AnalyzeSentimentRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def analyze_sentiment(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse
analyze_sentiment
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- encoding_type (::Google::Cloud::Language::V1beta2::EncodingType) — The encoding type used by the API to calculate sentence offsets for the sentence sentiment.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest.new # Call the analyze_sentiment method. result = client.analyze_sentiment request # The returned object is of type Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse. p result
#analyze_syntax
def analyze_syntax(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse
def analyze_syntax(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.
def analyze_syntax(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse
analyze_syntax
via a request object, either of type
AnalyzeSyntaxRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def analyze_syntax(document: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse
analyze_syntax
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- encoding_type (::Google::Cloud::Language::V1beta2::EncodingType) — The encoding type used by the API to calculate offsets.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest.new # Call the analyze_syntax method. result = client.analyze_syntax request # The returned object is of type Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse. p result
#annotate_text
def annotate_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnnotateTextResponse
def annotate_text(document: nil, features: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnnotateTextResponse
A convenience method that provides all syntax, sentiment, entity, and classification features in one call.
def annotate_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::AnnotateTextResponse
annotate_text
via a request object, either of type
AnnotateTextRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::AnnotateTextRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def annotate_text(document: nil, features: nil, encoding_type: nil) -> ::Google::Cloud::Language::V1beta2::AnnotateTextResponse
annotate_text
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- features (::Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features, ::Hash) — Required. The enabled features.
- encoding_type (::Google::Cloud::Language::V1beta2::EncodingType) — The encoding type used by the API to calculate offsets.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::AnnotateTextResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::AnnotateTextRequest.new # Call the annotate_text method. result = client.annotate_text request # The returned object is of type Google::Cloud::Language::V1beta2::AnnotateTextResponse. p result
#classify_text
def classify_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::ClassifyTextResponse
def classify_text(document: nil, classification_model_options: nil) -> ::Google::Cloud::Language::V1beta2::ClassifyTextResponse
Classifies a document into categories.
def classify_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::ClassifyTextResponse
classify_text
via a request object, either of type
ClassifyTextRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::ClassifyTextRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def classify_text(document: nil, classification_model_options: nil) -> ::Google::Cloud::Language::V1beta2::ClassifyTextResponse
classify_text
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- classification_model_options (::Google::Cloud::Language::V1beta2::ClassificationModelOptions, ::Hash) — Model options to use for classification. Defaults to v1 options if not specified.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::ClassifyTextResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::ClassifyTextRequest.new # Call the classify_text method. result = client.classify_text request # The returned object is of type Google::Cloud::Language::V1beta2::ClassifyTextResponse. p result
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the LanguageService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#initialize
def initialize() { |config| ... } -> Client
Create a new LanguageService client object.
- (config) — Configure the LanguageService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Language::V1beta2::LanguageService::Client.new do |config| config.timeout = 10.0 end
#moderate_text
def moderate_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::ModerateTextResponse
def moderate_text(document: nil) -> ::Google::Cloud::Language::V1beta2::ModerateTextResponse
Moderates a document for harmful and sensitive categories.
def moderate_text(request, options = nil) -> ::Google::Cloud::Language::V1beta2::ModerateTextResponse
moderate_text
via a request object, either of type
ModerateTextRequest or an equivalent Hash.
- request (::Google::Cloud::Language::V1beta2::ModerateTextRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def moderate_text(document: nil) -> ::Google::Cloud::Language::V1beta2::ModerateTextResponse
moderate_text
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- document (::Google::Cloud::Language::V1beta2::Document, ::Hash) — Required. Input document.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Language::V1beta2::ModerateTextResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/language/v1beta2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Language::V1beta2::LanguageService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Language::V1beta2::ModerateTextRequest.new # Call the moderate_text method. result = client.moderate_text request # The returned object is of type Google::Cloud::Language::V1beta2::ModerateTextResponse. p result
#universe_domain
def universe_domain() -> String
The effective universe domain
- (String)