google-cloud-language 0.36.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,160 +0,0 @@
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
- # 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
-
16
- require "google/cloud/language/v1beta2/language_service_client"
17
-
18
- module Google
19
- module Cloud
20
- module Language
21
- # rubocop:disable LineLength
22
-
23
- ##
24
- # # Ruby Client for Google Cloud Natural Language API
25
- #
26
- # [Google Cloud Natural Language API][Product Documentation]:
27
- # Google Cloud Natural Language API provides natural language understanding
28
- # technologies to developers. Examples include sentiment analysis, entity
29
- # recognition, and text annotations.
30
- # - [Product Documentation][]
31
- #
32
- # ## Quick Start
33
- # In order to use this library, you first need to go through the following
34
- # steps:
35
- #
36
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
37
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
38
- # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
39
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html)
40
- #
41
- # ### Installation
42
- # ```
43
- # $ gem install google-cloud-language
44
- # ```
45
- #
46
- # ### Preview
47
- # #### LanguageServiceClient
48
- # ```rb
49
- # require "google/cloud/language"
50
- #
51
- # language_client = Google::Cloud::Language.new(version: :v1beta2)
52
- # content = "Hello, world!"
53
- # type = :PLAIN_TEXT
54
- # document = { content: content, type: type }
55
- # response = language_client.analyze_sentiment(document)
56
- # ```
57
- #
58
- # ### Next Steps
59
- # - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
60
- # to learn more about the product and see How-to Guides.
61
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
62
- # to see the full list of Cloud APIs that we cover.
63
- #
64
- # [Product Documentation]: https://cloud.google.com/natural-language
65
- #
66
- # ## Enabling Logging
67
- #
68
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
69
- # 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,
70
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
71
- # 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)
72
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
73
- #
74
- # Configuring a Ruby stdlib logger:
75
- #
76
- # ```ruby
77
- # require "logger"
78
- #
79
- # module MyLogger
80
- # LOGGER = Logger.new $stderr, level: Logger::WARN
81
- # def logger
82
- # LOGGER
83
- # end
84
- # end
85
- #
86
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
87
- # module GRPC
88
- # extend MyLogger
89
- # end
90
- # ```
91
- #
92
- module V1beta2
93
- # rubocop:enable LineLength
94
-
95
- ##
96
- # Provides text analysis operations such as sentiment analysis and entity
97
- # recognition.
98
- #
99
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
100
- # Provides the means for authenticating requests made by the client. This parameter can
101
- # be many types.
102
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
103
- # authenticating requests made by this client.
104
- # A `String` will be treated as the path to the keyfile to be used for the construction of
105
- # credentials for this client.
106
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
107
- # credentials for this client.
108
- # A `GRPC::Core::Channel` will be used to make calls through.
109
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
110
- # should already be composed with a `GRPC::Core::CallCredentials` object.
111
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
112
- # metadata for requests, generally, to give OAuth credentials.
113
- # @param scopes [Array<String>]
114
- # The OAuth scopes for this service. This parameter is ignored if
115
- # an updater_proc is supplied.
116
- # @param client_config [Hash]
117
- # A Hash for call options for each method. See
118
- # Google::Gax#construct_settings for the structure of
119
- # this data. Falls back to the default config if not specified
120
- # or the specified config is missing data points.
121
- # @param timeout [Numeric]
122
- # The default timeout, in seconds, for calls made through this client.
123
- # @param metadata [Hash]
124
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
125
- # @param service_address [String]
126
- # Override for the service hostname, or `nil` to leave as the default.
127
- # @param service_port [Integer]
128
- # Override for the service port, or `nil` to leave as the default.
129
- # @param exception_transformer [Proc]
130
- # An optional proc that intercepts any exceptions raised during an API call to inject
131
- # custom error handling.
132
- def self.new \
133
- credentials: nil,
134
- scopes: nil,
135
- client_config: nil,
136
- timeout: nil,
137
- metadata: nil,
138
- service_address: nil,
139
- service_port: nil,
140
- exception_transformer: nil,
141
- lib_name: nil,
142
- lib_version: nil
143
- kwargs = {
144
- credentials: credentials,
145
- scopes: scopes,
146
- client_config: client_config,
147
- timeout: timeout,
148
- metadata: metadata,
149
- exception_transformer: exception_transformer,
150
- lib_name: lib_name,
151
- service_address: service_address,
152
- service_port: service_port,
153
- lib_version: lib_version
154
- }.select { |_, v| v != nil }
155
- Google::Cloud::Language::V1beta2::LanguageServiceClient.new(**kwargs)
156
- end
157
- end
158
- end
159
- end
160
- end
@@ -1,41 +0,0 @@
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
- # 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
-
16
- require "googleauth"
17
-
18
- module Google
19
- module Cloud
20
- module Language
21
- module V1beta2
22
- class Credentials < Google::Auth::Credentials
23
- SCOPE = [
24
- "https://www.googleapis.com/auth/cloud-platform"
25
- ].freeze
26
- PATH_ENV_VARS = %w(LANGUAGE_CREDENTIALS
27
- LANGUAGE_KEYFILE
28
- GOOGLE_CLOUD_CREDENTIALS
29
- GOOGLE_CLOUD_KEYFILE
30
- GCLOUD_KEYFILE)
31
- JSON_ENV_VARS = %w(LANGUAGE_CREDENTIALS_JSON
32
- LANGUAGE_KEYFILE_JSON
33
- GOOGLE_CLOUD_CREDENTIALS_JSON
34
- GOOGLE_CLOUD_KEYFILE_JSON
35
- GCLOUD_KEYFILE_JSON)
36
- DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,1049 +0,0 @@
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
- # 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
-
16
- module Google
17
- module Cloud
18
- module Language
19
- module V1beta2
20
- # ================================================================ #
21
- #
22
- # Represents the input to API methods.
23
- # @!attribute [rw] type
24
- # @return [Google::Cloud::Language::V1beta2::Document::Type]
25
- # Required. If the type is not set or is `TYPE_UNSPECIFIED`,
26
- # returns an `INVALID_ARGUMENT` error.
27
- # @!attribute [rw] content
28
- # @return [String]
29
- # The content of the input in string format.
30
- # Cloud audit logging exempt since it is based on user data.
31
- # @!attribute [rw] gcs_content_uri
32
- # @return [String]
33
- # The Google Cloud Storage URI where the file content is located.
34
- # This URI must be of the form: gs://bucket_name/object_name. For more
35
- # details, see https://cloud.google.com/storage/docs/reference-uris.
36
- # NOTE: Cloud Storage object versioning is not supported.
37
- # @!attribute [rw] language
38
- # @return [String]
39
- # The language of the document (if not specified, the language is
40
- # automatically detected). Both ISO and BCP-47 language codes are
41
- # accepted.<br>
42
- # [Language Support](https://cloud.google.com/natural-language/docs/languages)
43
- # lists currently supported languages for each API method.
44
- # If the language (either specified by the caller or automatically detected)
45
- # is not supported by the called API method, an `INVALID_ARGUMENT` error
46
- # is returned.
47
- class Document
48
- # The document types enum.
49
- module Type
50
- # The content type is not specified.
51
- TYPE_UNSPECIFIED = 0
52
-
53
- # Plain text
54
- PLAIN_TEXT = 1
55
-
56
- # HTML
57
- HTML = 2
58
- end
59
- end
60
-
61
- # Represents a sentence in the input document.
62
- # @!attribute [rw] text
63
- # @return [Google::Cloud::Language::V1beta2::TextSpan]
64
- # The sentence text.
65
- # @!attribute [rw] sentiment
66
- # @return [Google::Cloud::Language::V1beta2::Sentiment]
67
- # For calls to {AnalyzeSentiment} or if
68
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment} is set to
69
- # true, this field will contain the sentiment for the sentence.
70
- class Sentence; end
71
-
72
- # Represents a phrase in the text that is a known entity, such as
73
- # a person, an organization, or location. The API associates information, such
74
- # as salience and mentions, with entities.
75
- # @!attribute [rw] name
76
- # @return [String]
77
- # The representative name for the entity.
78
- # @!attribute [rw] type
79
- # @return [Google::Cloud::Language::V1beta2::Entity::Type]
80
- # The entity type.
81
- # @!attribute [rw] metadata
82
- # @return [Hash{String => String}]
83
- # Metadata associated with the entity.
84
- #
85
- # For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`)
86
- # and Knowledge Graph MID (`mid`), if they are available. For the metadata
87
- # associated with other entity types, see the Type table below.
88
- # @!attribute [rw] salience
89
- # @return [Float]
90
- # The salience score associated with the entity in the [0, 1.0] range.
91
- #
92
- # The salience score for an entity provides information about the
93
- # importance or centrality of that entity to the entire document text.
94
- # Scores closer to 0 are less salient, while scores closer to 1.0 are highly
95
- # salient.
96
- # @!attribute [rw] mentions
97
- # @return [Array<Google::Cloud::Language::V1beta2::EntityMention>]
98
- # The mentions of this entity in the input document. The API currently
99
- # supports proper noun mentions.
100
- # @!attribute [rw] sentiment
101
- # @return [Google::Cloud::Language::V1beta2::Sentiment]
102
- # For calls to {AnalyzeEntitySentiment} or if
103
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to
104
- # true, this field will contain the aggregate sentiment expressed for this
105
- # entity in the provided document.
106
- class Entity
107
- # The type of the entity. For most entity types, the associated metadata is a
108
- # Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table
109
- # below lists the associated fields for entities that have different
110
- # metadata.
111
- module Type
112
- # Unknown
113
- UNKNOWN = 0
114
-
115
- # Person
116
- PERSON = 1
117
-
118
- # Location
119
- LOCATION = 2
120
-
121
- # Organization
122
- ORGANIZATION = 3
123
-
124
- # Event
125
- EVENT = 4
126
-
127
- # Artwork
128
- WORK_OF_ART = 5
129
-
130
- # Consumer product
131
- CONSUMER_GOOD = 6
132
-
133
- # Other types of entities
134
- OTHER = 7
135
-
136
- # Phone number
137
- #
138
- # The metadata lists the phone number, formatted according to local
139
- # convention, plus whichever additional elements appear in the text:
140
- #
141
- # * `number` - the actual number, broken down into sections as per local
142
- # convention
143
- # * `national_prefix` - country code, if detected
144
- # * `area_code` - region or area code, if detected
145
- # * `extension` - phone extension (to be dialed after connection), if
146
- # detected
147
- PHONE_NUMBER = 9
148
-
149
- # Address
150
- #
151
- # The metadata identifies the street number and locality plus whichever
152
- # additional elements appear in the text:
153
- #
154
- # * `street_number` - street number
155
- # * `locality` - city or town
156
- # * `street_name` - street/route name, if detected
157
- # * `postal_code` - postal code, if detected
158
- # * `country` - country, if detected<
159
- # * `broad_region` - administrative area, such as the state, if detected
160
- # * `narrow_region` - smaller administrative area, such as county, if
161
- # detected
162
- # * `sublocality` - used in Asian addresses to demark a district within a
163
- # city, if detected
164
- ADDRESS = 10
165
-
166
- # Date
167
- #
168
- # The metadata identifies the components of the date:
169
- #
170
- # * `year` - four digit year, if detected
171
- # * `month` - two digit month number, if detected
172
- # * `day` - two digit day number, if detected
173
- DATE = 11
174
-
175
- # Number
176
- #
177
- # The metadata is the number itself.
178
- NUMBER = 12
179
-
180
- # Price
181
- #
182
- # The metadata identifies the `value` and `currency`.
183
- PRICE = 13
184
- end
185
- end
186
-
187
- # Represents the smallest syntactic building block of the text.
188
- # @!attribute [rw] text
189
- # @return [Google::Cloud::Language::V1beta2::TextSpan]
190
- # The token text.
191
- # @!attribute [rw] part_of_speech
192
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech]
193
- # Parts of speech tag for this token.
194
- # @!attribute [rw] dependency_edge
195
- # @return [Google::Cloud::Language::V1beta2::DependencyEdge]
196
- # Dependency tree parse for this token.
197
- # @!attribute [rw] lemma
198
- # @return [String]
199
- # [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.
200
- class Token; end
201
-
202
- # Represents the feeling associated with the entire text or entities in
203
- # the text.
204
- # Next ID: 6
205
- # @!attribute [rw] magnitude
206
- # @return [Float]
207
- # A non-negative number in the [0, +inf) range, which represents
208
- # the absolute magnitude of sentiment regardless of score (positive or
209
- # negative).
210
- # @!attribute [rw] score
211
- # @return [Float]
212
- # Sentiment score between -1.0 (negative sentiment) and 1.0
213
- # (positive sentiment).
214
- class Sentiment; end
215
-
216
- # Represents part of speech information for a token.
217
- # @!attribute [rw] tag
218
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Tag]
219
- # The part of speech tag.
220
- # @!attribute [rw] aspect
221
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Aspect]
222
- # The grammatical aspect.
223
- # @!attribute [rw] case
224
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Case]
225
- # The grammatical case.
226
- # @!attribute [rw] form
227
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Form]
228
- # The grammatical form.
229
- # @!attribute [rw] gender
230
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Gender]
231
- # The grammatical gender.
232
- # @!attribute [rw] mood
233
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Mood]
234
- # The grammatical mood.
235
- # @!attribute [rw] number
236
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Number]
237
- # The grammatical number.
238
- # @!attribute [rw] person
239
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Person]
240
- # The grammatical person.
241
- # @!attribute [rw] proper
242
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Proper]
243
- # The grammatical properness.
244
- # @!attribute [rw] reciprocity
245
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Reciprocity]
246
- # The grammatical reciprocity.
247
- # @!attribute [rw] tense
248
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Tense]
249
- # The grammatical tense.
250
- # @!attribute [rw] voice
251
- # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Voice]
252
- # The grammatical voice.
253
- class PartOfSpeech
254
- # The characteristic of a verb that expresses time flow during an event.
255
- module Aspect
256
- # Aspect is not applicable in the analyzed language or is not predicted.
257
- ASPECT_UNKNOWN = 0
258
-
259
- # Perfective
260
- PERFECTIVE = 1
261
-
262
- # Imperfective
263
- IMPERFECTIVE = 2
264
-
265
- # Progressive
266
- PROGRESSIVE = 3
267
- end
268
-
269
- # The grammatical function performed by a noun or pronoun in a phrase,
270
- # clause, or sentence. In some languages, other parts of speech, such as
271
- # adjective and determiner, take case inflection in agreement with the noun.
272
- module Case
273
- # Case is not applicable in the analyzed language or is not predicted.
274
- CASE_UNKNOWN = 0
275
-
276
- # Accusative
277
- ACCUSATIVE = 1
278
-
279
- # Adverbial
280
- ADVERBIAL = 2
281
-
282
- # Complementive
283
- COMPLEMENTIVE = 3
284
-
285
- # Dative
286
- DATIVE = 4
287
-
288
- # Genitive
289
- GENITIVE = 5
290
-
291
- # Instrumental
292
- INSTRUMENTAL = 6
293
-
294
- # Locative
295
- LOCATIVE = 7
296
-
297
- # Nominative
298
- NOMINATIVE = 8
299
-
300
- # Oblique
301
- OBLIQUE = 9
302
-
303
- # Partitive
304
- PARTITIVE = 10
305
-
306
- # Prepositional
307
- PREPOSITIONAL = 11
308
-
309
- # Reflexive
310
- REFLEXIVE_CASE = 12
311
-
312
- # Relative
313
- RELATIVE_CASE = 13
314
-
315
- # Vocative
316
- VOCATIVE = 14
317
- end
318
-
319
- # Depending on the language, Form can be categorizing different forms of
320
- # verbs, adjectives, adverbs, etc. For example, categorizing inflected
321
- # endings of verbs and adjectives or distinguishing between short and long
322
- # forms of adjectives and participles
323
- module Form
324
- # Form is not applicable in the analyzed language or is not predicted.
325
- FORM_UNKNOWN = 0
326
-
327
- # Adnomial
328
- ADNOMIAL = 1
329
-
330
- # Auxiliary
331
- AUXILIARY = 2
332
-
333
- # Complementizer
334
- COMPLEMENTIZER = 3
335
-
336
- # Final ending
337
- FINAL_ENDING = 4
338
-
339
- # Gerund
340
- GERUND = 5
341
-
342
- # Realis
343
- REALIS = 6
344
-
345
- # Irrealis
346
- IRREALIS = 7
347
-
348
- # Short form
349
- SHORT = 8
350
-
351
- # Long form
352
- LONG = 9
353
-
354
- # Order form
355
- ORDER = 10
356
-
357
- # Specific form
358
- SPECIFIC = 11
359
- end
360
-
361
- # Gender classes of nouns reflected in the behaviour of associated words.
362
- module Gender
363
- # Gender is not applicable in the analyzed language or is not predicted.
364
- GENDER_UNKNOWN = 0
365
-
366
- # Feminine
367
- FEMININE = 1
368
-
369
- # Masculine
370
- MASCULINE = 2
371
-
372
- # Neuter
373
- NEUTER = 3
374
- end
375
-
376
- # The grammatical feature of verbs, used for showing modality and attitude.
377
- module Mood
378
- # Mood is not applicable in the analyzed language or is not predicted.
379
- MOOD_UNKNOWN = 0
380
-
381
- # Conditional
382
- CONDITIONAL_MOOD = 1
383
-
384
- # Imperative
385
- IMPERATIVE = 2
386
-
387
- # Indicative
388
- INDICATIVE = 3
389
-
390
- # Interrogative
391
- INTERROGATIVE = 4
392
-
393
- # Jussive
394
- JUSSIVE = 5
395
-
396
- # Subjunctive
397
- SUBJUNCTIVE = 6
398
- end
399
-
400
- # Count distinctions.
401
- module Number
402
- # Number is not applicable in the analyzed language or is not predicted.
403
- NUMBER_UNKNOWN = 0
404
-
405
- # Singular
406
- SINGULAR = 1
407
-
408
- # Plural
409
- PLURAL = 2
410
-
411
- # Dual
412
- DUAL = 3
413
- end
414
-
415
- # The distinction between the speaker, second person, third person, etc.
416
- module Person
417
- # Person is not applicable in the analyzed language or is not predicted.
418
- PERSON_UNKNOWN = 0
419
-
420
- # First
421
- FIRST = 1
422
-
423
- # Second
424
- SECOND = 2
425
-
426
- # Third
427
- THIRD = 3
428
-
429
- # Reflexive
430
- REFLEXIVE_PERSON = 4
431
- end
432
-
433
- # This category shows if the token is part of a proper name.
434
- module Proper
435
- # Proper is not applicable in the analyzed language or is not predicted.
436
- PROPER_UNKNOWN = 0
437
-
438
- # Proper
439
- PROPER = 1
440
-
441
- # Not proper
442
- NOT_PROPER = 2
443
- end
444
-
445
- # Reciprocal features of a pronoun.
446
- module Reciprocity
447
- # Reciprocity is not applicable in the analyzed language or is not
448
- # predicted.
449
- RECIPROCITY_UNKNOWN = 0
450
-
451
- # Reciprocal
452
- RECIPROCAL = 1
453
-
454
- # Non-reciprocal
455
- NON_RECIPROCAL = 2
456
- end
457
-
458
- # The part of speech tags enum.
459
- module Tag
460
- # Unknown
461
- UNKNOWN = 0
462
-
463
- # Adjective
464
- ADJ = 1
465
-
466
- # Adposition (preposition and postposition)
467
- ADP = 2
468
-
469
- # Adverb
470
- ADV = 3
471
-
472
- # Conjunction
473
- CONJ = 4
474
-
475
- # Determiner
476
- DET = 5
477
-
478
- # Noun (common and proper)
479
- NOUN = 6
480
-
481
- # Cardinal number
482
- NUM = 7
483
-
484
- # Pronoun
485
- PRON = 8
486
-
487
- # Particle or other function word
488
- PRT = 9
489
-
490
- # Punctuation
491
- PUNCT = 10
492
-
493
- # Verb (all tenses and modes)
494
- VERB = 11
495
-
496
- # Other: foreign words, typos, abbreviations
497
- X = 12
498
-
499
- # Affix
500
- AFFIX = 13
501
- end
502
-
503
- # Time reference.
504
- module Tense
505
- # Tense is not applicable in the analyzed language or is not predicted.
506
- TENSE_UNKNOWN = 0
507
-
508
- # Conditional
509
- CONDITIONAL_TENSE = 1
510
-
511
- # Future
512
- FUTURE = 2
513
-
514
- # Past
515
- PAST = 3
516
-
517
- # Present
518
- PRESENT = 4
519
-
520
- # Imperfect
521
- IMPERFECT = 5
522
-
523
- # Pluperfect
524
- PLUPERFECT = 6
525
- end
526
-
527
- # The relationship between the action that a verb expresses and the
528
- # participants identified by its arguments.
529
- module Voice
530
- # Voice is not applicable in the analyzed language or is not predicted.
531
- VOICE_UNKNOWN = 0
532
-
533
- # Active
534
- ACTIVE = 1
535
-
536
- # Causative
537
- CAUSATIVE = 2
538
-
539
- # Passive
540
- PASSIVE = 3
541
- end
542
- end
543
-
544
- # Represents dependency parse tree information for a token.
545
- # @!attribute [rw] head_token_index
546
- # @return [Integer]
547
- # Represents the head of this token in the dependency tree.
548
- # This is the index of the token which has an arc going to this token.
549
- # The index is the position of the token in the array of tokens returned
550
- # by the API method. If this token is a root token, then the
551
- # `head_token_index` is its own index.
552
- # @!attribute [rw] label
553
- # @return [Google::Cloud::Language::V1beta2::DependencyEdge::Label]
554
- # The parse label for the token.
555
- class DependencyEdge
556
- # The parse label enum for the token.
557
- module Label
558
- # Unknown
559
- UNKNOWN = 0
560
-
561
- # Abbreviation modifier
562
- ABBREV = 1
563
-
564
- # Adjectival complement
565
- ACOMP = 2
566
-
567
- # Adverbial clause modifier
568
- ADVCL = 3
569
-
570
- # Adverbial modifier
571
- ADVMOD = 4
572
-
573
- # Adjectival modifier of an NP
574
- AMOD = 5
575
-
576
- # Appositional modifier of an NP
577
- APPOS = 6
578
-
579
- # Attribute dependent of a copular verb
580
- ATTR = 7
581
-
582
- # Auxiliary (non-main) verb
583
- AUX = 8
584
-
585
- # Passive auxiliary
586
- AUXPASS = 9
587
-
588
- # Coordinating conjunction
589
- CC = 10
590
-
591
- # Clausal complement of a verb or adjective
592
- CCOMP = 11
593
-
594
- # Conjunct
595
- CONJ = 12
596
-
597
- # Clausal subject
598
- CSUBJ = 13
599
-
600
- # Clausal passive subject
601
- CSUBJPASS = 14
602
-
603
- # Dependency (unable to determine)
604
- DEP = 15
605
-
606
- # Determiner
607
- DET = 16
608
-
609
- # Discourse
610
- DISCOURSE = 17
611
-
612
- # Direct object
613
- DOBJ = 18
614
-
615
- # Expletive
616
- EXPL = 19
617
-
618
- # Goes with (part of a word in a text not well edited)
619
- GOESWITH = 20
620
-
621
- # Indirect object
622
- IOBJ = 21
623
-
624
- # Marker (word introducing a subordinate clause)
625
- MARK = 22
626
-
627
- # Multi-word expression
628
- MWE = 23
629
-
630
- # Multi-word verbal expression
631
- MWV = 24
632
-
633
- # Negation modifier
634
- NEG = 25
635
-
636
- # Noun compound modifier
637
- NN = 26
638
-
639
- # Noun phrase used as an adverbial modifier
640
- NPADVMOD = 27
641
-
642
- # Nominal subject
643
- NSUBJ = 28
644
-
645
- # Passive nominal subject
646
- NSUBJPASS = 29
647
-
648
- # Numeric modifier of a noun
649
- NUM = 30
650
-
651
- # Element of compound number
652
- NUMBER = 31
653
-
654
- # Punctuation mark
655
- P = 32
656
-
657
- # Parataxis relation
658
- PARATAXIS = 33
659
-
660
- # Participial modifier
661
- PARTMOD = 34
662
-
663
- # The complement of a preposition is a clause
664
- PCOMP = 35
665
-
666
- # Object of a preposition
667
- POBJ = 36
668
-
669
- # Possession modifier
670
- POSS = 37
671
-
672
- # Postverbal negative particle
673
- POSTNEG = 38
674
-
675
- # Predicate complement
676
- PRECOMP = 39
677
-
678
- # Preconjunt
679
- PRECONJ = 40
680
-
681
- # Predeterminer
682
- PREDET = 41
683
-
684
- # Prefix
685
- PREF = 42
686
-
687
- # Prepositional modifier
688
- PREP = 43
689
-
690
- # The relationship between a verb and verbal morpheme
691
- PRONL = 44
692
-
693
- # Particle
694
- PRT = 45
695
-
696
- # Associative or possessive marker
697
- PS = 46
698
-
699
- # Quantifier phrase modifier
700
- QUANTMOD = 47
701
-
702
- # Relative clause modifier
703
- RCMOD = 48
704
-
705
- # Complementizer in relative clause
706
- RCMODREL = 49
707
-
708
- # Ellipsis without a preceding predicate
709
- RDROP = 50
710
-
711
- # Referent
712
- REF = 51
713
-
714
- # Remnant
715
- REMNANT = 52
716
-
717
- # Reparandum
718
- REPARANDUM = 53
719
-
720
- # Root
721
- ROOT = 54
722
-
723
- # Suffix specifying a unit of number
724
- SNUM = 55
725
-
726
- # Suffix
727
- SUFF = 56
728
-
729
- # Temporal modifier
730
- TMOD = 57
731
-
732
- # Topic marker
733
- TOPIC = 58
734
-
735
- # Clause headed by an infinite form of the verb that modifies a noun
736
- VMOD = 59
737
-
738
- # Vocative
739
- VOCATIVE = 60
740
-
741
- # Open clausal complement
742
- XCOMP = 61
743
-
744
- # Name suffix
745
- SUFFIX = 62
746
-
747
- # Name title
748
- TITLE = 63
749
-
750
- # Adverbial phrase modifier
751
- ADVPHMOD = 64
752
-
753
- # Causative auxiliary
754
- AUXCAUS = 65
755
-
756
- # Helper auxiliary
757
- AUXVV = 66
758
-
759
- # Rentaishi (Prenominal modifier)
760
- DTMOD = 67
761
-
762
- # Foreign words
763
- FOREIGN = 68
764
-
765
- # Keyword
766
- KW = 69
767
-
768
- # List for chains of comparable items
769
- LIST = 70
770
-
771
- # Nominalized clause
772
- NOMC = 71
773
-
774
- # Nominalized clausal subject
775
- NOMCSUBJ = 72
776
-
777
- # Nominalized clausal passive
778
- NOMCSUBJPASS = 73
779
-
780
- # Compound of numeric modifier
781
- NUMC = 74
782
-
783
- # Copula
784
- COP = 75
785
-
786
- # Dislocated relation (for fronted/topicalized elements)
787
- DISLOCATED = 76
788
-
789
- # Aspect marker
790
- ASP = 77
791
-
792
- # Genitive modifier
793
- GMOD = 78
794
-
795
- # Genitive object
796
- GOBJ = 79
797
-
798
- # Infinitival modifier
799
- INFMOD = 80
800
-
801
- # Measure
802
- MES = 81
803
-
804
- # Nominal complement of a noun
805
- NCOMP = 82
806
- end
807
- end
808
-
809
- # Represents a mention for an entity in the text. Currently, proper noun
810
- # mentions are supported.
811
- # @!attribute [rw] text
812
- # @return [Google::Cloud::Language::V1beta2::TextSpan]
813
- # The mention text.
814
- # @!attribute [rw] type
815
- # @return [Google::Cloud::Language::V1beta2::EntityMention::Type]
816
- # The type of the entity mention.
817
- # @!attribute [rw] sentiment
818
- # @return [Google::Cloud::Language::V1beta2::Sentiment]
819
- # For calls to {AnalyzeEntitySentiment} or if
820
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to
821
- # true, this field will contain the sentiment expressed for this mention of
822
- # the entity in the provided document.
823
- class EntityMention
824
- # The supported types of mentions.
825
- module Type
826
- # Unknown
827
- TYPE_UNKNOWN = 0
828
-
829
- # Proper name
830
- PROPER = 1
831
-
832
- # Common noun (or noun compound)
833
- COMMON = 2
834
- end
835
- end
836
-
837
- # Represents an output piece of text.
838
- # @!attribute [rw] content
839
- # @return [String]
840
- # The content of the output text.
841
- # @!attribute [rw] begin_offset
842
- # @return [Integer]
843
- # The API calculates the beginning offset of the content in the original
844
- # document according to the {Google::Cloud::Language::V1beta2::EncodingType EncodingType} specified in the API request.
845
- class TextSpan; end
846
-
847
- # Represents a category returned from the text classifier.
848
- # @!attribute [rw] name
849
- # @return [String]
850
- # The name of the category representing the document, from the [predefined
851
- # taxonomy](/natural-language/docs/categories).
852
- # @!attribute [rw] confidence
853
- # @return [Float]
854
- # The classifier's confidence of the category. Number represents how certain
855
- # the classifier is that this category represents the given text.
856
- class ClassificationCategory; end
857
-
858
- # The sentiment analysis request message.
859
- # @!attribute [rw] document
860
- # @return [Google::Cloud::Language::V1beta2::Document]
861
- # Required. Input document.
862
- # @!attribute [rw] encoding_type
863
- # @return [Google::Cloud::Language::V1beta2::EncodingType]
864
- # The encoding type used by the API to calculate sentence offsets for the
865
- # sentence sentiment.
866
- class AnalyzeSentimentRequest; end
867
-
868
- # The sentiment analysis response message.
869
- # @!attribute [rw] document_sentiment
870
- # @return [Google::Cloud::Language::V1beta2::Sentiment]
871
- # The overall sentiment of the input document.
872
- # @!attribute [rw] language
873
- # @return [String]
874
- # The language of the text, which will be the same as the language specified
875
- # in the request or, if not specified, the automatically-detected language.
876
- # See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
877
- # @!attribute [rw] sentences
878
- # @return [Array<Google::Cloud::Language::V1beta2::Sentence>]
879
- # The sentiment for all the sentences in the document.
880
- class AnalyzeSentimentResponse; end
881
-
882
- # The entity-level sentiment analysis request message.
883
- # @!attribute [rw] document
884
- # @return [Google::Cloud::Language::V1beta2::Document]
885
- # Required. Input document.
886
- # @!attribute [rw] encoding_type
887
- # @return [Google::Cloud::Language::V1beta2::EncodingType]
888
- # The encoding type used by the API to calculate offsets.
889
- class AnalyzeEntitySentimentRequest; end
890
-
891
- # The entity-level sentiment analysis response message.
892
- # @!attribute [rw] entities
893
- # @return [Array<Google::Cloud::Language::V1beta2::Entity>]
894
- # The recognized entities in the input document with associated sentiments.
895
- # @!attribute [rw] language
896
- # @return [String]
897
- # The language of the text, which will be the same as the language specified
898
- # in the request or, if not specified, the automatically-detected language.
899
- # See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
900
- class AnalyzeEntitySentimentResponse; end
901
-
902
- # The entity analysis request message.
903
- # @!attribute [rw] document
904
- # @return [Google::Cloud::Language::V1beta2::Document]
905
- # Required. Input document.
906
- # @!attribute [rw] encoding_type
907
- # @return [Google::Cloud::Language::V1beta2::EncodingType]
908
- # The encoding type used by the API to calculate offsets.
909
- class AnalyzeEntitiesRequest; end
910
-
911
- # The entity analysis response message.
912
- # @!attribute [rw] entities
913
- # @return [Array<Google::Cloud::Language::V1beta2::Entity>]
914
- # The recognized entities in the input document.
915
- # @!attribute [rw] language
916
- # @return [String]
917
- # The language of the text, which will be the same as the language specified
918
- # in the request or, if not specified, the automatically-detected language.
919
- # See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
920
- class AnalyzeEntitiesResponse; end
921
-
922
- # The syntax analysis request message.
923
- # @!attribute [rw] document
924
- # @return [Google::Cloud::Language::V1beta2::Document]
925
- # Required. Input document.
926
- # @!attribute [rw] encoding_type
927
- # @return [Google::Cloud::Language::V1beta2::EncodingType]
928
- # The encoding type used by the API to calculate offsets.
929
- class AnalyzeSyntaxRequest; end
930
-
931
- # The syntax analysis response message.
932
- # @!attribute [rw] sentences
933
- # @return [Array<Google::Cloud::Language::V1beta2::Sentence>]
934
- # Sentences in the input document.
935
- # @!attribute [rw] tokens
936
- # @return [Array<Google::Cloud::Language::V1beta2::Token>]
937
- # Tokens, along with their syntactic information, in the input document.
938
- # @!attribute [rw] language
939
- # @return [String]
940
- # The language of the text, which will be the same as the language specified
941
- # in the request or, if not specified, the automatically-detected language.
942
- # See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
943
- class AnalyzeSyntaxResponse; end
944
-
945
- # The document classification request message.
946
- # @!attribute [rw] document
947
- # @return [Google::Cloud::Language::V1beta2::Document]
948
- # Required. Input document.
949
- class ClassifyTextRequest; end
950
-
951
- # The document classification response message.
952
- # @!attribute [rw] categories
953
- # @return [Array<Google::Cloud::Language::V1beta2::ClassificationCategory>]
954
- # Categories representing the input document.
955
- class ClassifyTextResponse; end
956
-
957
- # The request message for the text annotation API, which can perform multiple
958
- # analysis types (sentiment, entities, and syntax) in one call.
959
- # @!attribute [rw] document
960
- # @return [Google::Cloud::Language::V1beta2::Document]
961
- # Required. Input document.
962
- # @!attribute [rw] features
963
- # @return [Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features]
964
- # Required. The enabled features.
965
- # @!attribute [rw] encoding_type
966
- # @return [Google::Cloud::Language::V1beta2::EncodingType]
967
- # The encoding type used by the API to calculate offsets.
968
- class AnnotateTextRequest
969
- # All available features for sentiment, syntax, and semantic analysis.
970
- # Setting each one to true will enable that specific analysis for the input.
971
- # Next ID: 10
972
- # @!attribute [rw] extract_syntax
973
- # @return [true, false]
974
- # Extract syntax information.
975
- # @!attribute [rw] extract_entities
976
- # @return [true, false]
977
- # Extract entities.
978
- # @!attribute [rw] extract_document_sentiment
979
- # @return [true, false]
980
- # Extract document-level sentiment.
981
- # @!attribute [rw] extract_entity_sentiment
982
- # @return [true, false]
983
- # Extract entities and their associated sentiment.
984
- # @!attribute [rw] classify_text
985
- # @return [true, false]
986
- # Classify the full document into categories. If this is true,
987
- # the API will use the default model which classifies into a
988
- # [predefined taxonomy](https://cloud.google.com/natural-language/docs/categories).
989
- class Features; end
990
- end
991
-
992
- # The text annotations response message.
993
- # @!attribute [rw] sentences
994
- # @return [Array<Google::Cloud::Language::V1beta2::Sentence>]
995
- # Sentences in the input document. Populated if the user enables
996
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}.
997
- # @!attribute [rw] tokens
998
- # @return [Array<Google::Cloud::Language::V1beta2::Token>]
999
- # Tokens, along with their syntactic information, in the input document.
1000
- # Populated if the user enables
1001
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}.
1002
- # @!attribute [rw] entities
1003
- # @return [Array<Google::Cloud::Language::V1beta2::Entity>]
1004
- # Entities, along with their semantic information, in the input document.
1005
- # Populated if the user enables
1006
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entities AnnotateTextRequest::Features#extract_entities}.
1007
- # @!attribute [rw] document_sentiment
1008
- # @return [Google::Cloud::Language::V1beta2::Sentiment]
1009
- # The overall sentiment for the document. Populated if the user enables
1010
- # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment}.
1011
- # @!attribute [rw] language
1012
- # @return [String]
1013
- # The language of the text, which will be the same as the language specified
1014
- # in the request or, if not specified, the automatically-detected language.
1015
- # See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
1016
- # @!attribute [rw] categories
1017
- # @return [Array<Google::Cloud::Language::V1beta2::ClassificationCategory>]
1018
- # Categories identified in the input document.
1019
- class AnnotateTextResponse; end
1020
-
1021
- # Represents the text encoding that the caller uses to process the output.
1022
- # Providing an `EncodingType` is recommended because the API provides the
1023
- # beginning offsets for various outputs, such as tokens and mentions, and
1024
- # languages that natively use different text encodings may access offsets
1025
- # differently.
1026
- module EncodingType
1027
- # If `EncodingType` is not specified, encoding-dependent information (such as
1028
- # `begin_offset`) will be set at `-1`.
1029
- NONE = 0
1030
-
1031
- # Encoding-dependent information (such as `begin_offset`) is calculated based
1032
- # on the UTF-8 encoding of the input. C++ and Go are examples of languages
1033
- # that use this encoding natively.
1034
- UTF8 = 1
1035
-
1036
- # Encoding-dependent information (such as `begin_offset`) is calculated based
1037
- # on the UTF-16 encoding of the input. Java and JavaScript are examples of
1038
- # languages that use this encoding natively.
1039
- UTF16 = 2
1040
-
1041
- # Encoding-dependent information (such as `begin_offset`) is calculated based
1042
- # on the UTF-32 encoding of the input. Python is an example of a language
1043
- # that uses this encoding natively.
1044
- UTF32 = 3
1045
- end
1046
- end
1047
- end
1048
- end
1049
- end