Class: Google::Apis::LanguageV1beta2::CloudNaturalLanguageService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/language_v1beta2/service.rb

Overview

Cloud Natural Language API

Provides natural language understanding technologies, such as sentiment analysis, entity recognition, entity sentiment analysis, and other text annotations, to developers.

Examples:

require 'google/apis/language_v1beta2'

Language = Google::Apis::LanguageV1beta2 # Alias the module
service = Language::CloudNaturalLanguageService.new

See Also:

Constant Summary collapse

DEFAULT_ENDPOINT_TEMPLATE =
"https://language.$UNIVERSE_DOMAIN$/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCloudNaturalLanguageService

Returns a new instance of CloudNaturalLanguageService.



49
50
51
52
53
54
# File 'lib/google/apis/language_v1beta2/service.rb', line 49

def initialize
  super(DEFAULT_ENDPOINT_TEMPLATE, '',
        client_name: 'google-apis-language_v1beta2',
        client_version: Google::Apis::LanguageV1beta2::GEM_VERSION)
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

Returns:

  • (String)

    API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.



42
43
44
# File 'lib/google/apis/language_v1beta2/service.rb', line 42

def key
  @key
end

#quota_userString

Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

Returns:

  • (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.



47
48
49
# File 'lib/google/apis/language_v1beta2/service.rb', line 47

def quota_user
  @quota_user
end

Instance Method Details

#analyze_document_entities(analyze_entities_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::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.

Parameters:

  • analyze_entities_request_object (Google::Apis::LanguageV1beta2::AnalyzeEntitiesRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



77
78
79
80
81
82
83
84
85
86
# File 'lib/google/apis/language_v1beta2/service.rb', line 77

def analyze_document_entities(analyze_entities_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:analyzeEntities', options)
  command.request_representation = Google::Apis::LanguageV1beta2::AnalyzeEntitiesRequest::Representation
  command.request_object = analyze_entities_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::AnalyzeEntitiesResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::AnalyzeEntitiesResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#analyze_document_entity_sentiment(analyze_entity_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::AnalyzeEntitySentimentResponse

Finds entities, similar to AnalyzeEntities in the text and analyzes sentiment associated with each entity and its mentions.

Parameters:

  • analyze_entity_sentiment_request_object (Google::Apis::LanguageV1beta2::AnalyzeEntitySentimentRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



108
109
110
111
112
113
114
115
116
117
# File 'lib/google/apis/language_v1beta2/service.rb', line 108

def analyze_document_entity_sentiment(analyze_entity_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:analyzeEntitySentiment', options)
  command.request_representation = Google::Apis::LanguageV1beta2::AnalyzeEntitySentimentRequest::Representation
  command.request_object = analyze_entity_sentiment_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::AnalyzeEntitySentimentResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::AnalyzeEntitySentimentResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#analyze_document_sentiment(analyze_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::AnalyzeSentimentResponse

Analyzes the sentiment of the provided text.

Parameters:

  • analyze_sentiment_request_object (Google::Apis::LanguageV1beta2::AnalyzeSentimentRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



138
139
140
141
142
143
144
145
146
147
# File 'lib/google/apis/language_v1beta2/service.rb', line 138

def analyze_document_sentiment(analyze_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:analyzeSentiment', options)
  command.request_representation = Google::Apis::LanguageV1beta2::AnalyzeSentimentRequest::Representation
  command.request_object = analyze_sentiment_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::AnalyzeSentimentResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::AnalyzeSentimentResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#analyze_document_syntax(analyze_syntax_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::AnalyzeSyntaxResponse

Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.

Parameters:

  • analyze_syntax_request_object (Google::Apis::LanguageV1beta2::AnalyzeSyntaxRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



170
171
172
173
174
175
176
177
178
179
# File 'lib/google/apis/language_v1beta2/service.rb', line 170

def analyze_document_syntax(analyze_syntax_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:analyzeSyntax', options)
  command.request_representation = Google::Apis::LanguageV1beta2::AnalyzeSyntaxRequest::Representation
  command.request_object = analyze_syntax_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::AnalyzeSyntaxResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::AnalyzeSyntaxResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#annotate_document_text(annotate_text_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::AnnotateTextResponse

A convenience method that provides all syntax, sentiment, entity, and classification features in one call.

Parameters:

  • annotate_text_request_object (Google::Apis::LanguageV1beta2::AnnotateTextRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



201
202
203
204
205
206
207
208
209
210
# File 'lib/google/apis/language_v1beta2/service.rb', line 201

def annotate_document_text(annotate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:annotateText', options)
  command.request_representation = Google::Apis::LanguageV1beta2::AnnotateTextRequest::Representation
  command.request_object = annotate_text_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::AnnotateTextResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::AnnotateTextResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#classify_document_text(classify_text_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::ClassifyTextResponse

Classifies a document into categories.

Parameters:

  • classify_text_request_object (Google::Apis::LanguageV1beta2::ClassifyTextRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



231
232
233
234
235
236
237
238
239
240
# File 'lib/google/apis/language_v1beta2/service.rb', line 231

def classify_document_text(classify_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:classifyText', options)
  command.request_representation = Google::Apis::LanguageV1beta2::ClassifyTextRequest::Representation
  command.request_object = classify_text_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::ClassifyTextResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::ClassifyTextResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#moderate_document_text(moderate_text_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::LanguageV1beta2::ModerateTextResponse

Moderates a document for harmful and sensitive categories.

Parameters:

  • moderate_text_request_object (Google::Apis::LanguageV1beta2::ModerateTextRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



261
262
263
264
265
266
267
268
269
270
# File 'lib/google/apis/language_v1beta2/service.rb', line 261

def moderate_document_text(moderate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1beta2/documents:moderateText', options)
  command.request_representation = Google::Apis::LanguageV1beta2::ModerateTextRequest::Representation
  command.request_object = moderate_text_request_object
  command.response_representation = Google::Apis::LanguageV1beta2::ModerateTextResponse::Representation
  command.response_class = Google::Apis::LanguageV1beta2::ModerateTextResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end