Class: Google::Apis::LanguageV1::CloudNaturalLanguageService

Inherits:
Core::BaseService show all
Defined in:
generated/google/apis/language_v1/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_v1'

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

See Also:

Instance Attribute Summary collapse

Attributes inherited from Core::BaseService

#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path

Instance Method Summary collapse

Methods inherited from Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Methods included from Core::Logging

#logger

Constructor Details

#initializeCloudNaturalLanguageService

Returns a new instance of CloudNaturalLanguageService


47
48
49
50
# File 'generated/google/apis/language_v1/service.rb', line 47

def initialize
  super('https://language.googleapis.com/', '')
  @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.


40
41
42
# File 'generated/google/apis/language_v1/service.rb', line 40

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.


45
46
47
# File 'generated/google/apis/language_v1/service.rb', line 45

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::LanguageV1::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::LanguageV1::AnalyzeEntitiesRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


73
74
75
76
77
78
79
80
81
82
# File 'generated/google/apis/language_v1/service.rb', line 73

def analyze_document_entities(analyze_entities_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/documents:analyzeEntities', options)
  command.request_representation = Google::Apis::LanguageV1::AnalyzeEntitiesRequest::Representation
  command.request_object = analyze_entities_request_object
  command.response_representation = Google::Apis::LanguageV1::AnalyzeEntitiesResponse::Representation
  command.response_class = Google::Apis::LanguageV1::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::LanguageV1::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::LanguageV1::AnalyzeEntitySentimentRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


104
105
106
107
108
109
110
111
112
113
# File 'generated/google/apis/language_v1/service.rb', line 104

def analyze_document_entity_sentiment(analyze_entity_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/documents:analyzeEntitySentiment', options)
  command.request_representation = Google::Apis::LanguageV1::AnalyzeEntitySentimentRequest::Representation
  command.request_object = analyze_entity_sentiment_request_object
  command.response_representation = Google::Apis::LanguageV1::AnalyzeEntitySentimentResponse::Representation
  command.response_class = Google::Apis::LanguageV1::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::LanguageV1::AnalyzeSentimentResponse

Analyzes the sentiment of the provided text.

Parameters:

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

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


134
135
136
137
138
139
140
141
142
143
# File 'generated/google/apis/language_v1/service.rb', line 134

def analyze_document_sentiment(analyze_sentiment_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/documents:analyzeSentiment', options)
  command.request_representation = Google::Apis::LanguageV1::AnalyzeSentimentRequest::Representation
  command.request_object = analyze_sentiment_request_object
  command.response_representation = Google::Apis::LanguageV1::AnalyzeSentimentResponse::Representation
  command.response_class = Google::Apis::LanguageV1::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::LanguageV1::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::LanguageV1::AnalyzeSyntaxRequest) (defaults to: nil)
  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


166
167
168
169
170
171
172
173
174
175
# File 'generated/google/apis/language_v1/service.rb', line 166

def analyze_document_syntax(analyze_syntax_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/documents:analyzeSyntax', options)
  command.request_representation = Google::Apis::LanguageV1::AnalyzeSyntaxRequest::Representation
  command.request_object = analyze_syntax_request_object
  command.response_representation = Google::Apis::LanguageV1::AnalyzeSyntaxResponse::Representation
  command.response_class = Google::Apis::LanguageV1::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::LanguageV1::AnnotateTextResponse

A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.

Parameters:

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

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


197
198
199
200
201
202
203
204
205
206
# File 'generated/google/apis/language_v1/service.rb', line 197

def annotate_document_text(annotate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v1/documents:annotateText', options)
  command.request_representation = Google::Apis::LanguageV1::AnnotateTextRequest::Representation
  command.request_object = annotate_text_request_object
  command.response_representation = Google::Apis::LanguageV1::AnnotateTextResponse::Representation
  command.response_class = Google::Apis::LanguageV1::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::LanguageV1::ClassifyTextResponse

Classifies a document into categories.

Parameters:

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

    Selector specifying which fields to include in a partial response.

  • quota_user (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.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


227
228
229
230
231
232
233
234
235
236
# File 'generated/google/apis/language_v1/service.rb', line 227

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