google-cloud-language 0.21.0 → 0.22.0

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