google-apis-language_v2 0.1.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 +7 -0
- data/.yardopts +13 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.md +202 -0
- data/OVERVIEW.md +96 -0
- data/lib/google/apis/language_v2/classes.rb +675 -0
- data/lib/google/apis/language_v2/gem_version.rb +28 -0
- data/lib/google/apis/language_v2/representations.rb +333 -0
- data/lib/google/apis/language_v2/service.rb +215 -0
- data/lib/google/apis/language_v2.rb +41 -0
- data/lib/google-apis-language_v2.rb +15 -0
- metadata +82 -0
@@ -0,0 +1,675 @@
|
|
1
|
+
# Copyright 2020 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
|
+
# http://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 'date'
|
16
|
+
require 'google/apis/core/base_service'
|
17
|
+
require 'google/apis/core/json_representation'
|
18
|
+
require 'google/apis/core/hashable'
|
19
|
+
require 'google/apis/errors'
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Apis
|
23
|
+
module LanguageV2
|
24
|
+
|
25
|
+
# The entity analysis request message.
|
26
|
+
class AnalyzeEntitiesRequest
|
27
|
+
include Google::Apis::Core::Hashable
|
28
|
+
|
29
|
+
# Represents the input to API methods.
|
30
|
+
# Corresponds to the JSON property `document`
|
31
|
+
# @return [Google::Apis::LanguageV2::Document]
|
32
|
+
attr_accessor :document
|
33
|
+
|
34
|
+
# The encoding type used by the API to calculate offsets.
|
35
|
+
# Corresponds to the JSON property `encodingType`
|
36
|
+
# @return [String]
|
37
|
+
attr_accessor :encoding_type
|
38
|
+
|
39
|
+
def initialize(**args)
|
40
|
+
update!(**args)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Update properties of this object
|
44
|
+
def update!(**args)
|
45
|
+
@document = args[:document] if args.key?(:document)
|
46
|
+
@encoding_type = args[:encoding_type] if args.key?(:encoding_type)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# The entity analysis response message.
|
51
|
+
class AnalyzeEntitiesResponse
|
52
|
+
include Google::Apis::Core::Hashable
|
53
|
+
|
54
|
+
# The recognized entities in the input document.
|
55
|
+
# Corresponds to the JSON property `entities`
|
56
|
+
# @return [Array<Google::Apis::LanguageV2::Entity>]
|
57
|
+
attr_accessor :entities
|
58
|
+
|
59
|
+
# The language of the text, which will be the same as the language specified in
|
60
|
+
# the request or, if not specified, the automatically-detected language. See
|
61
|
+
# Document.language field for more details.
|
62
|
+
# Corresponds to the JSON property `languageCode`
|
63
|
+
# @return [String]
|
64
|
+
attr_accessor :language_code
|
65
|
+
|
66
|
+
# Whether the language is officially supported. The API may still return a
|
67
|
+
# response when the language is not supported, but it is on a best effort basis.
|
68
|
+
# Corresponds to the JSON property `languageSupported`
|
69
|
+
# @return [Boolean]
|
70
|
+
attr_accessor :language_supported
|
71
|
+
alias_method :language_supported?, :language_supported
|
72
|
+
|
73
|
+
def initialize(**args)
|
74
|
+
update!(**args)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Update properties of this object
|
78
|
+
def update!(**args)
|
79
|
+
@entities = args[:entities] if args.key?(:entities)
|
80
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
81
|
+
@language_supported = args[:language_supported] if args.key?(:language_supported)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# The sentiment analysis request message.
|
86
|
+
class AnalyzeSentimentRequest
|
87
|
+
include Google::Apis::Core::Hashable
|
88
|
+
|
89
|
+
# Represents the input to API methods.
|
90
|
+
# Corresponds to the JSON property `document`
|
91
|
+
# @return [Google::Apis::LanguageV2::Document]
|
92
|
+
attr_accessor :document
|
93
|
+
|
94
|
+
# The encoding type used by the API to calculate sentence offsets.
|
95
|
+
# Corresponds to the JSON property `encodingType`
|
96
|
+
# @return [String]
|
97
|
+
attr_accessor :encoding_type
|
98
|
+
|
99
|
+
def initialize(**args)
|
100
|
+
update!(**args)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Update properties of this object
|
104
|
+
def update!(**args)
|
105
|
+
@document = args[:document] if args.key?(:document)
|
106
|
+
@encoding_type = args[:encoding_type] if args.key?(:encoding_type)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# The sentiment analysis response message.
|
111
|
+
class AnalyzeSentimentResponse
|
112
|
+
include Google::Apis::Core::Hashable
|
113
|
+
|
114
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
115
|
+
# Corresponds to the JSON property `documentSentiment`
|
116
|
+
# @return [Google::Apis::LanguageV2::Sentiment]
|
117
|
+
attr_accessor :document_sentiment
|
118
|
+
|
119
|
+
# The language of the text, which will be the same as the language specified in
|
120
|
+
# the request or, if not specified, the automatically-detected language. See
|
121
|
+
# Document.language field for more details.
|
122
|
+
# Corresponds to the JSON property `languageCode`
|
123
|
+
# @return [String]
|
124
|
+
attr_accessor :language_code
|
125
|
+
|
126
|
+
# Whether the language is officially supported. The API may still return a
|
127
|
+
# response when the language is not supported, but it is on a best effort basis.
|
128
|
+
# Corresponds to the JSON property `languageSupported`
|
129
|
+
# @return [Boolean]
|
130
|
+
attr_accessor :language_supported
|
131
|
+
alias_method :language_supported?, :language_supported
|
132
|
+
|
133
|
+
# The sentiment for all the sentences in the document.
|
134
|
+
# Corresponds to the JSON property `sentences`
|
135
|
+
# @return [Array<Google::Apis::LanguageV2::Sentence>]
|
136
|
+
attr_accessor :sentences
|
137
|
+
|
138
|
+
def initialize(**args)
|
139
|
+
update!(**args)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Update properties of this object
|
143
|
+
def update!(**args)
|
144
|
+
@document_sentiment = args[:document_sentiment] if args.key?(:document_sentiment)
|
145
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
146
|
+
@language_supported = args[:language_supported] if args.key?(:language_supported)
|
147
|
+
@sentences = args[:sentences] if args.key?(:sentences)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# The request message for the text annotation API, which can perform multiple
|
152
|
+
# analysis types in one call.
|
153
|
+
class AnnotateTextRequest
|
154
|
+
include Google::Apis::Core::Hashable
|
155
|
+
|
156
|
+
# Represents the input to API methods.
|
157
|
+
# Corresponds to the JSON property `document`
|
158
|
+
# @return [Google::Apis::LanguageV2::Document]
|
159
|
+
attr_accessor :document
|
160
|
+
|
161
|
+
# The encoding type used by the API to calculate offsets.
|
162
|
+
# Corresponds to the JSON property `encodingType`
|
163
|
+
# @return [String]
|
164
|
+
attr_accessor :encoding_type
|
165
|
+
|
166
|
+
# All available features. Setting each one to true will enable that specific
|
167
|
+
# analysis for the input.
|
168
|
+
# Corresponds to the JSON property `features`
|
169
|
+
# @return [Google::Apis::LanguageV2::Features]
|
170
|
+
attr_accessor :features
|
171
|
+
|
172
|
+
def initialize(**args)
|
173
|
+
update!(**args)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Update properties of this object
|
177
|
+
def update!(**args)
|
178
|
+
@document = args[:document] if args.key?(:document)
|
179
|
+
@encoding_type = args[:encoding_type] if args.key?(:encoding_type)
|
180
|
+
@features = args[:features] if args.key?(:features)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# The text annotations response message.
|
185
|
+
class AnnotateTextResponse
|
186
|
+
include Google::Apis::Core::Hashable
|
187
|
+
|
188
|
+
# Categories identified in the input document.
|
189
|
+
# Corresponds to the JSON property `categories`
|
190
|
+
# @return [Array<Google::Apis::LanguageV2::ClassificationCategory>]
|
191
|
+
attr_accessor :categories
|
192
|
+
|
193
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
194
|
+
# Corresponds to the JSON property `documentSentiment`
|
195
|
+
# @return [Google::Apis::LanguageV2::Sentiment]
|
196
|
+
attr_accessor :document_sentiment
|
197
|
+
|
198
|
+
# Entities, along with their semantic information, in the input document.
|
199
|
+
# Populated if the user enables AnnotateTextRequest.Features.extract_entities or
|
200
|
+
# AnnotateTextRequest.Features.extract_entity_sentiment.
|
201
|
+
# Corresponds to the JSON property `entities`
|
202
|
+
# @return [Array<Google::Apis::LanguageV2::Entity>]
|
203
|
+
attr_accessor :entities
|
204
|
+
|
205
|
+
# The language of the text, which will be the same as the language specified in
|
206
|
+
# the request or, if not specified, the automatically-detected language. See
|
207
|
+
# Document.language field for more details.
|
208
|
+
# Corresponds to the JSON property `languageCode`
|
209
|
+
# @return [String]
|
210
|
+
attr_accessor :language_code
|
211
|
+
|
212
|
+
# Whether the language is officially supported by all requested features. The
|
213
|
+
# API may still return a response when the language is not supported, but it is
|
214
|
+
# on a best effort basis.
|
215
|
+
# Corresponds to the JSON property `languageSupported`
|
216
|
+
# @return [Boolean]
|
217
|
+
attr_accessor :language_supported
|
218
|
+
alias_method :language_supported?, :language_supported
|
219
|
+
|
220
|
+
# Harmful and sensitive categories identified in the input document.
|
221
|
+
# Corresponds to the JSON property `moderationCategories`
|
222
|
+
# @return [Array<Google::Apis::LanguageV2::ClassificationCategory>]
|
223
|
+
attr_accessor :moderation_categories
|
224
|
+
|
225
|
+
# Sentences in the input document. Populated if the user enables
|
226
|
+
# AnnotateTextRequest.Features.extract_document_sentiment.
|
227
|
+
# Corresponds to the JSON property `sentences`
|
228
|
+
# @return [Array<Google::Apis::LanguageV2::Sentence>]
|
229
|
+
attr_accessor :sentences
|
230
|
+
|
231
|
+
def initialize(**args)
|
232
|
+
update!(**args)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Update properties of this object
|
236
|
+
def update!(**args)
|
237
|
+
@categories = args[:categories] if args.key?(:categories)
|
238
|
+
@document_sentiment = args[:document_sentiment] if args.key?(:document_sentiment)
|
239
|
+
@entities = args[:entities] if args.key?(:entities)
|
240
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
241
|
+
@language_supported = args[:language_supported] if args.key?(:language_supported)
|
242
|
+
@moderation_categories = args[:moderation_categories] if args.key?(:moderation_categories)
|
243
|
+
@sentences = args[:sentences] if args.key?(:sentences)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# Represents a category returned from the text classifier.
|
248
|
+
class ClassificationCategory
|
249
|
+
include Google::Apis::Core::Hashable
|
250
|
+
|
251
|
+
# The classifier's confidence of the category. Number represents how certain the
|
252
|
+
# classifier is that this category represents the given text.
|
253
|
+
# Corresponds to the JSON property `confidence`
|
254
|
+
# @return [Float]
|
255
|
+
attr_accessor :confidence
|
256
|
+
|
257
|
+
# The name of the category representing the document.
|
258
|
+
# Corresponds to the JSON property `name`
|
259
|
+
# @return [String]
|
260
|
+
attr_accessor :name
|
261
|
+
|
262
|
+
def initialize(**args)
|
263
|
+
update!(**args)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Update properties of this object
|
267
|
+
def update!(**args)
|
268
|
+
@confidence = args[:confidence] if args.key?(:confidence)
|
269
|
+
@name = args[:name] if args.key?(:name)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
# The document classification request message.
|
274
|
+
class ClassifyTextRequest
|
275
|
+
include Google::Apis::Core::Hashable
|
276
|
+
|
277
|
+
# Represents the input to API methods.
|
278
|
+
# Corresponds to the JSON property `document`
|
279
|
+
# @return [Google::Apis::LanguageV2::Document]
|
280
|
+
attr_accessor :document
|
281
|
+
|
282
|
+
def initialize(**args)
|
283
|
+
update!(**args)
|
284
|
+
end
|
285
|
+
|
286
|
+
# Update properties of this object
|
287
|
+
def update!(**args)
|
288
|
+
@document = args[:document] if args.key?(:document)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# The document classification response message.
|
293
|
+
class ClassifyTextResponse
|
294
|
+
include Google::Apis::Core::Hashable
|
295
|
+
|
296
|
+
# Categories representing the input document.
|
297
|
+
# Corresponds to the JSON property `categories`
|
298
|
+
# @return [Array<Google::Apis::LanguageV2::ClassificationCategory>]
|
299
|
+
attr_accessor :categories
|
300
|
+
|
301
|
+
# The language of the text, which will be the same as the language specified in
|
302
|
+
# the request or, if not specified, the automatically-detected language. See
|
303
|
+
# Document.language field for more details.
|
304
|
+
# Corresponds to the JSON property `languageCode`
|
305
|
+
# @return [String]
|
306
|
+
attr_accessor :language_code
|
307
|
+
|
308
|
+
# Whether the language is officially supported. The API may still return a
|
309
|
+
# response when the language is not supported, but it is on a best effort basis.
|
310
|
+
# Corresponds to the JSON property `languageSupported`
|
311
|
+
# @return [Boolean]
|
312
|
+
attr_accessor :language_supported
|
313
|
+
alias_method :language_supported?, :language_supported
|
314
|
+
|
315
|
+
def initialize(**args)
|
316
|
+
update!(**args)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Update properties of this object
|
320
|
+
def update!(**args)
|
321
|
+
@categories = args[:categories] if args.key?(:categories)
|
322
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
323
|
+
@language_supported = args[:language_supported] if args.key?(:language_supported)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
# Represents the input to API methods.
|
328
|
+
class Document
|
329
|
+
include Google::Apis::Core::Hashable
|
330
|
+
|
331
|
+
# The content of the input in string format. Cloud audit logging exempt since it
|
332
|
+
# is based on user data.
|
333
|
+
# Corresponds to the JSON property `content`
|
334
|
+
# @return [String]
|
335
|
+
attr_accessor :content
|
336
|
+
|
337
|
+
# The Google Cloud Storage URI where the file content is located. This URI must
|
338
|
+
# be of the form: gs://bucket_name/object_name. For more details, see https://
|
339
|
+
# cloud.google.com/storage/docs/reference-uris. NOTE: Cloud Storage object
|
340
|
+
# versioning is not supported.
|
341
|
+
# Corresponds to the JSON property `gcsContentUri`
|
342
|
+
# @return [String]
|
343
|
+
attr_accessor :gcs_content_uri
|
344
|
+
|
345
|
+
# Optional. The language of the document (if not specified, the language is
|
346
|
+
# automatically detected). Both ISO and BCP-47 language codes are accepted. [
|
347
|
+
# Language Support](https://cloud.google.com/natural-language/docs/languages)
|
348
|
+
# lists currently supported languages for each API method. If the language (
|
349
|
+
# either specified by the caller or automatically detected) is not supported by
|
350
|
+
# the called API method, an `INVALID_ARGUMENT` error is returned.
|
351
|
+
# Corresponds to the JSON property `languageCode`
|
352
|
+
# @return [String]
|
353
|
+
attr_accessor :language_code
|
354
|
+
|
355
|
+
# Required. If the type is not set or is `TYPE_UNSPECIFIED`, returns an `
|
356
|
+
# INVALID_ARGUMENT` error.
|
357
|
+
# Corresponds to the JSON property `type`
|
358
|
+
# @return [String]
|
359
|
+
attr_accessor :type
|
360
|
+
|
361
|
+
def initialize(**args)
|
362
|
+
update!(**args)
|
363
|
+
end
|
364
|
+
|
365
|
+
# Update properties of this object
|
366
|
+
def update!(**args)
|
367
|
+
@content = args[:content] if args.key?(:content)
|
368
|
+
@gcs_content_uri = args[:gcs_content_uri] if args.key?(:gcs_content_uri)
|
369
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
370
|
+
@type = args[:type] if args.key?(:type)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
# Represents a phrase in the text that is a known entity, such as a person, an
|
375
|
+
# organization, or location. The API associates information, such as probability
|
376
|
+
# and mentions, with entities.
|
377
|
+
class Entity
|
378
|
+
include Google::Apis::Core::Hashable
|
379
|
+
|
380
|
+
# The mentions of this entity in the input document. The API currently supports
|
381
|
+
# proper noun mentions.
|
382
|
+
# Corresponds to the JSON property `mentions`
|
383
|
+
# @return [Array<Google::Apis::LanguageV2::EntityMention>]
|
384
|
+
attr_accessor :mentions
|
385
|
+
|
386
|
+
# Metadata associated with the entity. For most entity types, the metadata is a
|
387
|
+
# Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`), if they are
|
388
|
+
# available. For the metadata associated with other entity types, see the Type
|
389
|
+
# table below.
|
390
|
+
# Corresponds to the JSON property `metadata`
|
391
|
+
# @return [Hash<String,String>]
|
392
|
+
attr_accessor :metadata
|
393
|
+
|
394
|
+
# The representative name for the entity.
|
395
|
+
# Corresponds to the JSON property `name`
|
396
|
+
# @return [String]
|
397
|
+
attr_accessor :name
|
398
|
+
|
399
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
400
|
+
# Corresponds to the JSON property `sentiment`
|
401
|
+
# @return [Google::Apis::LanguageV2::Sentiment]
|
402
|
+
attr_accessor :sentiment
|
403
|
+
|
404
|
+
# The entity type.
|
405
|
+
# Corresponds to the JSON property `type`
|
406
|
+
# @return [String]
|
407
|
+
attr_accessor :type
|
408
|
+
|
409
|
+
def initialize(**args)
|
410
|
+
update!(**args)
|
411
|
+
end
|
412
|
+
|
413
|
+
# Update properties of this object
|
414
|
+
def update!(**args)
|
415
|
+
@mentions = args[:mentions] if args.key?(:mentions)
|
416
|
+
@metadata = args[:metadata] if args.key?(:metadata)
|
417
|
+
@name = args[:name] if args.key?(:name)
|
418
|
+
@sentiment = args[:sentiment] if args.key?(:sentiment)
|
419
|
+
@type = args[:type] if args.key?(:type)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
# Represents a mention for an entity in the text. Currently, proper noun
|
424
|
+
# mentions are supported.
|
425
|
+
class EntityMention
|
426
|
+
include Google::Apis::Core::Hashable
|
427
|
+
|
428
|
+
# Probability score associated with the entity. The score shows the probability
|
429
|
+
# of the entity mention being the entity type. The score is in (0, 1] range.
|
430
|
+
# Corresponds to the JSON property `probability`
|
431
|
+
# @return [Float]
|
432
|
+
attr_accessor :probability
|
433
|
+
|
434
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
435
|
+
# Corresponds to the JSON property `sentiment`
|
436
|
+
# @return [Google::Apis::LanguageV2::Sentiment]
|
437
|
+
attr_accessor :sentiment
|
438
|
+
|
439
|
+
# Represents a text span in the input document.
|
440
|
+
# Corresponds to the JSON property `text`
|
441
|
+
# @return [Google::Apis::LanguageV2::TextSpan]
|
442
|
+
attr_accessor :text
|
443
|
+
|
444
|
+
# The type of the entity mention.
|
445
|
+
# Corresponds to the JSON property `type`
|
446
|
+
# @return [String]
|
447
|
+
attr_accessor :type
|
448
|
+
|
449
|
+
def initialize(**args)
|
450
|
+
update!(**args)
|
451
|
+
end
|
452
|
+
|
453
|
+
# Update properties of this object
|
454
|
+
def update!(**args)
|
455
|
+
@probability = args[:probability] if args.key?(:probability)
|
456
|
+
@sentiment = args[:sentiment] if args.key?(:sentiment)
|
457
|
+
@text = args[:text] if args.key?(:text)
|
458
|
+
@type = args[:type] if args.key?(:type)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
# All available features. Setting each one to true will enable that specific
|
463
|
+
# analysis for the input.
|
464
|
+
class Features
|
465
|
+
include Google::Apis::Core::Hashable
|
466
|
+
|
467
|
+
# Optional. Classify the full document into categories.
|
468
|
+
# Corresponds to the JSON property `classifyText`
|
469
|
+
# @return [Boolean]
|
470
|
+
attr_accessor :classify_text
|
471
|
+
alias_method :classify_text?, :classify_text
|
472
|
+
|
473
|
+
# Optional. Extract document-level sentiment.
|
474
|
+
# Corresponds to the JSON property `extractDocumentSentiment`
|
475
|
+
# @return [Boolean]
|
476
|
+
attr_accessor :extract_document_sentiment
|
477
|
+
alias_method :extract_document_sentiment?, :extract_document_sentiment
|
478
|
+
|
479
|
+
# Optional. Extract entities.
|
480
|
+
# Corresponds to the JSON property `extractEntities`
|
481
|
+
# @return [Boolean]
|
482
|
+
attr_accessor :extract_entities
|
483
|
+
alias_method :extract_entities?, :extract_entities
|
484
|
+
|
485
|
+
# Optional. Moderate the document for harmful and sensitive categories.
|
486
|
+
# Corresponds to the JSON property `moderateText`
|
487
|
+
# @return [Boolean]
|
488
|
+
attr_accessor :moderate_text
|
489
|
+
alias_method :moderate_text?, :moderate_text
|
490
|
+
|
491
|
+
def initialize(**args)
|
492
|
+
update!(**args)
|
493
|
+
end
|
494
|
+
|
495
|
+
# Update properties of this object
|
496
|
+
def update!(**args)
|
497
|
+
@classify_text = args[:classify_text] if args.key?(:classify_text)
|
498
|
+
@extract_document_sentiment = args[:extract_document_sentiment] if args.key?(:extract_document_sentiment)
|
499
|
+
@extract_entities = args[:extract_entities] if args.key?(:extract_entities)
|
500
|
+
@moderate_text = args[:moderate_text] if args.key?(:moderate_text)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
# The document moderation request message.
|
505
|
+
class ModerateTextRequest
|
506
|
+
include Google::Apis::Core::Hashable
|
507
|
+
|
508
|
+
# Represents the input to API methods.
|
509
|
+
# Corresponds to the JSON property `document`
|
510
|
+
# @return [Google::Apis::LanguageV2::Document]
|
511
|
+
attr_accessor :document
|
512
|
+
|
513
|
+
def initialize(**args)
|
514
|
+
update!(**args)
|
515
|
+
end
|
516
|
+
|
517
|
+
# Update properties of this object
|
518
|
+
def update!(**args)
|
519
|
+
@document = args[:document] if args.key?(:document)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
# The document moderation response message.
|
524
|
+
class ModerateTextResponse
|
525
|
+
include Google::Apis::Core::Hashable
|
526
|
+
|
527
|
+
# The language of the text, which will be the same as the language specified in
|
528
|
+
# the request or, if not specified, the automatically-detected language. See
|
529
|
+
# Document.language field for more details.
|
530
|
+
# Corresponds to the JSON property `languageCode`
|
531
|
+
# @return [String]
|
532
|
+
attr_accessor :language_code
|
533
|
+
|
534
|
+
# Whether the language is officially supported. The API may still return a
|
535
|
+
# response when the language is not supported, but it is on a best effort basis.
|
536
|
+
# Corresponds to the JSON property `languageSupported`
|
537
|
+
# @return [Boolean]
|
538
|
+
attr_accessor :language_supported
|
539
|
+
alias_method :language_supported?, :language_supported
|
540
|
+
|
541
|
+
# Harmful and sensitive categories representing the input document.
|
542
|
+
# Corresponds to the JSON property `moderationCategories`
|
543
|
+
# @return [Array<Google::Apis::LanguageV2::ClassificationCategory>]
|
544
|
+
attr_accessor :moderation_categories
|
545
|
+
|
546
|
+
def initialize(**args)
|
547
|
+
update!(**args)
|
548
|
+
end
|
549
|
+
|
550
|
+
# Update properties of this object
|
551
|
+
def update!(**args)
|
552
|
+
@language_code = args[:language_code] if args.key?(:language_code)
|
553
|
+
@language_supported = args[:language_supported] if args.key?(:language_supported)
|
554
|
+
@moderation_categories = args[:moderation_categories] if args.key?(:moderation_categories)
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
# Represents a sentence in the input document.
|
559
|
+
class Sentence
|
560
|
+
include Google::Apis::Core::Hashable
|
561
|
+
|
562
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
563
|
+
# Corresponds to the JSON property `sentiment`
|
564
|
+
# @return [Google::Apis::LanguageV2::Sentiment]
|
565
|
+
attr_accessor :sentiment
|
566
|
+
|
567
|
+
# Represents a text span in the input document.
|
568
|
+
# Corresponds to the JSON property `text`
|
569
|
+
# @return [Google::Apis::LanguageV2::TextSpan]
|
570
|
+
attr_accessor :text
|
571
|
+
|
572
|
+
def initialize(**args)
|
573
|
+
update!(**args)
|
574
|
+
end
|
575
|
+
|
576
|
+
# Update properties of this object
|
577
|
+
def update!(**args)
|
578
|
+
@sentiment = args[:sentiment] if args.key?(:sentiment)
|
579
|
+
@text = args[:text] if args.key?(:text)
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
# Represents the feeling associated with the entire text or entities in the text.
|
584
|
+
class Sentiment
|
585
|
+
include Google::Apis::Core::Hashable
|
586
|
+
|
587
|
+
# A non-negative number in the [0, +inf) range, which represents the absolute
|
588
|
+
# magnitude of sentiment regardless of score (positive or negative).
|
589
|
+
# Corresponds to the JSON property `magnitude`
|
590
|
+
# @return [Float]
|
591
|
+
attr_accessor :magnitude
|
592
|
+
|
593
|
+
# Sentiment score between -1.0 (negative sentiment) and 1.0 (positive sentiment).
|
594
|
+
# Corresponds to the JSON property `score`
|
595
|
+
# @return [Float]
|
596
|
+
attr_accessor :score
|
597
|
+
|
598
|
+
def initialize(**args)
|
599
|
+
update!(**args)
|
600
|
+
end
|
601
|
+
|
602
|
+
# Update properties of this object
|
603
|
+
def update!(**args)
|
604
|
+
@magnitude = args[:magnitude] if args.key?(:magnitude)
|
605
|
+
@score = args[:score] if args.key?(:score)
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
609
|
+
# The `Status` type defines a logical error model that is suitable for different
|
610
|
+
# programming environments, including REST APIs and RPC APIs. It is used by [
|
611
|
+
# gRPC](https://github.com/grpc). Each `Status` message contains three pieces of
|
612
|
+
# data: error code, error message, and error details. You can find out more
|
613
|
+
# about this error model and how to work with it in the [API Design Guide](https:
|
614
|
+
# //cloud.google.com/apis/design/errors).
|
615
|
+
class Status
|
616
|
+
include Google::Apis::Core::Hashable
|
617
|
+
|
618
|
+
# The status code, which should be an enum value of google.rpc.Code.
|
619
|
+
# Corresponds to the JSON property `code`
|
620
|
+
# @return [Fixnum]
|
621
|
+
attr_accessor :code
|
622
|
+
|
623
|
+
# A list of messages that carry the error details. There is a common set of
|
624
|
+
# message types for APIs to use.
|
625
|
+
# Corresponds to the JSON property `details`
|
626
|
+
# @return [Array<Hash<String,Object>>]
|
627
|
+
attr_accessor :details
|
628
|
+
|
629
|
+
# A developer-facing error message, which should be in English. Any user-facing
|
630
|
+
# error message should be localized and sent in the google.rpc.Status.details
|
631
|
+
# field, or localized by the client.
|
632
|
+
# Corresponds to the JSON property `message`
|
633
|
+
# @return [String]
|
634
|
+
attr_accessor :message
|
635
|
+
|
636
|
+
def initialize(**args)
|
637
|
+
update!(**args)
|
638
|
+
end
|
639
|
+
|
640
|
+
# Update properties of this object
|
641
|
+
def update!(**args)
|
642
|
+
@code = args[:code] if args.key?(:code)
|
643
|
+
@details = args[:details] if args.key?(:details)
|
644
|
+
@message = args[:message] if args.key?(:message)
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
# Represents a text span in the input document.
|
649
|
+
class TextSpan
|
650
|
+
include Google::Apis::Core::Hashable
|
651
|
+
|
652
|
+
# The API calculates the beginning offset of the content in the original
|
653
|
+
# document according to the EncodingType specified in the API request.
|
654
|
+
# Corresponds to the JSON property `beginOffset`
|
655
|
+
# @return [Fixnum]
|
656
|
+
attr_accessor :begin_offset
|
657
|
+
|
658
|
+
# The content of the text span, which is a substring of the document.
|
659
|
+
# Corresponds to the JSON property `content`
|
660
|
+
# @return [String]
|
661
|
+
attr_accessor :content
|
662
|
+
|
663
|
+
def initialize(**args)
|
664
|
+
update!(**args)
|
665
|
+
end
|
666
|
+
|
667
|
+
# Update properties of this object
|
668
|
+
def update!(**args)
|
669
|
+
@begin_offset = args[:begin_offset] if args.key?(:begin_offset)
|
670
|
+
@content = args[:content] if args.key?(:content)
|
671
|
+
end
|
672
|
+
end
|
673
|
+
end
|
674
|
+
end
|
675
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright 2020 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
|
+
# http://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
|
+
module Google
|
16
|
+
module Apis
|
17
|
+
module LanguageV2
|
18
|
+
# Version of the google-apis-language_v2 gem
|
19
|
+
GEM_VERSION = "0.1.0"
|
20
|
+
|
21
|
+
# Version of the code generator used to generate this client
|
22
|
+
GENERATOR_VERSION = "0.12.0"
|
23
|
+
|
24
|
+
# Revision of the discovery document this client was generated from
|
25
|
+
REVISION = "20230812"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|