google-cloud-language 0.33.0 → 1.2.3

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