google-cloud-language 0.27.1 → 0.28.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 +5 -5
- data/.yardopts +2 -6
- data/LICENSE +1 -1
- data/README.md +35 -59
- data/lib/google/cloud/language.rb +81 -230
- data/lib/google/cloud/language/credentials.rb +9 -11
- data/lib/google/cloud/language/v1.rb +107 -0
- data/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb +108 -18
- data/lib/google/cloud/language/v1/doc/overview.rb +67 -0
- data/lib/google/cloud/language/v1/language_service_client.rb +157 -67
- data/lib/google/cloud/language/v1/language_service_client_config.json +10 -0
- data/lib/google/cloud/language/v1/language_service_pb.rb +34 -0
- data/lib/google/cloud/language/v1/language_service_services_pb.rb +5 -0
- data/lib/google/cloud/language/v1beta2.rb +107 -0
- data/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb +29 -0
- data/lib/google/cloud/language/v1beta2/doc/overview.rb +67 -0
- data/lib/google/cloud/language/v1beta2/language_service_client.rb +5 -6
- data/lib/google/cloud/language/v1beta2/language_service_pb.rb +6 -0
- metadata +24 -100
- data/lib/google-cloud-language.rb +0 -112
- data/lib/google/cloud/language/annotation.rb +0 -1084
- data/lib/google/cloud/language/convert.rb +0 -35
- data/lib/google/cloud/language/document.rb +0 -375
- data/lib/google/cloud/language/project.rb +0 -376
- data/lib/google/cloud/language/service.rb +0 -143
- data/lib/google/cloud/language/version.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 577cf57a9adac4e45b66f535d28a678748bf9b4641ff2f7cc395af122d4c16bb
|
4
|
+
data.tar.gz: 12920a68328d2168090dac303fc7d5ac3a1a46fa79ba91c05111b19a330676ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8130b0e8dc4cc3f5d9a9e0f43f57b403c673d1f60adc06600de84bbd6ddc7214673ae50f3ae8e5a6532669860661e355f8036233bd5e0e385c3c0cf03c5df5
|
7
|
+
data.tar.gz: df63b764ba60e4b7e84f89ba74bf0529918b8794a0ca5c69b339c1c7e2667cdb965b4e4a5f554cbb0f65148ab7947f04d51bffbd4c8a8bee1e93341241890a56
|
data/.yardopts
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
--no-private
|
2
|
-
--title=Google Cloud Language
|
3
|
-
--exclude
|
4
|
-
--exclude lib/google/cloud/language/v1/language_service_pb.rb
|
5
|
-
--exclude lib/google/cloud/language/v1/language_service_services_pb.rb
|
6
|
-
--exclude lib/google/cloud/language/v1beta2/language_service_pb.rb
|
7
|
-
--exclude lib/google/cloud/language/v1beta2/language_service_services_pb.rb
|
2
|
+
--title=Google Cloud Natural Language API
|
3
|
+
--exclude _pb\.rb$
|
8
4
|
--markup markdown
|
9
5
|
|
10
6
|
./lib/**/*.rb
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,72 +1,48 @@
|
|
1
|
-
# google-cloud-
|
1
|
+
# Ruby Client for Google Cloud Natural Language API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
2
2
|
|
3
|
-
[Google Cloud Natural Language API]
|
3
|
+
[Google Cloud Natural Language API][Product Documentation]:
|
4
|
+
Google Cloud Natural Language API provides natural language understanding
|
5
|
+
technologies to developers. Examples include sentiment analysis, entity
|
6
|
+
recognition, and text annotations.
|
7
|
+
- [Client Library Documentation][]
|
8
|
+
- [Product Documentation][]
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
- [google-cloud-language on RubyGems](https://rubygems.org/gems/google-cloud-language)
|
9
|
-
- [Google Cloud Natural Language API documentation](https://cloud.google.com/natural-language/docs)
|
10
|
+
*This release, 0.28.0, introduces breaking changes relative to the previous
|
11
|
+
release, 0.27.1. For more details and instructions to migrate your code, please
|
12
|
+
visit the [migration guide](https://cloud.google.com/natural-language/docs/ruby-client-migration).*
|
10
13
|
|
11
14
|
## Quick Start
|
15
|
+
In order to use this library, you first need to go through the following
|
16
|
+
steps:
|
17
|
+
|
18
|
+
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
19
|
+
2. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
|
20
|
+
3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
12
21
|
|
13
|
-
|
22
|
+
### Installation
|
23
|
+
```
|
14
24
|
$ gem install google-cloud-language
|
15
25
|
```
|
16
26
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/guides/authentication).
|
22
|
-
|
23
|
-
## Example
|
24
|
-
|
25
|
-
```ruby
|
27
|
+
### Preview
|
28
|
+
#### LanguageServiceClient
|
29
|
+
```rb
|
26
30
|
require "google/cloud/language"
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
document =
|
32
|
-
|
33
|
-
|
34
|
-
annotation.entities.count #=> 3
|
35
|
-
annotation.sentiment.score #=> 0.10000000149011612
|
36
|
-
annotation.sentiment.magnitude #=> 1.100000023841858
|
37
|
-
annotation.sentences.count #=> 2
|
38
|
-
annotation.tokens.count #=> 13
|
32
|
+
language_service_client = Google::Cloud::Language.new
|
33
|
+
content = "Hello, world!"
|
34
|
+
type = :PLAIN_TEXT
|
35
|
+
document = { content: content, type: type }
|
36
|
+
response = language_service_client.analyze_sentiment(document)
|
39
37
|
```
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
It is currently in major version zero (0.y.z), which means that anything may change at any time and the public API should not be considered stable.
|
50
|
-
|
51
|
-
### Lower-level (GAPIC) API versioning
|
52
|
-
|
53
|
-
The lower-level API support contained within this package is versioned separately to match its corresponding Google Cloud Platform service API version.
|
54
|
-
|
55
|
-
*Please note that in lower-level API support in this package, version `v1beta2` comes after version `v1`. The API version `v1beta2` contains new features that were not released in `v1`.*
|
56
|
-
|
57
|
-
## Contributing
|
58
|
-
|
59
|
-
Contributions to this library are always welcome and highly encouraged.
|
60
|
-
|
61
|
-
See the [Contributing Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/contributing) for more information on how to get started.
|
62
|
-
|
63
|
-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](../CODE_OF_CONDUCT.md) for more information.
|
64
|
-
|
65
|
-
## License
|
66
|
-
|
67
|
-
This library is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).
|
68
|
-
|
69
|
-
## Support
|
39
|
+
### Next Steps
|
40
|
+
- Read the [Client Library Documentation][] for Google Cloud Natural Language API
|
41
|
+
to see other available methods on the client.
|
42
|
+
- Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
|
43
|
+
to learn more about the product and see How-to Guides.
|
44
|
+
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
45
|
+
to see the full list of Cloud APIs that we cover.
|
70
46
|
|
71
|
-
|
72
|
-
|
47
|
+
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1
|
48
|
+
[Product Documentation]: https://cloud.google.com/language
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
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.
|
@@ -12,255 +12,106 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
|
16
|
-
require "
|
17
|
-
require "google/cloud/language/project"
|
15
|
+
require "google/gax"
|
16
|
+
require "pathname"
|
18
17
|
|
19
18
|
module Google
|
20
19
|
module Cloud
|
20
|
+
# rubocop:disable LineLength
|
21
|
+
|
21
22
|
##
|
22
|
-
# # Google Cloud Natural Language API
|
23
|
-
#
|
24
|
-
# Google Cloud Natural Language API reveals the structure and meaning of
|
25
|
-
# text by offering powerful machine learning models in an easy to use REST
|
26
|
-
# API. You can use it to extract information about people, places, events
|
27
|
-
# and much more, mentioned in text documents, news articles or blog posts.
|
28
|
-
# You can use it to understand sentiment about your product on social media
|
29
|
-
# or parse intent from customer conversations happening in a call center or
|
30
|
-
# a messaging app. You can analyze text uploaded in your request or
|
31
|
-
# integrate with your document storage on Google Cloud Storage. Combine the
|
32
|
-
# API with the Google Cloud Speech API and extract insights from audio
|
33
|
-
# conversations. Use with Vision API OCR to understand scanned documents.
|
34
|
-
# Extract entities and understand sentiments in multiple languages by
|
35
|
-
# translating text first with Cloud Translation API.
|
36
|
-
#
|
37
|
-
# For more information about Cloud Natural Language API, read the [Google
|
38
|
-
# Cloud Natural Language API
|
39
|
-
# Documentation](https://cloud.google.com/natural-language/docs/).
|
40
|
-
#
|
41
|
-
# The goal of google-cloud is to provide an API that is comfortable to
|
42
|
-
# Rubyists. Authentication is handled by {Google::Cloud#language}. You can
|
43
|
-
# provide the project and credential information to connect to the Cloud
|
44
|
-
# Natural Language API, or if you are running on Google Compute Engine this
|
45
|
-
# configuration is taken care of for you. You can read more about the
|
46
|
-
# options for connecting in the [Authentication
|
47
|
-
# Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
|
48
|
-
#
|
49
|
-
# ## Creating documents
|
50
|
-
#
|
51
|
-
# Use {Language::Project#document} to create documents for the Cloud Natural
|
52
|
-
# Language service. (The Cloud Natural Language API currently supports
|
53
|
-
# English, Spanish, and Japanese.)
|
54
|
-
#
|
55
|
-
# You can provide text or HTML content as a string:
|
56
|
-
#
|
57
|
-
# ```ruby
|
58
|
-
# require "google/cloud/language"
|
59
|
-
#
|
60
|
-
# language = Google::Cloud::Language.new
|
61
|
-
#
|
62
|
-
# document = language.document "It was the best of times, it was..."
|
63
|
-
# ```
|
64
|
-
#
|
65
|
-
# Or, you can pass a Google Cloud Storage URI for a text or HTML file:
|
66
|
-
#
|
67
|
-
# ```ruby
|
68
|
-
# require "google/cloud/language"
|
69
|
-
#
|
70
|
-
# language = Google::Cloud::Language.new
|
71
|
-
#
|
72
|
-
# document = language.document "gs://bucket-name/path/to/document"
|
73
|
-
# ```
|
74
|
-
#
|
75
|
-
# Or, you can initialize it with a Google Cloud Storage File object:
|
76
|
-
#
|
77
|
-
# ```ruby
|
78
|
-
# require "google/cloud/storage"
|
79
|
-
#
|
80
|
-
# storage = Google::Cloud::Storage.new
|
81
|
-
#
|
82
|
-
# bucket = storage.bucket "bucket-name"
|
83
|
-
# file = bucket.file "path/to/document"
|
84
|
-
#
|
85
|
-
# require "google/cloud/language"
|
86
|
-
#
|
87
|
-
# language = Google::Cloud::Language.new
|
88
|
-
#
|
89
|
-
# document = language.document file
|
90
|
-
# ```
|
91
|
-
#
|
92
|
-
# You can specify the format and language of the content:
|
93
|
-
#
|
94
|
-
# ```ruby
|
95
|
-
# require "google/cloud/language"
|
96
|
-
#
|
97
|
-
# language = Google::Cloud::Language.new
|
98
|
-
#
|
99
|
-
# document = language.document "<p>El viejo y el mar</p>",
|
100
|
-
# format: :html, language: "es"
|
101
|
-
# ```
|
102
|
-
#
|
103
|
-
# Creating a Document instance does not perform an API request.
|
104
|
-
#
|
105
|
-
# ## Annotating documents
|
106
|
-
#
|
107
|
-
# The instance methods on {Language::Document} invoke Cloud Natural
|
108
|
-
# Language's detection features individually. Each method call makes an API
|
109
|
-
# request. If you want to run multiple features in a single request, see
|
110
|
-
# the examples for {Language::Document#annotate}, below. Calling `annotate`
|
111
|
-
# with no arguments will perform **all** analysis features. Each feature
|
112
|
-
# is priced separately. See [Pricing](https://cloud.google.com/natural-language/pricing)
|
113
|
-
# for details.
|
23
|
+
# # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
114
24
|
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
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][]
|
120
30
|
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
# language = Google::Cloud::Language.new
|
125
|
-
#
|
126
|
-
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
127
|
-
# document = language.document content
|
128
|
-
# sentiment = document.sentiment # API call
|
129
|
-
#
|
130
|
-
# sentiment.score #=> 0.10000000149011612
|
131
|
-
# sentiment.magnitude #=> 1.100000023841858
|
132
|
-
# ```
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
133
34
|
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
# {Language::Document#entities} method.
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
|
37
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
138
38
|
#
|
139
|
-
#
|
39
|
+
# ### Preview
|
40
|
+
# #### LanguageServiceClient
|
41
|
+
# ```rb
|
140
42
|
# require "google/cloud/language"
|
141
43
|
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
# document =
|
146
|
-
#
|
147
|
-
#
|
148
|
-
# entities.count #=> 3
|
149
|
-
# entities.first.name #=> "Star Wars"
|
150
|
-
# entities.first.type #=> :WORK_OF_ART
|
151
|
-
# entities.first.mid #=> "/m/06mmr"
|
152
|
-
# entities.first.wikipedia_url #=> "http://en.wikipedia.org/wiki/Star_Wars"
|
44
|
+
# language_service_client = Google::Cloud::Language.new
|
45
|
+
# content = "Hello, world!"
|
46
|
+
# type = :PLAIN_TEXT
|
47
|
+
# document = { content: content, type: type }
|
48
|
+
# response = language_service_client.analyze_sentiment(document)
|
153
49
|
# ```
|
154
50
|
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
# ```ruby
|
161
|
-
# require "google/cloud/language"
|
162
|
-
#
|
163
|
-
# language = Google::Cloud::Language.new
|
51
|
+
# ### Next Steps
|
52
|
+
# - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
|
53
|
+
# to learn more about the product and see How-to Guides.
|
54
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
55
|
+
# to see the full list of Cloud APIs that we cover.
|
164
56
|
#
|
165
|
-
#
|
166
|
-
# document = language.document content
|
167
|
-
# syntax = document.syntax # API call
|
168
|
-
#
|
169
|
-
# syntax.sentences.count #=> 2
|
170
|
-
# syntax.tokens.count #=> 13
|
171
|
-
# ```
|
172
|
-
#
|
173
|
-
# To run multiple features on a document in a single request, pass the flag
|
174
|
-
# for each desired feature to {Language::Document#annotate}:
|
175
|
-
#
|
176
|
-
# ```ruby
|
177
|
-
# require "google/cloud/language"
|
178
|
-
#
|
179
|
-
# language = Google::Cloud::Language.new
|
180
|
-
#
|
181
|
-
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
182
|
-
# document = language.document content
|
183
|
-
# annotation = document.annotate entities: true, syntax: true
|
184
|
-
#
|
185
|
-
# annotation.entities.count #=> 3
|
186
|
-
# annotation.sentences.count #=> 2
|
187
|
-
# annotation.tokens.count #=> 13
|
188
|
-
# ```
|
57
|
+
# [Product Documentation]: https://cloud.google.com/language
|
189
58
|
#
|
190
|
-
# Or, simply call {Language::Document#annotate} with no arguments to process
|
191
|
-
# the document with **all** features:
|
192
|
-
#
|
193
|
-
# ```ruby
|
194
|
-
# require "google/cloud/language"
|
195
|
-
#
|
196
|
-
# language = Google::Cloud::Language.new
|
197
|
-
#
|
198
|
-
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
199
|
-
# document = language.document content
|
200
|
-
# annotation = document.annotate
|
201
|
-
#
|
202
|
-
# annotation.sentiment.score #=> 0.10000000149011612
|
203
|
-
# annotation.sentiment.magnitude #=> 1.100000023841858
|
204
|
-
# annotation.entities.count #=> 3
|
205
|
-
# annotation.sentences.count #=> 2
|
206
|
-
# annotation.tokens.count #=> 13
|
207
|
-
# ```
|
208
59
|
#
|
209
60
|
module Language
|
61
|
+
# rubocop:enable LineLength
|
62
|
+
|
63
|
+
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("language"))
|
64
|
+
|
65
|
+
AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
|
66
|
+
.select { |file| File.directory?(file) }
|
67
|
+
.select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
|
68
|
+
.select { |dir| File.exist?(dir + ".rb") }
|
69
|
+
.map { |dir| File.basename(dir) }
|
70
|
+
|
210
71
|
##
|
211
|
-
#
|
212
|
-
#
|
72
|
+
# Provides text analysis operations such as sentiment analysis and entity
|
73
|
+
# recognition.
|
213
74
|
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
def self.new project: nil, keyfile: nil, scope: nil, timeout: nil,
|
247
|
-
client_config: nil
|
248
|
-
project ||= Google::Cloud::Language::Project.default_project
|
249
|
-
project = project.to_s # Always cast to a string
|
250
|
-
fail ArgumentError, "project is missing" if project.empty?
|
251
|
-
|
252
|
-
if keyfile.nil?
|
253
|
-
credentials = Google::Cloud::Language::Credentials.default(
|
254
|
-
scope: scope)
|
255
|
-
else
|
256
|
-
credentials = Google::Cloud::Language::Credentials.new(
|
257
|
-
keyfile, scope: scope)
|
75
|
+
# @param version [Symbol, String]
|
76
|
+
# The major version of the service to be used. By default :v1
|
77
|
+
# is used.
|
78
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
79
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
80
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
81
|
+
# be many types.
|
82
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
83
|
+
# authenticating requests made by this client.
|
84
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
85
|
+
# credentials for this client.
|
86
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
87
|
+
# credentials for this client.
|
88
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
89
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
90
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
91
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
92
|
+
# metadata for requests, generally, to give OAuth credentials.
|
93
|
+
# @param scopes [Array<String>]
|
94
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
95
|
+
# an updater_proc is supplied.
|
96
|
+
# @param client_config [Hash]
|
97
|
+
# A Hash for call options for each method. See
|
98
|
+
# Google::Gax#construct_settings for the structure of
|
99
|
+
# this data. Falls back to the default config if not specified
|
100
|
+
# or the specified config is missing data points.
|
101
|
+
# @param timeout [Numeric]
|
102
|
+
# The default timeout, in seconds, for calls made through this client.
|
103
|
+
def self.new(*args, version: :v1, **kwargs)
|
104
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
105
|
+
raise "The version: #{version} is not available. The available versions " \
|
106
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
258
107
|
end
|
259
108
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
109
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
110
|
+
version_module = Google::Cloud::Language
|
111
|
+
.constants
|
112
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
113
|
+
.first
|
114
|
+
Google::Cloud::Language.const_get(version_module).new(*args, **kwargs)
|
264
115
|
end
|
265
116
|
end
|
266
117
|
end
|