google-cloud-language 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/README.md +8 -8
- data/lib/google-cloud-language.rb +2 -2
- data/lib/google/cloud/language.rb +22 -22
- data/lib/google/cloud/language/annotation.rb +92 -82
- data/lib/google/cloud/language/credentials.rb +1 -1
- data/lib/google/cloud/language/document.rb +35 -36
- data/lib/google/cloud/language/project.rb +28 -26
- data/lib/google/cloud/language/service.rb +2 -2
- data/lib/google/cloud/language/v1.rb +1 -1
- data/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb +35 -8
- data/lib/google/cloud/language/v1/{language_service_api.rb → language_service_client.rb} +18 -17
- data/lib/google/cloud/language/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413f09d5f6c45191fdf13e7e6496f7da9d3011f6
|
4
|
+
data.tar.gz: c32b9f8ebc5643ff076ee854b4f2e9e32a9d6aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 146e46b869f16a2b3431f1a4689c2d12abd1e9d5e57569cbc9afffab797beea6b169fb2db671e53a8f7436658225bdf549a300f16f28ddfd1eb611996daddde4
|
7
|
+
data.tar.gz: 984040275c3a11255021bb28782f8e7f7f5130f11258229209b4aca1ad88a0c8e4d747414b28e3e5b50f3453c77105dab95a81d3eaefea7e2fcbcfc003922c66
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# google-cloud-language
|
2
2
|
|
3
|
-
[Google Cloud Natural Language API](https://cloud.google.com/language/) ([docs](https://cloud.google.com/language/docs)) reveals the structure and meaning of text by offering powerful machine learning models in an easy to use REST API. You can use it to extract information about people, places, events and much more, mentioned in text documents, news articles or blog posts. You can use it to understand sentiment about your product on social media or parse intent from customer conversations happening in a call center or a messaging app. You can analyze text uploaded in your request or integrate with your document storage on Google Cloud Storage.
|
3
|
+
[Google Cloud Natural Language API](https://cloud.google.com/natural-language/) ([docs](https://cloud.google.com/natural-language/docs)) reveals the structure and meaning of text by offering powerful machine learning models in an easy to use REST API. You can use it to extract information about people, places, events and much more, mentioned in text documents, news articles or blog posts. You can use it to understand sentiment about your product on social media or parse intent from customer conversations happening in a call center or a messaging app. You can analyze text uploaded in your request or integrate with your document storage on Google Cloud Storage.
|
4
4
|
|
5
5
|
The Google Cloud Natural Language API is currently a beta release, and might be changed in backward-incompatible ways. It is not subject to any SLA or deprecation policy and is not intended for real-time usage in critical applications.
|
6
6
|
|
7
7
|
- [google-cloud-language API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/master/google/cloud/language)
|
8
8
|
- [google-cloud-language on RubyGems](https://rubygems.org/gems/google-cloud-language)
|
9
|
-
- [Google Cloud Natural Language API documentation](https://cloud.google.com/language/docs)
|
9
|
+
- [Google Cloud Natural Language API documentation](https://cloud.google.com/natural-language/docs)
|
10
10
|
|
11
11
|
## Quick Start
|
12
12
|
|
@@ -27,15 +27,15 @@ require "google/cloud/language"
|
|
27
27
|
|
28
28
|
language = Google::Cloud::Language.new
|
29
29
|
|
30
|
-
content = "
|
30
|
+
content = "Star Wars is a great movie. The Death Star is fearsome."
|
31
31
|
document = language.document content
|
32
32
|
annotation = document.annotate
|
33
33
|
|
34
|
-
annotation.
|
35
|
-
annotation.sentiment.
|
36
|
-
annotation.
|
37
|
-
annotation.sentences.count #=>
|
38
|
-
annotation.tokens.count #=>
|
34
|
+
annotation.entities.count #=> 3
|
35
|
+
annotation.sentiment.score #=> 0.10000000149011612
|
36
|
+
annotation.sentiment.magnitude #=> 1.100000023841858
|
37
|
+
annotation.sentences.count #=> 2
|
38
|
+
annotation.tokens.count #=> 13
|
39
39
|
```
|
40
40
|
|
41
41
|
## Supported Ruby Versions
|
@@ -50,7 +50,7 @@ module Google
|
|
50
50
|
# gcloud = Google::Cloud.new
|
51
51
|
# language = gcloud.language
|
52
52
|
#
|
53
|
-
# content = "
|
53
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
54
54
|
# document = language.document content
|
55
55
|
# annotation = document.annotate
|
56
56
|
#
|
@@ -97,7 +97,7 @@ module Google
|
|
97
97
|
#
|
98
98
|
# language = Google::Cloud.language
|
99
99
|
#
|
100
|
-
# content = "
|
100
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
101
101
|
# document = language.document content
|
102
102
|
# annotation = document.annotate
|
103
103
|
#
|
@@ -32,7 +32,7 @@ module Google
|
|
32
32
|
# API with the Google Cloud Speech API and extract insights from audio
|
33
33
|
# conversations. Use with Vision API OCR to understand scanned documents.
|
34
34
|
# Extract entities and understand sentiments in multiple languages by
|
35
|
-
# translating text first with
|
35
|
+
# translating text first with Cloud Translation API.
|
36
36
|
#
|
37
37
|
# The Google Cloud Natural Language API is currently a beta release, and
|
38
38
|
# might be changed in backward-incompatible ways. It is not subject to any
|
@@ -131,12 +131,12 @@ module Google
|
|
131
131
|
#
|
132
132
|
# language = Google::Cloud::Language.new
|
133
133
|
#
|
134
|
-
# content = "
|
134
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
135
135
|
# document = language.document content
|
136
136
|
# sentiment = document.sentiment # API call
|
137
137
|
#
|
138
|
-
# sentiment.score #=>
|
139
|
-
# sentiment.magnitude #=>
|
138
|
+
# sentiment.score #=> 0.10000000149011612
|
139
|
+
# sentiment.magnitude #=> 1.100000023841858
|
140
140
|
# ```
|
141
141
|
#
|
142
142
|
# Entity analysis inspects the given text for known entities (proper nouns
|
@@ -149,15 +149,15 @@ module Google
|
|
149
149
|
#
|
150
150
|
# language = Google::Cloud::Language.new
|
151
151
|
#
|
152
|
-
# content = "
|
152
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
153
153
|
# document = language.document content
|
154
154
|
# entities = document.entities # API call
|
155
155
|
#
|
156
|
-
# entities.count #=>
|
157
|
-
# entities.first.name #=> "Darth Vader"
|
158
|
-
# entities.first.type #=> :PERSON
|
156
|
+
# entities.count #=> 3
|
159
157
|
# entities.first.name #=> "Star Wars"
|
160
158
|
# entities.first.type #=> :WORK_OF_ART
|
159
|
+
# entities.first.mid #=> "/m/06mmr"
|
160
|
+
# entities.first.wikipedia_url #=> "http://en.wikipedia.org/wiki/Star_Wars"
|
161
161
|
# ```
|
162
162
|
#
|
163
163
|
# Syntactic analysis extracts linguistic information, breaking up the given
|
@@ -170,12 +170,12 @@ module Google
|
|
170
170
|
#
|
171
171
|
# language = Google::Cloud::Language.new
|
172
172
|
#
|
173
|
-
# content = "
|
173
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
174
174
|
# document = language.document content
|
175
175
|
# syntax = document.syntax # API call
|
176
176
|
#
|
177
|
-
# syntax.sentences.count #=>
|
178
|
-
# syntax.tokens.count #=>
|
177
|
+
# syntax.sentences.count #=> 2
|
178
|
+
# syntax.tokens.count #=> 13
|
179
179
|
# ```
|
180
180
|
#
|
181
181
|
# To run multiple features on a document in a single request, pass the flag
|
@@ -186,14 +186,14 @@ module Google
|
|
186
186
|
#
|
187
187
|
# language = Google::Cloud::Language.new
|
188
188
|
#
|
189
|
-
# content = "
|
189
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
190
190
|
# document = language.document content
|
191
191
|
# annotation = document.annotate entities: true, text: true
|
192
192
|
#
|
193
193
|
# annotation.sentiment #=> nil
|
194
|
-
# annotation.entities.count #=>
|
195
|
-
# annotation.sentences.count #=>
|
196
|
-
# annotation.tokens.count #=>
|
194
|
+
# annotation.entities.count #=> 3
|
195
|
+
# annotation.sentences.count #=> 2
|
196
|
+
# annotation.tokens.count #=> 13
|
197
197
|
# ```
|
198
198
|
#
|
199
199
|
# Or, simply call {Language::Document#annotate} with no arguments to process
|
@@ -204,15 +204,15 @@ module Google
|
|
204
204
|
#
|
205
205
|
# language = Google::Cloud::Language.new
|
206
206
|
#
|
207
|
-
# content = "
|
207
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
208
208
|
# document = language.document content
|
209
209
|
# annotation = document.annotate
|
210
210
|
#
|
211
|
-
# annotation.sentiment.score #=>
|
212
|
-
# annotation.sentiment.magnitude #=>
|
213
|
-
# annotation.entities.count #=>
|
214
|
-
# annotation.sentences.count #=>
|
215
|
-
# annotation.tokens.count #=>
|
211
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
212
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
213
|
+
# annotation.entities.count #=> 3
|
214
|
+
# annotation.sentences.count #=> 2
|
215
|
+
# annotation.tokens.count #=> 13
|
216
216
|
# ```
|
217
217
|
#
|
218
218
|
module Language
|
@@ -248,7 +248,7 @@ module Google
|
|
248
248
|
#
|
249
249
|
# language = Google::Cloud::Language.new
|
250
250
|
#
|
251
|
-
# content = "
|
251
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
252
252
|
# document = language.document content
|
253
253
|
# annotation = document.annotate
|
254
254
|
#
|
@@ -30,15 +30,15 @@ module Google
|
|
30
30
|
#
|
31
31
|
# language = Google::Cloud::Language.new
|
32
32
|
#
|
33
|
-
# content = "
|
33
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
34
34
|
# document = language.document content
|
35
35
|
# annotation = document.annotate
|
36
36
|
#
|
37
|
-
# annotation.sentiment.score #=>
|
38
|
-
# annotation.sentiment.magnitude #=>
|
39
|
-
# annotation.entities.count #=>
|
40
|
-
# annotation.sentences.count #=>
|
41
|
-
# annotation.tokens.count #=>
|
37
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
38
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
39
|
+
# annotation.entities.count #=> 3
|
40
|
+
# annotation.sentences.count #=> 2
|
41
|
+
# annotation.tokens.count #=> 13
|
42
42
|
#
|
43
43
|
class Annotation
|
44
44
|
##
|
@@ -62,13 +62,13 @@ module Google
|
|
62
62
|
#
|
63
63
|
# language = Google::Cloud::Language.new
|
64
64
|
#
|
65
|
-
# content = "
|
65
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
66
66
|
# document = language.document content
|
67
67
|
# annotation = document.annotate
|
68
68
|
#
|
69
69
|
# sentence = annotation.sentences.last
|
70
|
-
# sentence.text #=> "
|
71
|
-
# sentence.offset #=>
|
70
|
+
# sentence.text #=> "The Death Star is fearsome."
|
71
|
+
# sentence.offset #=> 28
|
72
72
|
#
|
73
73
|
def sentences
|
74
74
|
@sentences ||= Array(grpc.sentences).map { |g| Sentence.from_grpc g }
|
@@ -85,19 +85,19 @@ module Google
|
|
85
85
|
#
|
86
86
|
# language = Google::Cloud::Language.new
|
87
87
|
#
|
88
|
-
# content = "
|
88
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
89
89
|
# document = language.document content
|
90
90
|
# annotation = document.annotate
|
91
91
|
#
|
92
|
-
# annotation.tokens.count #=>
|
92
|
+
# annotation.tokens.count #=> 13
|
93
93
|
# token = annotation.tokens.first
|
94
94
|
#
|
95
|
-
# token.text #=> "
|
95
|
+
# token.text #=> "Star"
|
96
96
|
# token.offset #=> 0
|
97
|
-
# token.part_of_speech #=> :NOUN
|
97
|
+
# token.part_of_speech.tag #=> :NOUN
|
98
98
|
# token.head_token_index #=> 1
|
99
|
-
# token.label #=> :
|
100
|
-
# token.lemma #=> "
|
99
|
+
# token.label #=> :TITLE
|
100
|
+
# token.lemma #=> "Star"
|
101
101
|
#
|
102
102
|
def tokens
|
103
103
|
@tokens ||= Array(grpc.tokens).map { |g| Token.from_grpc g }
|
@@ -113,24 +113,24 @@ module Google
|
|
113
113
|
#
|
114
114
|
# language = Google::Cloud::Language.new
|
115
115
|
#
|
116
|
-
# content = "
|
116
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
117
117
|
# document = language.document content
|
118
118
|
# annotation = document.annotate
|
119
119
|
# syntax = annotation.syntax
|
120
120
|
#
|
121
121
|
# sentence = syntax.sentences.last
|
122
|
-
# sentence.text #=> "
|
123
|
-
# sentence.offset #=>
|
122
|
+
# sentence.text #=> "The Death Star is fearsome."
|
123
|
+
# sentence.offset #=> 28
|
124
124
|
#
|
125
|
-
# syntax.tokens.count #=>
|
125
|
+
# syntax.tokens.count #=> 13
|
126
126
|
# token = syntax.tokens.first
|
127
127
|
#
|
128
|
-
# token.text #=> "
|
128
|
+
# token.text #=> "Star"
|
129
129
|
# token.offset #=> 0
|
130
|
-
# token.part_of_speech #=> :NOUN
|
130
|
+
# token.part_of_speech.tag #=> :NOUN
|
131
131
|
# token.head_token_index #=> 1
|
132
|
-
# token.label #=> :
|
133
|
-
# token.lemma #=> "
|
132
|
+
# token.label #=> :TITLE
|
133
|
+
# token.lemma #=> "Star"
|
134
134
|
#
|
135
135
|
def syntax
|
136
136
|
return nil if @grpc.tokens.nil?
|
@@ -147,21 +147,22 @@ module Google
|
|
147
147
|
#
|
148
148
|
# language = Google::Cloud::Language.new
|
149
149
|
#
|
150
|
-
# content = "
|
150
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
151
151
|
# document = language.document content
|
152
152
|
# annotation = document.annotate
|
153
153
|
#
|
154
154
|
# entities = annotation.entities
|
155
|
-
# entities.count #=>
|
155
|
+
# entities.count #=> 3
|
156
156
|
# entity = entities.first
|
157
157
|
#
|
158
|
-
# entity.name #=> "
|
159
|
-
# entity.type #=> :
|
160
|
-
# entity.salience #=> 0.
|
158
|
+
# entity.name #=> "Star Wars"
|
159
|
+
# entity.type #=> :WORK_OF_ART
|
160
|
+
# entity.salience #=> 0.6457656025886536
|
161
161
|
# entity.mentions.count #=> 1
|
162
|
-
# entity.mentions.first.text # => "
|
162
|
+
# entity.mentions.first.text # => "Star Wars"
|
163
163
|
# entity.mentions.first.offset # => 0
|
164
|
-
# entity.
|
164
|
+
# entity.mid #=> "/m/06mmr"
|
165
|
+
# entity.wikipedia_url #=> "http://en.wikipedia.org/wiki/Star_Wars"
|
165
166
|
#
|
166
167
|
def entities
|
167
168
|
@entities ||= Entities.from_grpc @grpc
|
@@ -177,18 +178,18 @@ module Google
|
|
177
178
|
#
|
178
179
|
# language = Google::Cloud::Language.new
|
179
180
|
#
|
180
|
-
# content = "
|
181
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
181
182
|
# document = language.document content
|
182
183
|
# annotation = document.annotate
|
183
184
|
# sentiment = annotation.sentiment
|
184
185
|
#
|
185
|
-
# sentiment.score #=>
|
186
|
-
# sentiment.magnitude #=>
|
186
|
+
# sentiment.score #=> 0.10000000149011612
|
187
|
+
# sentiment.magnitude #=> 1.100000023841858
|
187
188
|
# sentiment.language #=> "en"
|
188
189
|
#
|
189
190
|
# sentence = sentiment.sentences.first
|
190
|
-
# sentence.sentiment.score #=>
|
191
|
-
# sentence.sentiment.magnitude #=> 0.
|
191
|
+
# sentence.sentiment.score #=> 0.699999988079071
|
192
|
+
# sentence.sentiment.magnitude #=> 0.699999988079071
|
192
193
|
#
|
193
194
|
def sentiment
|
194
195
|
return nil if @grpc.document_sentiment.nil?
|
@@ -207,7 +208,7 @@ module Google
|
|
207
208
|
#
|
208
209
|
# language = Google::Cloud::Language.new
|
209
210
|
#
|
210
|
-
# content = "
|
211
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
211
212
|
# document = language.document content
|
212
213
|
# annotation = document.annotate
|
213
214
|
# annotation.language #=> "en"
|
@@ -248,14 +249,14 @@ module Google
|
|
248
249
|
#
|
249
250
|
# language = Google::Cloud::Language.new
|
250
251
|
#
|
251
|
-
# content = "
|
252
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
252
253
|
# document = language.document content
|
253
254
|
# annotation = document.annotate
|
254
255
|
#
|
255
256
|
# sentence = annotation.sentences.last
|
256
257
|
# text_span = sentence.text_span
|
257
|
-
#
|
258
|
-
#
|
258
|
+
# sentence.text #=> "The Death Star is fearsome."
|
259
|
+
# sentence.offset #=> 28
|
259
260
|
#
|
260
261
|
class TextSpan
|
261
262
|
attr_reader :text, :offset
|
@@ -301,16 +302,16 @@ module Google
|
|
301
302
|
#
|
302
303
|
# language = Google::Cloud::Language.new
|
303
304
|
#
|
304
|
-
# content = "
|
305
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
305
306
|
# document = language.document content
|
306
307
|
# annotation = document.annotate
|
307
308
|
#
|
308
|
-
# annotation.tokens.count #=>
|
309
|
+
# annotation.tokens.count #=> 13
|
309
310
|
# token = annotation.tokens.first
|
310
311
|
#
|
311
|
-
# token.text_span.text #=> "
|
312
|
+
# token.text_span.text #=> "Star"
|
312
313
|
# token.part_of_speech.tag #=> :NOUN
|
313
|
-
# token.part_of_speech.
|
314
|
+
# token.part_of_speech.number #=> :SINGULAR
|
314
315
|
#
|
315
316
|
class PartOfSpeech
|
316
317
|
attr_reader :tag, :aspect, :case, :form, :gender, :mood, :number,
|
@@ -353,11 +354,14 @@ module Google
|
|
353
354
|
#
|
354
355
|
# language = Google::Cloud::Language.new
|
355
356
|
#
|
356
|
-
# content = "
|
357
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
357
358
|
# document = language.document content
|
358
359
|
# annotation = document.annotate
|
359
360
|
#
|
360
|
-
# annotation.sentences.count #=>
|
361
|
+
# annotation.sentences.count #=> 2
|
362
|
+
# sentence = annotation.sentences.first
|
363
|
+
# sentence.text #=> "Star Wars is a great movie."
|
364
|
+
# sentence.offset #=> 0
|
361
365
|
#
|
362
366
|
class Sentence
|
363
367
|
attr_reader :text_span, :sentiment
|
@@ -447,18 +451,19 @@ module Google
|
|
447
451
|
#
|
448
452
|
# language = Google::Cloud::Language.new
|
449
453
|
#
|
450
|
-
# content = "
|
454
|
+
# content = "Star Wars is a great movie. \
|
455
|
+
# The Death Star is fearsome."
|
451
456
|
# document = language.document content
|
452
457
|
# annotation = document.annotate
|
453
458
|
# sentiment = annotation.sentiment
|
454
459
|
#
|
455
|
-
# sentiment.score #=>
|
456
|
-
# sentiment.magnitude #=>
|
460
|
+
# sentiment.score #=> 0.10000000149011612
|
461
|
+
# sentiment.magnitude #=> 1.100000023841858
|
457
462
|
# sentiment.language #=> "en"
|
458
463
|
#
|
459
464
|
# sentence = sentiment.sentences.first
|
460
|
-
# sentence.sentiment.score #=>
|
461
|
-
# sentence.sentiment.magnitude #=> 0.
|
465
|
+
# sentence.sentiment.score #=> 0.699999988079071
|
466
|
+
# sentence.sentiment.magnitude #=> 0.699999988079071
|
462
467
|
#
|
463
468
|
class Sentiment
|
464
469
|
attr_reader :score, :magnitude
|
@@ -500,20 +505,20 @@ module Google
|
|
500
505
|
#
|
501
506
|
# language = Google::Cloud::Language.new
|
502
507
|
#
|
503
|
-
# content = "
|
508
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
504
509
|
# document = language.document content
|
505
510
|
# annotation = document.annotate
|
506
511
|
#
|
507
|
-
# annotation.tokens.count #=>
|
512
|
+
# annotation.tokens.count #=> 13
|
508
513
|
# token = annotation.tokens.first
|
509
514
|
#
|
510
|
-
# token.text_span.text #=> "
|
515
|
+
# token.text_span.text #=> "Star"
|
511
516
|
# token.text_span.offset #=> 0
|
512
517
|
# token.part_of_speech.tag #=> :NOUN
|
513
|
-
# token.part_of_speech.
|
518
|
+
# token.part_of_speech.number #=> :SINGULAR
|
514
519
|
# token.head_token_index #=> 1
|
515
|
-
# token.label #=> :
|
516
|
-
# token.lemma #=> "
|
520
|
+
# token.label #=> :TITLE
|
521
|
+
# token.lemma #=> "Star"
|
517
522
|
#
|
518
523
|
class Token
|
519
524
|
attr_reader :text_span, :part_of_speech, :head_token_index, :label,
|
@@ -567,25 +572,26 @@ module Google
|
|
567
572
|
#
|
568
573
|
# language = Google::Cloud::Language.new
|
569
574
|
#
|
570
|
-
# content = "
|
575
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
571
576
|
# document = language.document content
|
572
577
|
# annotation = document.annotate
|
573
578
|
#
|
574
579
|
# syntax = annotation.syntax
|
575
580
|
#
|
576
581
|
# sentence = syntax.sentences.last
|
577
|
-
# sentence.text #=> "
|
578
|
-
# sentence.offset #=>
|
582
|
+
# sentence.text #=> "The Death Star is fearsome."
|
583
|
+
# sentence.offset #=> 28
|
579
584
|
#
|
580
|
-
# syntax.tokens.count #=>
|
585
|
+
# syntax.tokens.count #=> 13
|
581
586
|
# token = syntax.tokens.first
|
582
587
|
#
|
583
|
-
# token.text #=> "
|
584
|
-
# token.offset #=> 0
|
585
|
-
# token.part_of_speech #=> :NOUN
|
588
|
+
# token.text_span.text #=> "Star"
|
589
|
+
# token.text_span.offset #=> 0
|
590
|
+
# token.part_of_speech.tag #=> :NOUN
|
591
|
+
# token.part_of_speech.number #=> :SINGULAR
|
586
592
|
# token.head_token_index #=> 1
|
587
|
-
# token.label #=> :
|
588
|
-
# token.lemma #=> "
|
593
|
+
# token.label #=> :TITLE
|
594
|
+
# token.lemma #=> "Star"
|
589
595
|
#
|
590
596
|
class Syntax
|
591
597
|
attr_reader :sentences, :tokens, :language
|
@@ -620,12 +626,12 @@ module Google
|
|
620
626
|
#
|
621
627
|
# language = Google::Cloud::Language.new
|
622
628
|
#
|
623
|
-
# content = "
|
629
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
624
630
|
# document = language.document content
|
625
631
|
# annotation = document.annotate
|
626
632
|
#
|
627
633
|
# entities = annotation.entities
|
628
|
-
# entities.count #=>
|
634
|
+
# entities.count #=> 3
|
629
635
|
# entities.people.count #=> 1
|
630
636
|
# entities.artwork.count #=> 1
|
631
637
|
#
|
@@ -745,21 +751,22 @@ module Google
|
|
745
751
|
#
|
746
752
|
# language = Google::Cloud::Language.new
|
747
753
|
#
|
748
|
-
# content = "
|
754
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
749
755
|
# document = language.document content
|
750
756
|
# annotation = document.annotate
|
751
757
|
#
|
752
758
|
# entities = annotation.entities
|
753
|
-
# entities.count #=>
|
759
|
+
# entities.count #=> 3
|
754
760
|
# entity = entities.first
|
755
761
|
#
|
756
|
-
# entity.name #=> "
|
757
|
-
# entity.type #=> :
|
758
|
-
# entity.salience #=> 0.
|
762
|
+
# entity.name #=> "Star Wars"
|
763
|
+
# entity.type #=> :WORK_OF_ART
|
764
|
+
# entity.salience #=> 0.6457656025886536
|
759
765
|
# entity.mentions.count #=> 1
|
760
|
-
# entity.mentions.first.text # => "
|
766
|
+
# entity.mentions.first.text # => "Star Wars"
|
761
767
|
# entity.mentions.first.offset # => 0
|
762
|
-
# entity.
|
768
|
+
# entity.mid #=> "/m/06mmr"
|
769
|
+
# entity.wikipedia_url #=> "http://en.wikipedia.org/wiki/Star_Wars"
|
763
770
|
#
|
764
771
|
class Entity
|
765
772
|
attr_reader :name, :type, :metadata, :salience, :mentions
|
@@ -897,18 +904,21 @@ module Google
|
|
897
904
|
#
|
898
905
|
# language = Google::Cloud::Language.new
|
899
906
|
#
|
900
|
-
# content = "
|
907
|
+
# content = "Star Wars is a great movie. \
|
908
|
+
# The Death Star is fearsome."
|
901
909
|
# document = language.document content
|
902
910
|
# annotation = document.annotate
|
903
911
|
#
|
904
912
|
# entities = annotation.entities
|
905
|
-
# entities.count #=>
|
913
|
+
# entities.count #=> 3
|
906
914
|
# entity = entities.first
|
907
915
|
#
|
908
916
|
# entity.mentions.count #=> 1
|
909
|
-
# entity.mentions.first
|
910
|
-
#
|
911
|
-
#
|
917
|
+
# mention = entity.mentions.first
|
918
|
+
# mention.text # => "Star Wars"
|
919
|
+
# mention.offset # => 0
|
920
|
+
# mention.proper? # => true
|
921
|
+
# mention.type # => :PROPER
|
912
922
|
#
|
913
923
|
class Mention
|
914
924
|
attr_reader :text_span, :type
|
@@ -992,13 +1002,13 @@ module Google
|
|
992
1002
|
#
|
993
1003
|
# language = Google::Cloud::Language.new
|
994
1004
|
#
|
995
|
-
# content = "
|
1005
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
996
1006
|
# document = language.document content
|
997
1007
|
# annotation = document.annotate
|
998
1008
|
#
|
999
1009
|
# sentiment = annotation.sentiment
|
1000
|
-
# sentiment.score #=>
|
1001
|
-
# sentiment.magnitude #=>
|
1010
|
+
# sentiment.score #=> 0.10000000149011612
|
1011
|
+
# sentiment.magnitude #=> 1.100000023841858
|
1002
1012
|
# sentiment.language #=> "en"
|
1003
1013
|
#
|
1004
1014
|
class Sentiment
|
@@ -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 =
|
25
|
+
SCOPE = V1::LanguageServiceClient::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)
|
@@ -38,15 +38,15 @@ module Google
|
|
38
38
|
#
|
39
39
|
# language = Google::Cloud::Language.new
|
40
40
|
#
|
41
|
-
# content = "
|
41
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
42
42
|
# document = language.document content
|
43
43
|
# annotation = document.annotate
|
44
44
|
#
|
45
|
-
# annotation.entities.count #=>
|
46
|
-
# annotation.sentiment.score #=>
|
47
|
-
# annotation.sentiment.magnitude #=>
|
48
|
-
# annotation.sentences.count #=>
|
49
|
-
# annotation.tokens.count #=>
|
45
|
+
# annotation.entities.count #=> 3
|
46
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
47
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
48
|
+
# annotation.sentences.count #=> 2
|
49
|
+
# annotation.tokens.count #=> 13
|
50
50
|
#
|
51
51
|
class Document
|
52
52
|
##
|
@@ -189,29 +189,29 @@ module Google
|
|
189
189
|
#
|
190
190
|
# language = Google::Cloud::Language.new
|
191
191
|
#
|
192
|
-
# content = "
|
192
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
193
193
|
# document = language.document content
|
194
194
|
# annotation = document.annotate
|
195
195
|
#
|
196
|
-
# annotation.sentiment.score #=>
|
197
|
-
# annotation.sentiment.magnitude #=>
|
198
|
-
# annotation.entities.count #=>
|
199
|
-
# annotation.sentences.count #=>
|
200
|
-
# annotation.tokens.count #=>
|
196
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
197
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
198
|
+
# annotation.entities.count #=> 3
|
199
|
+
# annotation.sentences.count #=> 2
|
200
|
+
# annotation.tokens.count #=> 13
|
201
201
|
#
|
202
202
|
# @example With feature flags:
|
203
203
|
# require "google/cloud/language"
|
204
204
|
#
|
205
205
|
# language = Google::Cloud::Language.new
|
206
206
|
#
|
207
|
-
# content = "
|
207
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
208
208
|
# document = language.document content
|
209
209
|
# annotation = document.annotate entities: true, text: true
|
210
210
|
#
|
211
211
|
# annotation.sentiment #=> nil
|
212
|
-
# annotation.entities.count #=>
|
213
|
-
# annotation.sentences.count #=>
|
214
|
-
# annotation.tokens.count #=>
|
212
|
+
# annotation.entities.count #=> 3
|
213
|
+
# annotation.sentences.count #=> 2
|
214
|
+
# annotation.tokens.count #=> 13
|
215
215
|
#
|
216
216
|
def annotate sentiment: false, entities: false, syntax: false,
|
217
217
|
encoding: nil
|
@@ -240,24 +240,24 @@ module Google
|
|
240
240
|
#
|
241
241
|
# language = Google::Cloud::Language.new
|
242
242
|
#
|
243
|
-
# content = "
|
243
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
244
244
|
# document = language.document content
|
245
245
|
#
|
246
246
|
# syntax = document.syntax
|
247
247
|
#
|
248
248
|
# sentence = syntax.sentences.last
|
249
|
-
# sentence.text #=> "
|
250
|
-
# sentence.offset #=>
|
249
|
+
# sentence.text #=> "The Death Star is fearsome."
|
250
|
+
# sentence.offset #=> 28
|
251
251
|
#
|
252
|
-
# syntax.tokens.count #=>
|
252
|
+
# syntax.tokens.count #=> 13
|
253
253
|
# token = syntax.tokens.first
|
254
254
|
#
|
255
|
-
# token.text #=> "
|
255
|
+
# token.text #=> "Star"
|
256
256
|
# token.offset #=> 0
|
257
257
|
# token.part_of_speech.tag #=> :NOUN
|
258
258
|
# token.head_token_index #=> 1
|
259
|
-
# token.label #=> :
|
260
|
-
# token.lemma #=> "
|
259
|
+
# token.label #=> :TITLE
|
260
|
+
# token.lemma #=> "Star"
|
261
261
|
#
|
262
262
|
def syntax encoding: nil
|
263
263
|
ensure_service!
|
@@ -280,15 +280,14 @@ module Google
|
|
280
280
|
#
|
281
281
|
# language = Google::Cloud::Language.new
|
282
282
|
#
|
283
|
-
#
|
284
|
-
#
|
285
|
-
#
|
283
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
284
|
+
# document = language.document content
|
285
|
+
# entities = document.entities # API call
|
286
286
|
#
|
287
|
-
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
291
|
-
# entities.first.type #=> :WORK_OF_ART
|
287
|
+
# entities.count #=> 3
|
288
|
+
# entities.first.name #=> "Star Wars"
|
289
|
+
# entities.first.type #=> :WORK_OF_ART
|
290
|
+
# entities.first.mid #=> "/m/06mmr"
|
292
291
|
#
|
293
292
|
def entities encoding: nil
|
294
293
|
ensure_service!
|
@@ -313,18 +312,18 @@ module Google
|
|
313
312
|
#
|
314
313
|
# language = Google::Cloud::Language.new
|
315
314
|
#
|
316
|
-
# content = "
|
315
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
317
316
|
# document = language.document content
|
318
317
|
#
|
319
318
|
# sentiment = document.sentiment
|
320
319
|
#
|
321
|
-
# sentiment.score #=>
|
322
|
-
# sentiment.magnitude #=>
|
320
|
+
# sentiment.score #=> 0.10000000149011612
|
321
|
+
# sentiment.magnitude #=> 1.100000023841858
|
323
322
|
# sentiment.language #=> "en"
|
324
323
|
#
|
325
324
|
# sentence = sentiment.sentences.first
|
326
|
-
# sentence.sentiment.score #=>
|
327
|
-
# sentence.sentiment.magnitude #=> 0.
|
325
|
+
# sentence.sentiment.score #=> 0.699999988079071
|
326
|
+
# sentence.sentiment.magnitude #=> 0.699999988079071
|
328
327
|
#
|
329
328
|
def sentiment encoding: nil
|
330
329
|
ensure_service!
|
@@ -37,14 +37,14 @@ module Google
|
|
37
37
|
#
|
38
38
|
# language = Google::Cloud::Language.new
|
39
39
|
#
|
40
|
-
# content = "
|
40
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
41
41
|
# annotation = language.annotate content
|
42
42
|
#
|
43
|
-
# annotation.sentiment.score #=>
|
44
|
-
# annotation.sentiment.magnitude #=>
|
45
|
-
# annotation.entities.count #=>
|
46
|
-
# annotation.sentences.count #=>
|
47
|
-
# annotation.tokens.count #=>
|
43
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
44
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
45
|
+
# annotation.entities.count #=> 3
|
46
|
+
# annotation.sentences.count #=> 2
|
47
|
+
# annotation.tokens.count #=> 13
|
48
48
|
#
|
49
49
|
class Project
|
50
50
|
##
|
@@ -216,14 +216,14 @@ module Google
|
|
216
216
|
#
|
217
217
|
# language = Google::Cloud::Language.new
|
218
218
|
#
|
219
|
-
# content = "
|
219
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
220
220
|
# annotation = language.annotate content
|
221
221
|
#
|
222
|
-
# annotation.sentiment.score #=>
|
223
|
-
# annotation.sentiment.magnitude #=>
|
224
|
-
# annotation.entities.count #=>
|
225
|
-
# annotation.sentences.count #=>
|
226
|
-
# annotation.tokens.count #=>
|
222
|
+
# annotation.sentiment.score #=> 0.10000000149011612
|
223
|
+
# annotation.sentiment.magnitude #=> 1.100000023841858
|
224
|
+
# annotation.entities.count #=> 3
|
225
|
+
# annotation.sentences.count #=> 2
|
226
|
+
# annotation.tokens.count #=> 13
|
227
227
|
#
|
228
228
|
def annotate content, sentiment: false, entities: false, syntax: false,
|
229
229
|
format: nil, language: nil, encoding: nil
|
@@ -263,24 +263,25 @@ module Google
|
|
263
263
|
#
|
264
264
|
# language = Google::Cloud::Language.new
|
265
265
|
#
|
266
|
-
#
|
266
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
267
|
+
# document = language.document content
|
267
268
|
#
|
268
269
|
# annotation = language.syntax document
|
269
270
|
# syntax = annotation.syntax
|
270
271
|
#
|
271
272
|
# sentence = syntax.sentences.last
|
272
|
-
# sentence.text #=> "
|
273
|
-
# sentence.offset #=>
|
273
|
+
# sentence.text #=> "The Death Star is fearsome."
|
274
|
+
# sentence.offset #=> 28
|
274
275
|
#
|
275
|
-
# syntax.tokens.count #=>
|
276
|
+
# syntax.tokens.count #=> 13
|
276
277
|
# token = syntax.tokens.first
|
277
278
|
#
|
278
|
-
# token.text #=> "
|
279
|
+
# token.text #=> "Star"
|
279
280
|
# token.offset #=> 0
|
280
281
|
# token.part_of_speech.tag #=> :NOUN
|
281
282
|
# token.head_token_index #=> 1
|
282
|
-
# token.label #=> :
|
283
|
-
# token.lemma #=> "
|
283
|
+
# token.label #=> :TITLE
|
284
|
+
# token.lemma #=> "Star"
|
284
285
|
#
|
285
286
|
def syntax content, format: nil, language: nil, encoding: nil
|
286
287
|
ensure_service!
|
@@ -312,10 +313,11 @@ module Google
|
|
312
313
|
#
|
313
314
|
# language = Google::Cloud::Language.new
|
314
315
|
#
|
315
|
-
#
|
316
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
317
|
+
# document = language.document content
|
316
318
|
#
|
317
319
|
# entities = language.entities document
|
318
|
-
# entities.count #=>
|
320
|
+
# entities.count #=> 3
|
319
321
|
#
|
320
322
|
def entities content, format: :text, language: nil, encoding: nil
|
321
323
|
ensure_service!
|
@@ -349,18 +351,18 @@ module Google
|
|
349
351
|
#
|
350
352
|
# language = Google::Cloud::Language.new
|
351
353
|
#
|
352
|
-
# content = "
|
354
|
+
# content = "Star Wars is a great movie. The Death Star is fearsome."
|
353
355
|
# document = language.document content
|
354
356
|
#
|
355
357
|
# sentiment = language.sentiment document
|
356
358
|
#
|
357
|
-
# sentiment.score #=>
|
358
|
-
# sentiment.magnitude #=>
|
359
|
+
# sentiment.score #=> 0.10000000149011612
|
360
|
+
# sentiment.magnitude #=> 1.100000023841858
|
359
361
|
# sentiment.language #=> "en"
|
360
362
|
#
|
361
363
|
# sentence = sentiment.sentences.first
|
362
|
-
# sentence.sentiment.score #=>
|
363
|
-
# sentence.sentiment.magnitude #=> 0.
|
364
|
+
# sentence.sentiment.score #=> 0.699999988079071
|
365
|
+
# sentence.sentiment.magnitude #=> 0.699999988079071
|
364
366
|
#
|
365
367
|
def sentiment content, format: :text, language: nil, encoding: nil
|
366
368
|
ensure_service!
|
@@ -33,7 +33,7 @@ module Google
|
|
33
33
|
timeout: nil
|
34
34
|
@project = project
|
35
35
|
@credentials = credentials
|
36
|
-
@host = host || V1::
|
36
|
+
@host = host || V1::LanguageServiceClient::SERVICE_ADDRESS
|
37
37
|
@client_config = client_config || {}
|
38
38
|
@timeout = timeout
|
39
39
|
end
|
@@ -52,7 +52,7 @@ module Google
|
|
52
52
|
|
53
53
|
def service
|
54
54
|
return mocked_service if mocked_service
|
55
|
-
@service ||= V1::
|
55
|
+
@service ||= V1::LanguageServiceClient.new(
|
56
56
|
service_path: host,
|
57
57
|
channel: channel,
|
58
58
|
timeout: timeout,
|
@@ -15,6 +15,29 @@
|
|
15
15
|
module Google
|
16
16
|
module Cloud
|
17
17
|
module Language
|
18
|
+
##
|
19
|
+
# The `Google::Cloud::Language::V1` module provides the following types:
|
20
|
+
#
|
21
|
+
# Class | Description
|
22
|
+
# ----- | -----------
|
23
|
+
# {Google::Cloud::Language::V1::AnalyzeEntitiesRequest} | The entity analysis request message.
|
24
|
+
# {Google::Cloud::Language::V1::AnalyzeEntitiesResponse} | The entity analysis response message.
|
25
|
+
# {Google::Cloud::Language::V1::AnalyzeSentimentRequest} | The sentiment analysis request message.
|
26
|
+
# {Google::Cloud::Language::V1::AnalyzeSentimentResponse} | The sentiment analysis response message.
|
27
|
+
# {Google::Cloud::Language::V1::AnalyzeSyntaxRequest} | The syntax analysis request message.
|
28
|
+
# {Google::Cloud::Language::V1::AnalyzeSyntaxResponse} | The syntax analysis response message.
|
29
|
+
# {Google::Cloud::Language::V1::AnnotateTextRequest} | The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call.
|
30
|
+
# {Google::Cloud::Language::V1::AnnotateTextRequest::Features} | All available features for sentiment, syntax, and semantic analysis.
|
31
|
+
# {Google::Cloud::Language::V1::DependencyEdge} | Represents dependency parse tree information for a token.
|
32
|
+
# {Google::Cloud::Language::V1::EncodingType} | Represents the text encoding that the caller uses to process the output.
|
33
|
+
# {Google::Cloud::Language::V1::Entity} | Represents a phrase in the text that is a known entity, such as a person, an organization, or location.
|
34
|
+
# {Google::Cloud::Language::V1::EntityMention} | Represents a mention for an entity in the text.
|
35
|
+
# {Google::Cloud::Language::V1::PartOfSpeech} | Represents part of speech information for a token.
|
36
|
+
# {Google::Cloud::Language::V1::Sentence} | Represents a sentence in the input document.
|
37
|
+
# {Google::Cloud::Language::V1::Sentiment} | Represents the feeling associated with the entire text or entities in the text.
|
38
|
+
# {Google::Cloud::Language::V1::TextSpan} | Represents an output piece of text.
|
39
|
+
# {Google::Cloud::Language::V1::Token} | Represents the smallest syntactic building block of the text.
|
40
|
+
#
|
18
41
|
module V1
|
19
42
|
# ================================================================ #
|
20
43
|
#
|
@@ -40,7 +63,8 @@ module Google
|
|
40
63
|
# **Current Language Restrictions:**
|
41
64
|
#
|
42
65
|
# * Only English, Spanish, and Japanese textual content
|
43
|
-
# are supported
|
66
|
+
# are supported, with the following additional restriction:
|
67
|
+
# * +analyzeSentiment+ only supports English text.
|
44
68
|
# If the language (either specified by the caller or automatically detected)
|
45
69
|
# is not supported by the called API method, an +INVALID_ARGUMENT+ error
|
46
70
|
# is returned.
|
@@ -82,8 +106,8 @@ module Google
|
|
82
106
|
# @return [Hash{String => String}]
|
83
107
|
# Metadata associated with the entity.
|
84
108
|
#
|
85
|
-
# Currently,
|
86
|
-
# The associated
|
109
|
+
# Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
|
110
|
+
# available. The associated keys are "wikipedia_url" and "mid", respectively.
|
87
111
|
# @!attribute [rw] salience
|
88
112
|
# @return [Float]
|
89
113
|
# The salience score associated with the entity in the [0, 1.0] range.
|
@@ -137,8 +161,7 @@ module Google
|
|
137
161
|
# Dependency tree parse for this token.
|
138
162
|
# @!attribute [rw] lemma
|
139
163
|
# @return [String]
|
140
|
-
# {Lemma}[https://en.wikipedia.org/wiki/Lemma_
|
141
|
-
# of the token.
|
164
|
+
# {Lemma}[https://en.wikipedia.org/wiki/Lemma_%28morphology%29] of the token.
|
142
165
|
class Token; end
|
143
166
|
|
144
167
|
# Represents the feeling associated with the entire text or entities in
|
@@ -154,7 +177,9 @@ module Google
|
|
154
177
|
# (positive sentiment.)
|
155
178
|
class Sentiment; end
|
156
179
|
|
157
|
-
# Represents part of speech information for a token.
|
180
|
+
# Represents part of speech information for a token. Parts of speech
|
181
|
+
# are as defined in
|
182
|
+
# http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
|
158
183
|
# @!attribute [rw] tag
|
159
184
|
# @return [Google::Cloud::Language::V1::PartOfSpeech::Tag]
|
160
185
|
# The part of speech tag.
|
@@ -482,7 +507,9 @@ module Google
|
|
482
507
|
end
|
483
508
|
end
|
484
509
|
|
485
|
-
# Represents dependency parse tree information for a token.
|
510
|
+
# Represents dependency parse tree information for a token. (For more
|
511
|
+
# information on dependency labels, see
|
512
|
+
# http://www.aclweb.org/anthology/P13-2017
|
486
513
|
# @!attribute [rw] head_token_index
|
487
514
|
# @return [Integer]
|
488
515
|
# Represents the head of this token in the dependency tree.
|
@@ -908,4 +935,4 @@ module Google
|
|
908
935
|
end
|
909
936
|
end
|
910
937
|
end
|
911
|
-
end
|
938
|
+
end
|
@@ -37,7 +37,7 @@ module Google
|
|
37
37
|
#
|
38
38
|
# @!attribute [r] language_service_stub
|
39
39
|
# @return [Google::Cloud::Language::V1::LanguageService::Stub]
|
40
|
-
class
|
40
|
+
class LanguageServiceClient
|
41
41
|
attr_reader :language_service_stub
|
42
42
|
|
43
43
|
# The default address of the service.
|
@@ -91,6 +91,7 @@ module Google
|
|
91
91
|
require "google/gax/grpc"
|
92
92
|
require "google/cloud/language/v1/language_service_services_pb"
|
93
93
|
|
94
|
+
|
94
95
|
google_api_client = "#{app_name}/#{app_version} " \
|
95
96
|
"#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
|
96
97
|
"ruby/#{RUBY_VERSION}".freeze
|
@@ -151,14 +152,14 @@ module Google
|
|
151
152
|
# @return [Google::Cloud::Language::V1::AnalyzeSentimentResponse]
|
152
153
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
153
154
|
# @example
|
154
|
-
# require "google/cloud/language/v1/
|
155
|
+
# require "google/cloud/language/v1/language_service_client"
|
155
156
|
#
|
156
157
|
# Document = Google::Cloud::Language::V1::Document
|
157
|
-
#
|
158
|
+
# LanguageServiceClient = Google::Cloud::Language::V1::LanguageServiceClient
|
158
159
|
#
|
159
|
-
#
|
160
|
+
# language_service_client = LanguageServiceClient.new
|
160
161
|
# document = Document.new
|
161
|
-
# response =
|
162
|
+
# response = language_service_client.analyze_sentiment(document)
|
162
163
|
|
163
164
|
def analyze_sentiment \
|
164
165
|
document,
|
@@ -184,16 +185,16 @@ module Google
|
|
184
185
|
# @return [Google::Cloud::Language::V1::AnalyzeEntitiesResponse]
|
185
186
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
186
187
|
# @example
|
187
|
-
# require "google/cloud/language/v1/
|
188
|
+
# require "google/cloud/language/v1/language_service_client"
|
188
189
|
#
|
189
190
|
# Document = Google::Cloud::Language::V1::Document
|
190
191
|
# EncodingType = Google::Cloud::Language::V1::EncodingType
|
191
|
-
#
|
192
|
+
# LanguageServiceClient = Google::Cloud::Language::V1::LanguageServiceClient
|
192
193
|
#
|
193
|
-
#
|
194
|
+
# language_service_client = LanguageServiceClient.new
|
194
195
|
# document = Document.new
|
195
196
|
# encoding_type = EncodingType::NONE
|
196
|
-
# response =
|
197
|
+
# response = language_service_client.analyze_entities(document, encoding_type)
|
197
198
|
|
198
199
|
def analyze_entities \
|
199
200
|
document,
|
@@ -220,16 +221,16 @@ module Google
|
|
220
221
|
# @return [Google::Cloud::Language::V1::AnalyzeSyntaxResponse]
|
221
222
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
222
223
|
# @example
|
223
|
-
# require "google/cloud/language/v1/
|
224
|
+
# require "google/cloud/language/v1/language_service_client"
|
224
225
|
#
|
225
226
|
# Document = Google::Cloud::Language::V1::Document
|
226
227
|
# EncodingType = Google::Cloud::Language::V1::EncodingType
|
227
|
-
#
|
228
|
+
# LanguageServiceClient = Google::Cloud::Language::V1::LanguageServiceClient
|
228
229
|
#
|
229
|
-
#
|
230
|
+
# language_service_client = LanguageServiceClient.new
|
230
231
|
# document = Document.new
|
231
232
|
# encoding_type = EncodingType::NONE
|
232
|
-
# response =
|
233
|
+
# response = language_service_client.analyze_syntax(document, encoding_type)
|
233
234
|
|
234
235
|
def analyze_syntax \
|
235
236
|
document,
|
@@ -257,18 +258,18 @@ module Google
|
|
257
258
|
# @return [Google::Cloud::Language::V1::AnnotateTextResponse]
|
258
259
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
259
260
|
# @example
|
260
|
-
# require "google/cloud/language/v1/
|
261
|
+
# require "google/cloud/language/v1/language_service_client"
|
261
262
|
#
|
262
263
|
# Document = Google::Cloud::Language::V1::Document
|
263
264
|
# EncodingType = Google::Cloud::Language::V1::EncodingType
|
264
265
|
# Features = Google::Cloud::Language::V1::AnnotateTextRequest::Features
|
265
|
-
#
|
266
|
+
# LanguageServiceClient = Google::Cloud::Language::V1::LanguageServiceClient
|
266
267
|
#
|
267
|
-
#
|
268
|
+
# language_service_client = LanguageServiceClient.new
|
268
269
|
# document = Document.new
|
269
270
|
# features = Features.new
|
270
271
|
# encoding_type = EncodingType::NONE
|
271
|
-
# response =
|
272
|
+
# response = language_service_client.annotate_text(document, features, encoding_type)
|
272
273
|
|
273
274
|
def annotate_text \
|
274
275
|
document,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-language
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -197,14 +197,14 @@ dependencies:
|
|
197
197
|
name: yard-doctest
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- - "
|
200
|
+
- - "<="
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 0.1.8
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
|
-
- - "
|
207
|
+
- - "<="
|
208
208
|
- !ruby/object:Gem::Version
|
209
209
|
version: 0.1.8
|
210
210
|
description: google-cloud-language is the official library for Google Cloud Natural
|
@@ -228,7 +228,7 @@ files:
|
|
228
228
|
- lib/google/cloud/language/service.rb
|
229
229
|
- lib/google/cloud/language/v1.rb
|
230
230
|
- lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb
|
231
|
-
- lib/google/cloud/language/v1/
|
231
|
+
- lib/google/cloud/language/v1/language_service_client.rb
|
232
232
|
- lib/google/cloud/language/v1/language_service_client_config.json
|
233
233
|
- lib/google/cloud/language/v1/language_service_pb.rb
|
234
234
|
- lib/google/cloud/language/v1/language_service_services_pb.rb
|
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
requirements: []
|
255
255
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.
|
256
|
+
rubygems_version: 2.6.10
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: API Client library for Google Cloud Natural Language API
|