google-cloud-language 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +38 -1
- data/lib/google/cloud/language.rb +32 -2
- data/lib/google/cloud/language/v1.rb +75 -41
- data/lib/google/cloud/language/v1/credentials.rb +40 -0
- data/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb +0 -11
- data/lib/google/cloud/language/v1/doc/overview.rb +27 -2
- data/lib/google/cloud/language/v1/language_service_client.rb +91 -34
- data/lib/google/cloud/language/v1beta2.rb +76 -51
- data/lib/google/cloud/language/v1beta2/credentials.rb +40 -0
- data/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb +1 -12
- data/lib/google/cloud/language/v1beta2/doc/overview.rb +31 -5
- data/lib/google/cloud/language/v1beta2/language_service_client.rb +100 -55
- data/lib/google/cloud/language/v1beta2/language_service_services_pb.rb +1 -1
- metadata +36 -7
- data/lib/google/cloud/language/credentials.rb +0 -30
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -16,47 +16,73 @@ require "google/cloud/language/v1beta2/language_service_client"
|
|
16
16
|
|
17
17
|
module Google
|
18
18
|
module Cloud
|
19
|
-
# rubocop:disable LineLength
|
20
|
-
|
21
|
-
##
|
22
|
-
# # Ruby Client for Google Cloud Natural Language API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
23
|
-
#
|
24
|
-
# [Google Cloud Natural Language API][Product Documentation]:
|
25
|
-
# Google Cloud Natural Language API provides natural language understanding
|
26
|
-
# technologies to developers. Examples include sentiment analysis, entity
|
27
|
-
# recognition, and text annotations.
|
28
|
-
# - [Product Documentation][]
|
29
|
-
#
|
30
|
-
# ## Quick Start
|
31
|
-
# In order to use this library, you first need to go through the following
|
32
|
-
# steps:
|
33
|
-
#
|
34
|
-
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
35
|
-
# 2. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
|
36
|
-
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
37
|
-
#
|
38
|
-
# ### Preview
|
39
|
-
# #### LanguageServiceClient
|
40
|
-
# ```rb
|
41
|
-
# require "google/cloud/language/v1beta2"
|
42
|
-
#
|
43
|
-
# language_service_client = Google::Cloud::Language::V1beta2.new
|
44
|
-
# content = "Hello, world!"
|
45
|
-
# type = :PLAIN_TEXT
|
46
|
-
# document = { content: content, type: type }
|
47
|
-
# response = language_service_client.analyze_sentiment(document)
|
48
|
-
# ```
|
49
|
-
#
|
50
|
-
# ### Next Steps
|
51
|
-
# - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
|
52
|
-
# to learn more about the product and see How-to Guides.
|
53
|
-
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
54
|
-
# to see the full list of Cloud APIs that we cover.
|
55
|
-
#
|
56
|
-
# [Product Documentation]: https://cloud.google.com/natural-language
|
57
|
-
#
|
58
|
-
#
|
59
19
|
module Language
|
20
|
+
# rubocop:disable LineLength
|
21
|
+
|
22
|
+
##
|
23
|
+
# # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
24
|
+
#
|
25
|
+
# [Google Cloud Natural Language API][Product Documentation]:
|
26
|
+
# Google Cloud Natural Language API provides natural language understanding
|
27
|
+
# technologies to developers. Examples include sentiment analysis, entity
|
28
|
+
# recognition, and text annotations.
|
29
|
+
# - [Product Documentation][]
|
30
|
+
#
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
34
|
+
#
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
+
# 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
|
38
|
+
# 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
39
|
+
#
|
40
|
+
# ### Preview
|
41
|
+
# #### LanguageServiceClient
|
42
|
+
# ```rb
|
43
|
+
# require "google/cloud/language"
|
44
|
+
#
|
45
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
46
|
+
# content = "Hello, world!"
|
47
|
+
# type = :PLAIN_TEXT
|
48
|
+
# document = { content: content, type: type }
|
49
|
+
# response = language_service_client.analyze_sentiment(document)
|
50
|
+
# ```
|
51
|
+
#
|
52
|
+
# ### Next Steps
|
53
|
+
# - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
|
54
|
+
# to learn more about the product and see How-to Guides.
|
55
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
56
|
+
# to see the full list of Cloud APIs that we cover.
|
57
|
+
#
|
58
|
+
# [Product Documentation]: https://cloud.google.com/natural-language
|
59
|
+
#
|
60
|
+
# ## Enabling Logging
|
61
|
+
#
|
62
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
63
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
64
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
65
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
66
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
67
|
+
#
|
68
|
+
# Configuring a Ruby stdlib logger:
|
69
|
+
#
|
70
|
+
# ```ruby
|
71
|
+
# require "logger"
|
72
|
+
#
|
73
|
+
# module MyLogger
|
74
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
75
|
+
# def logger
|
76
|
+
# LOGGER
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
81
|
+
# module GRPC
|
82
|
+
# extend MyLogger
|
83
|
+
# end
|
84
|
+
# ```
|
85
|
+
#
|
60
86
|
module V1beta2
|
61
87
|
# rubocop:enable LineLength
|
62
88
|
|
@@ -88,28 +114,27 @@ module Google
|
|
88
114
|
# or the specified config is missing data points.
|
89
115
|
# @param timeout [Numeric]
|
90
116
|
# The default timeout, in seconds, for calls made through this client.
|
117
|
+
# @param metadata [Hash]
|
118
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
119
|
+
# @param exception_transformer [Proc]
|
120
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
121
|
+
# custom error handling.
|
91
122
|
def self.new \
|
92
|
-
service_path: nil,
|
93
|
-
port: nil,
|
94
|
-
channel: nil,
|
95
|
-
chan_creds: nil,
|
96
|
-
updater_proc: nil,
|
97
123
|
credentials: nil,
|
98
124
|
scopes: nil,
|
99
125
|
client_config: nil,
|
100
126
|
timeout: nil,
|
127
|
+
metadata: nil,
|
128
|
+
exception_transformer: nil,
|
101
129
|
lib_name: nil,
|
102
130
|
lib_version: nil
|
103
131
|
kwargs = {
|
104
|
-
service_path: service_path,
|
105
|
-
port: port,
|
106
|
-
channel: channel,
|
107
|
-
chan_creds: chan_creds,
|
108
|
-
updater_proc: updater_proc,
|
109
132
|
credentials: credentials,
|
110
133
|
scopes: scopes,
|
111
134
|
client_config: client_config,
|
112
135
|
timeout: timeout,
|
136
|
+
metadata: metadata,
|
137
|
+
exception_transformer: exception_transformer,
|
113
138
|
lib_name: lib_name,
|
114
139
|
lib_version: lib_version
|
115
140
|
}.select { |_, v| v != nil }
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "googleauth"
|
16
|
+
|
17
|
+
module Google
|
18
|
+
module Cloud
|
19
|
+
module Language
|
20
|
+
module V1beta2
|
21
|
+
class Credentials < Google::Auth::Credentials
|
22
|
+
SCOPE = [
|
23
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
24
|
+
].freeze
|
25
|
+
PATH_ENV_VARS = %w(LANGUAGE_CREDENTIALS
|
26
|
+
LANGUAGE_KEYFILE
|
27
|
+
GOOGLE_CLOUD_CREDENTIALS
|
28
|
+
GOOGLE_CLOUD_KEYFILE
|
29
|
+
GCLOUD_KEYFILE)
|
30
|
+
JSON_ENV_VARS = %w(LANGUAGE_CREDENTIALS_JSON
|
31
|
+
LANGUAGE_KEYFILE_JSON
|
32
|
+
GOOGLE_CLOUD_CREDENTIALS_JSON
|
33
|
+
GOOGLE_CLOUD_KEYFILE_JSON
|
34
|
+
GCLOUD_KEYFILE_JSON)
|
35
|
+
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -15,17 +15,6 @@
|
|
15
15
|
module Google
|
16
16
|
module Cloud
|
17
17
|
module Language
|
18
|
-
##
|
19
|
-
# # Google Cloud Natural Language API Contents
|
20
|
-
#
|
21
|
-
# | Class | Description |
|
22
|
-
# | ----- | ----------- |
|
23
|
-
# | [LanguageServiceClient][] | Google Cloud Natural Language API provides natural language understanding technologies to developers. Examples include sentiment analysis, entity recognition, and text annotations. |
|
24
|
-
# | [Data Types][] | Data types for Google::Cloud::Language::V1beta2 |
|
25
|
-
#
|
26
|
-
# [LanguageServiceClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1beta2/languageserviceclient
|
27
|
-
# [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1beta2/datatypes
|
28
|
-
#
|
29
18
|
module V1beta2
|
30
19
|
# ================================================================ #
|
31
20
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -17,7 +17,7 @@ module Google
|
|
17
17
|
# rubocop:disable LineLength
|
18
18
|
|
19
19
|
##
|
20
|
-
# # Ruby Client for Google Cloud Natural Language API ([
|
20
|
+
# # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
21
21
|
#
|
22
22
|
# [Google Cloud Natural Language API][Product Documentation]:
|
23
23
|
# Google Cloud Natural Language API provides natural language understanding
|
@@ -30,8 +30,9 @@ module Google
|
|
30
30
|
# steps:
|
31
31
|
#
|
32
32
|
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
33
|
-
# 2. [Enable
|
34
|
-
# 3. [
|
33
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
34
|
+
# 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
|
35
|
+
# 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
35
36
|
#
|
36
37
|
# ### Installation
|
37
38
|
# ```
|
@@ -58,10 +59,35 @@ module Google
|
|
58
59
|
#
|
59
60
|
# [Product Documentation]: https://cloud.google.com/natural-language
|
60
61
|
#
|
62
|
+
# ## Enabling Logging
|
63
|
+
#
|
64
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
65
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
66
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
67
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
68
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
69
|
+
#
|
70
|
+
# Configuring a Ruby stdlib logger:
|
71
|
+
#
|
72
|
+
# ```ruby
|
73
|
+
# require "logger"
|
74
|
+
#
|
75
|
+
# module MyLogger
|
76
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
77
|
+
# def logger
|
78
|
+
# LOGGER
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
83
|
+
# module GRPC
|
84
|
+
# extend MyLogger
|
85
|
+
# end
|
86
|
+
# ```
|
61
87
|
#
|
62
88
|
module Language
|
63
89
|
module V1beta2
|
64
90
|
end
|
65
91
|
end
|
66
92
|
end
|
67
|
-
end
|
93
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -18,9 +18,6 @@
|
|
18
18
|
# and updates to that file get reflected here through a refresh process.
|
19
19
|
# For the short term, the refresh process will only be runnable by Google
|
20
20
|
# engineers.
|
21
|
-
#
|
22
|
-
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
-
# merge preserves those additions if the generated source changes.
|
24
21
|
|
25
22
|
require "json"
|
26
23
|
require "pathname"
|
@@ -28,7 +25,7 @@ require "pathname"
|
|
28
25
|
require "google/gax"
|
29
26
|
|
30
27
|
require "google/cloud/language/v1beta2/language_service_pb"
|
31
|
-
require "google/cloud/language/credentials"
|
28
|
+
require "google/cloud/language/v1beta2/credentials"
|
32
29
|
|
33
30
|
module Google
|
34
31
|
module Cloud
|
@@ -48,6 +45,9 @@ module Google
|
|
48
45
|
# The default port of the service.
|
49
46
|
DEFAULT_SERVICE_PORT = 443
|
50
47
|
|
48
|
+
# The default set of gRPC interceptors.
|
49
|
+
GRPC_INTERCEPTORS = []
|
50
|
+
|
51
51
|
DEFAULT_TIMEOUT = 30
|
52
52
|
|
53
53
|
# The scopes needed to make gRPC calls to all of the methods defined in
|
@@ -56,6 +56,7 @@ module Google
|
|
56
56
|
"https://www.googleapis.com/auth/cloud-platform"
|
57
57
|
].freeze
|
58
58
|
|
59
|
+
|
59
60
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
60
61
|
# Provides the means for authenticating requests made by the client. This parameter can
|
61
62
|
# be many types.
|
@@ -80,16 +81,18 @@ module Google
|
|
80
81
|
# or the specified config is missing data points.
|
81
82
|
# @param timeout [Numeric]
|
82
83
|
# The default timeout, in seconds, for calls made through this client.
|
84
|
+
# @param metadata [Hash]
|
85
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
86
|
+
# @param exception_transformer [Proc]
|
87
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
88
|
+
# custom error handling.
|
83
89
|
def initialize \
|
84
|
-
service_path: SERVICE_ADDRESS,
|
85
|
-
port: DEFAULT_SERVICE_PORT,
|
86
|
-
channel: nil,
|
87
|
-
chan_creds: nil,
|
88
|
-
updater_proc: nil,
|
89
90
|
credentials: nil,
|
90
91
|
scopes: ALL_SCOPES,
|
91
92
|
client_config: {},
|
92
93
|
timeout: DEFAULT_TIMEOUT,
|
94
|
+
metadata: nil,
|
95
|
+
exception_transformer: nil,
|
93
96
|
lib_name: nil,
|
94
97
|
lib_version: ""
|
95
98
|
# These require statements are intentionally placed here to initialize
|
@@ -98,21 +101,10 @@ module Google
|
|
98
101
|
require "google/gax/grpc"
|
99
102
|
require "google/cloud/language/v1beta2/language_service_services_pb"
|
100
103
|
|
101
|
-
|
102
|
-
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
103
|
-
"on 2017/09/08"
|
104
|
-
credentials ||= channel
|
105
|
-
credentials ||= chan_creds
|
106
|
-
credentials ||= updater_proc
|
107
|
-
end
|
108
|
-
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
109
|
-
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
110
|
-
end
|
111
|
-
|
112
|
-
credentials ||= Google::Cloud::Language::Credentials.default
|
104
|
+
credentials ||= Google::Cloud::Language::V1beta2::Credentials.default
|
113
105
|
|
114
106
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
115
|
-
updater_proc = Google::Cloud::Language::Credentials.new(credentials).updater_proc
|
107
|
+
updater_proc = Google::Cloud::Language::V1beta2::Credentials.new(credentials).updater_proc
|
116
108
|
end
|
117
109
|
if credentials.is_a?(GRPC::Core::Channel)
|
118
110
|
channel = credentials
|
@@ -127,13 +119,16 @@ module Google
|
|
127
119
|
updater_proc = credentials.updater_proc
|
128
120
|
end
|
129
121
|
|
122
|
+
package_version = Gem.loaded_specs['google-cloud-language'].version.version
|
123
|
+
|
130
124
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
131
125
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
132
|
-
google_api_client << " gapic
|
126
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
133
127
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
134
128
|
google_api_client.freeze
|
135
129
|
|
136
130
|
headers = { :"x-goog-api-client" => google_api_client }
|
131
|
+
headers.merge!(metadata) unless metadata.nil?
|
137
132
|
client_config_file = Pathname.new(__dir__).join(
|
138
133
|
"language_service_client_config.json"
|
139
134
|
)
|
@@ -145,9 +140,14 @@ module Google
|
|
145
140
|
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
146
141
|
timeout,
|
147
142
|
errors: Google::Gax::Grpc::API_ERRORS,
|
148
|
-
|
143
|
+
metadata: headers
|
149
144
|
)
|
150
145
|
end
|
146
|
+
|
147
|
+
# Allow overriding the service path/port in subclasses.
|
148
|
+
service_path = self.class::SERVICE_ADDRESS
|
149
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
150
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
151
151
|
@language_service_stub = Google::Gax::Grpc.create_stub(
|
152
152
|
service_path,
|
153
153
|
port,
|
@@ -155,32 +155,39 @@ module Google
|
|
155
155
|
channel: channel,
|
156
156
|
updater_proc: updater_proc,
|
157
157
|
scopes: scopes,
|
158
|
+
interceptors: interceptors,
|
158
159
|
&Google::Cloud::Language::V1beta2::LanguageService::Stub.method(:new)
|
159
160
|
)
|
160
161
|
|
161
162
|
@analyze_sentiment = Google::Gax.create_api_call(
|
162
163
|
@language_service_stub.method(:analyze_sentiment),
|
163
|
-
defaults["analyze_sentiment"]
|
164
|
+
defaults["analyze_sentiment"],
|
165
|
+
exception_transformer: exception_transformer
|
164
166
|
)
|
165
167
|
@analyze_entities = Google::Gax.create_api_call(
|
166
168
|
@language_service_stub.method(:analyze_entities),
|
167
|
-
defaults["analyze_entities"]
|
169
|
+
defaults["analyze_entities"],
|
170
|
+
exception_transformer: exception_transformer
|
168
171
|
)
|
169
172
|
@analyze_entity_sentiment = Google::Gax.create_api_call(
|
170
173
|
@language_service_stub.method(:analyze_entity_sentiment),
|
171
|
-
defaults["analyze_entity_sentiment"]
|
174
|
+
defaults["analyze_entity_sentiment"],
|
175
|
+
exception_transformer: exception_transformer
|
172
176
|
)
|
173
177
|
@analyze_syntax = Google::Gax.create_api_call(
|
174
178
|
@language_service_stub.method(:analyze_syntax),
|
175
|
-
defaults["analyze_syntax"]
|
179
|
+
defaults["analyze_syntax"],
|
180
|
+
exception_transformer: exception_transformer
|
176
181
|
)
|
177
182
|
@classify_text = Google::Gax.create_api_call(
|
178
183
|
@language_service_stub.method(:classify_text),
|
179
|
-
defaults["classify_text"]
|
184
|
+
defaults["classify_text"],
|
185
|
+
exception_transformer: exception_transformer
|
180
186
|
)
|
181
187
|
@annotate_text = Google::Gax.create_api_call(
|
182
188
|
@language_service_stub.method(:annotate_text),
|
183
|
-
defaults["annotate_text"]
|
189
|
+
defaults["annotate_text"],
|
190
|
+
exception_transformer: exception_transformer
|
184
191
|
)
|
185
192
|
end
|
186
193
|
|
@@ -198,25 +205,31 @@ module Google
|
|
198
205
|
# @param options [Google::Gax::CallOptions]
|
199
206
|
# Overrides the default settings for this call, e.g, timeout,
|
200
207
|
# retries, etc.
|
208
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
209
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse]
|
210
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
201
211
|
# @return [Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse]
|
202
212
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
203
213
|
# @example
|
204
|
-
# require "google/cloud/language
|
214
|
+
# require "google/cloud/language"
|
205
215
|
#
|
206
|
-
# language_service_client = Google::Cloud::Language
|
216
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
217
|
+
#
|
218
|
+
# # TODO: Initialize +document+:
|
207
219
|
# document = {}
|
208
220
|
# response = language_service_client.analyze_sentiment(document)
|
209
221
|
|
210
222
|
def analyze_sentiment \
|
211
223
|
document,
|
212
224
|
encoding_type: nil,
|
213
|
-
options: nil
|
225
|
+
options: nil,
|
226
|
+
&block
|
214
227
|
req = {
|
215
228
|
document: document,
|
216
229
|
encoding_type: encoding_type
|
217
230
|
}.delete_if { |_, v| v.nil? }
|
218
231
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest)
|
219
|
-
@analyze_sentiment.call(req, options)
|
232
|
+
@analyze_sentiment.call(req, options, &block)
|
220
233
|
end
|
221
234
|
|
222
235
|
# Finds named entities (currently proper names and common nouns) in the text
|
@@ -232,25 +245,31 @@ module Google
|
|
232
245
|
# @param options [Google::Gax::CallOptions]
|
233
246
|
# Overrides the default settings for this call, e.g, timeout,
|
234
247
|
# retries, etc.
|
248
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
249
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse]
|
250
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
235
251
|
# @return [Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse]
|
236
252
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
237
253
|
# @example
|
238
|
-
# require "google/cloud/language
|
254
|
+
# require "google/cloud/language"
|
255
|
+
#
|
256
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
239
257
|
#
|
240
|
-
#
|
258
|
+
# # TODO: Initialize +document+:
|
241
259
|
# document = {}
|
242
260
|
# response = language_service_client.analyze_entities(document)
|
243
261
|
|
244
262
|
def analyze_entities \
|
245
263
|
document,
|
246
264
|
encoding_type: nil,
|
247
|
-
options: nil
|
265
|
+
options: nil,
|
266
|
+
&block
|
248
267
|
req = {
|
249
268
|
document: document,
|
250
269
|
encoding_type: encoding_type
|
251
270
|
}.delete_if { |_, v| v.nil? }
|
252
271
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest)
|
253
|
-
@analyze_entities.call(req, options)
|
272
|
+
@analyze_entities.call(req, options, &block)
|
254
273
|
end
|
255
274
|
|
256
275
|
# Finds entities, similar to {Google::Cloud::Language::V1beta2::LanguageService::AnalyzeEntities AnalyzeEntities} in the text and analyzes
|
@@ -265,25 +284,31 @@ module Google
|
|
265
284
|
# @param options [Google::Gax::CallOptions]
|
266
285
|
# Overrides the default settings for this call, e.g, timeout,
|
267
286
|
# retries, etc.
|
287
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
288
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse]
|
289
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
268
290
|
# @return [Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse]
|
269
291
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
270
292
|
# @example
|
271
|
-
# require "google/cloud/language
|
293
|
+
# require "google/cloud/language"
|
272
294
|
#
|
273
|
-
# language_service_client = Google::Cloud::Language
|
295
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
296
|
+
#
|
297
|
+
# # TODO: Initialize +document+:
|
274
298
|
# document = {}
|
275
299
|
# response = language_service_client.analyze_entity_sentiment(document)
|
276
300
|
|
277
301
|
def analyze_entity_sentiment \
|
278
302
|
document,
|
279
303
|
encoding_type: nil,
|
280
|
-
options: nil
|
304
|
+
options: nil,
|
305
|
+
&block
|
281
306
|
req = {
|
282
307
|
document: document,
|
283
308
|
encoding_type: encoding_type
|
284
309
|
}.delete_if { |_, v| v.nil? }
|
285
310
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest)
|
286
|
-
@analyze_entity_sentiment.call(req, options)
|
311
|
+
@analyze_entity_sentiment.call(req, options, &block)
|
287
312
|
end
|
288
313
|
|
289
314
|
# Analyzes the syntax of the text and provides sentence boundaries and
|
@@ -299,25 +324,31 @@ module Google
|
|
299
324
|
# @param options [Google::Gax::CallOptions]
|
300
325
|
# Overrides the default settings for this call, e.g, timeout,
|
301
326
|
# retries, etc.
|
327
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
328
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse]
|
329
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
302
330
|
# @return [Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse]
|
303
331
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
304
332
|
# @example
|
305
|
-
# require "google/cloud/language
|
333
|
+
# require "google/cloud/language"
|
334
|
+
#
|
335
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
306
336
|
#
|
307
|
-
#
|
337
|
+
# # TODO: Initialize +document+:
|
308
338
|
# document = {}
|
309
339
|
# response = language_service_client.analyze_syntax(document)
|
310
340
|
|
311
341
|
def analyze_syntax \
|
312
342
|
document,
|
313
343
|
encoding_type: nil,
|
314
|
-
options: nil
|
344
|
+
options: nil,
|
345
|
+
&block
|
315
346
|
req = {
|
316
347
|
document: document,
|
317
348
|
encoding_type: encoding_type
|
318
349
|
}.delete_if { |_, v| v.nil? }
|
319
350
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest)
|
320
|
-
@analyze_syntax.call(req, options)
|
351
|
+
@analyze_syntax.call(req, options, &block)
|
321
352
|
end
|
322
353
|
|
323
354
|
# Classifies a document into categories.
|
@@ -329,23 +360,29 @@ module Google
|
|
329
360
|
# @param options [Google::Gax::CallOptions]
|
330
361
|
# Overrides the default settings for this call, e.g, timeout,
|
331
362
|
# retries, etc.
|
363
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
364
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::ClassifyTextResponse]
|
365
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
332
366
|
# @return [Google::Cloud::Language::V1beta2::ClassifyTextResponse]
|
333
367
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
334
368
|
# @example
|
335
|
-
# require "google/cloud/language
|
369
|
+
# require "google/cloud/language"
|
336
370
|
#
|
337
|
-
# language_service_client = Google::Cloud::Language
|
371
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
372
|
+
#
|
373
|
+
# # TODO: Initialize +document+:
|
338
374
|
# document = {}
|
339
375
|
# response = language_service_client.classify_text(document)
|
340
376
|
|
341
377
|
def classify_text \
|
342
378
|
document,
|
343
|
-
options: nil
|
379
|
+
options: nil,
|
380
|
+
&block
|
344
381
|
req = {
|
345
382
|
document: document
|
346
383
|
}.delete_if { |_, v| v.nil? }
|
347
384
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::ClassifyTextRequest)
|
348
|
-
@classify_text.call(req, options)
|
385
|
+
@classify_text.call(req, options, &block)
|
349
386
|
end
|
350
387
|
|
351
388
|
# A convenience method that provides all syntax, sentiment, entity, and
|
@@ -364,13 +401,20 @@ module Google
|
|
364
401
|
# @param options [Google::Gax::CallOptions]
|
365
402
|
# Overrides the default settings for this call, e.g, timeout,
|
366
403
|
# retries, etc.
|
404
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
405
|
+
# @yieldparam result [Google::Cloud::Language::V1beta2::AnnotateTextResponse]
|
406
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
367
407
|
# @return [Google::Cloud::Language::V1beta2::AnnotateTextResponse]
|
368
408
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
369
409
|
# @example
|
370
|
-
# require "google/cloud/language
|
410
|
+
# require "google/cloud/language"
|
411
|
+
#
|
412
|
+
# language_service_client = Google::Cloud::Language.new(version: :v1beta2)
|
371
413
|
#
|
372
|
-
#
|
414
|
+
# # TODO: Initialize +document+:
|
373
415
|
# document = {}
|
416
|
+
#
|
417
|
+
# # TODO: Initialize +features+:
|
374
418
|
# features = {}
|
375
419
|
# response = language_service_client.annotate_text(document, features)
|
376
420
|
|
@@ -378,14 +422,15 @@ module Google
|
|
378
422
|
document,
|
379
423
|
features,
|
380
424
|
encoding_type: nil,
|
381
|
-
options: nil
|
425
|
+
options: nil,
|
426
|
+
&block
|
382
427
|
req = {
|
383
428
|
document: document,
|
384
429
|
features: features,
|
385
430
|
encoding_type: encoding_type
|
386
431
|
}.delete_if { |_, v| v.nil? }
|
387
432
|
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnnotateTextRequest)
|
388
|
-
@annotate_text.call(req, options)
|
433
|
+
@annotate_text.call(req, options, &block)
|
389
434
|
end
|
390
435
|
end
|
391
436
|
end
|