google-cloud-language 0.27.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb +48 -21
- data/lib/google/cloud/language/v1beta2/language_service_client.rb +131 -79
- data/lib/google/cloud/language/v1beta2/language_service_client_config.json +5 -0
- data/lib/google/cloud/language/v1beta2/language_service_pb.rb +15 -0
- data/lib/google/cloud/language/v1beta2/language_service_services_pb.rb +4 -2
- data/lib/google/cloud/language/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 640b2b45f1a1c1591831ec87517594559da9089e
|
4
|
+
data.tar.gz: 667181d885dd29cb5bf5638d9671b4e5070bfd75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7466b754816e35ad9da93f510a7666073c5e4852310f4d9ee8b76700ebf51fa4be842eb868fce581fb7a55df349d81c25cddaec3ce12a92b10b4b37de3ce692
|
7
|
+
data.tar.gz: a0dbb87e8d94baadbf8c7e9110775bbf11c007754aa73c49b8da878ba9461809d7ecaaf8be064806b0e8313156340ac1ba9b71d5b3197e1315cc66488acc66b9
|
data/.yardopts
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
--no-private
|
2
2
|
--title=Google Cloud Language
|
3
3
|
--exclude lib/google/cloud/language/v1.rb
|
4
|
+
--exclude lib/google/cloud/language/v1/language_service_pb.rb
|
5
|
+
--exclude lib/google/cloud/language/v1/language_service_services_pb.rb
|
6
|
+
--exclude lib/google/cloud/language/v1beta2/language_service_pb.rb
|
7
|
+
--exclude lib/google/cloud/language/v1beta2/language_service_services_pb.rb
|
4
8
|
--markup markdown
|
5
9
|
|
6
10
|
./lib/**/*.rb
|
data/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb
CHANGED
@@ -37,9 +37,8 @@ module Google
|
|
37
37
|
# The language of the document (if not specified, the language is
|
38
38
|
# automatically detected). Both ISO and BCP-47 language codes are
|
39
39
|
# accepted.<br>
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# * Only English, Spanish, and Japanese textual content are supported.
|
40
|
+
# [Language Support](https://cloud.google.com/natural-language/docs/languages)
|
41
|
+
# lists currently supported languages for each API method.
|
43
42
|
# If the language (either specified by the caller or automatically detected)
|
44
43
|
# is not supported by the called API method, an +INVALID_ARGUMENT+ error
|
45
44
|
# is returned.
|
@@ -63,8 +62,8 @@ module Google
|
|
63
62
|
# The sentence text.
|
64
63
|
# @!attribute [rw] sentiment
|
65
64
|
# @return [Google::Cloud::Language::V1beta2::Sentiment]
|
66
|
-
# For calls to AnalyzeSentiment or if
|
67
|
-
# AnnotateTextRequest::Features#extract_document_sentiment is set to
|
65
|
+
# For calls to {AnalyzeSentiment} or if
|
66
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment} is set to
|
68
67
|
# true, this field will contain the sentiment for the sentence.
|
69
68
|
class Sentence; end
|
70
69
|
|
@@ -97,8 +96,8 @@ module Google
|
|
97
96
|
# supports proper noun mentions.
|
98
97
|
# @!attribute [rw] sentiment
|
99
98
|
# @return [Google::Cloud::Language::V1beta2::Sentiment]
|
100
|
-
# For calls to AnalyzeEntitySentiment or if
|
101
|
-
# AnnotateTextRequest::Features#extract_entity_sentiment is set to
|
99
|
+
# For calls to {AnalyzeEntitySentiment} or if
|
100
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to
|
102
101
|
# true, this field will contain the aggregate sentiment expressed for this
|
103
102
|
# entity in the provided document.
|
104
103
|
class Entity
|
@@ -142,7 +141,7 @@ module Google
|
|
142
141
|
# Dependency tree parse for this token.
|
143
142
|
# @!attribute [rw] lemma
|
144
143
|
# @return [String]
|
145
|
-
#
|
144
|
+
# [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.
|
146
145
|
class Token; end
|
147
146
|
|
148
147
|
# Represents the feeling associated with the entire text or entities in
|
@@ -743,8 +742,8 @@ module Google
|
|
743
742
|
# The type of the entity mention.
|
744
743
|
# @!attribute [rw] sentiment
|
745
744
|
# @return [Google::Cloud::Language::V1beta2::Sentiment]
|
746
|
-
# For calls to AnalyzeEntitySentiment or if
|
747
|
-
# AnnotateTextRequest::Features#extract_entity_sentiment is set to
|
745
|
+
# For calls to {AnalyzeEntitySentiment} or if
|
746
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to
|
748
747
|
# true, this field will contain the sentiment expressed for this mention of
|
749
748
|
# the entity in the provided document.
|
750
749
|
class EntityMention
|
@@ -768,14 +767,23 @@ module Google
|
|
768
767
|
# @!attribute [rw] begin_offset
|
769
768
|
# @return [Integer]
|
770
769
|
# The API calculates the beginning offset of the content in the original
|
771
|
-
# document according to the EncodingType specified in the API request.
|
770
|
+
# document according to the {Google::Cloud::Language::V1beta2::EncodingType EncodingType} specified in the API request.
|
772
771
|
class TextSpan; end
|
773
772
|
|
773
|
+
# Represents a category returned from the text classifier.
|
774
|
+
# @!attribute [rw] name
|
775
|
+
# @return [String]
|
776
|
+
# The name of the category representing the document.
|
777
|
+
# @!attribute [rw] confidence
|
778
|
+
# @return [Float]
|
779
|
+
# The classifier's confidence of the category. Number represents how certain
|
780
|
+
# the classifier is that this category represents the given text.
|
781
|
+
class ClassificationCategory; end
|
782
|
+
|
774
783
|
# The sentiment analysis request message.
|
775
784
|
# @!attribute [rw] document
|
776
785
|
# @return [Google::Cloud::Language::V1beta2::Document]
|
777
|
-
# Input document.
|
778
|
-
# (Document#language="EN").
|
786
|
+
# Input document.
|
779
787
|
# @!attribute [rw] encoding_type
|
780
788
|
# @return [Google::Cloud::Language::V1beta2::EncodingType]
|
781
789
|
# The encoding type used by the API to calculate sentence offsets for the
|
@@ -790,6 +798,7 @@ module Google
|
|
790
798
|
# @return [String]
|
791
799
|
# The language of the text, which will be the same as the language specified
|
792
800
|
# in the request or, if not specified, the automatically-detected language.
|
801
|
+
# See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
|
793
802
|
# @!attribute [rw] sentences
|
794
803
|
# @return [Array<Google::Cloud::Language::V1beta2::Sentence>]
|
795
804
|
# The sentiment for all the sentences in the document.
|
@@ -812,7 +821,7 @@ module Google
|
|
812
821
|
# @return [String]
|
813
822
|
# The language of the text, which will be the same as the language specified
|
814
823
|
# in the request or, if not specified, the automatically-detected language.
|
815
|
-
# See Document#language field for more details.
|
824
|
+
# See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
|
816
825
|
class AnalyzeEntitySentimentResponse; end
|
817
826
|
|
818
827
|
# The entity analysis request message.
|
@@ -832,7 +841,7 @@ module Google
|
|
832
841
|
# @return [String]
|
833
842
|
# The language of the text, which will be the same as the language specified
|
834
843
|
# in the request or, if not specified, the automatically-detected language.
|
835
|
-
# See Document#language field for more details.
|
844
|
+
# See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
|
836
845
|
class AnalyzeEntitiesResponse; end
|
837
846
|
|
838
847
|
# The syntax analysis request message.
|
@@ -855,9 +864,21 @@ module Google
|
|
855
864
|
# @return [String]
|
856
865
|
# The language of the text, which will be the same as the language specified
|
857
866
|
# in the request or, if not specified, the automatically-detected language.
|
858
|
-
# See Document#language field for more details.
|
867
|
+
# See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
|
859
868
|
class AnalyzeSyntaxResponse; end
|
860
869
|
|
870
|
+
# The document classification request message.
|
871
|
+
# @!attribute [rw] document
|
872
|
+
# @return [Google::Cloud::Language::V1beta2::Document]
|
873
|
+
# Input document.
|
874
|
+
class ClassifyTextRequest; end
|
875
|
+
|
876
|
+
# The document classification response message.
|
877
|
+
# @!attribute [rw] categories
|
878
|
+
# @return [Array<Google::Cloud::Language::V1beta2::ClassificationCategory>]
|
879
|
+
# Categories representing the input document.
|
880
|
+
class ClassifyTextResponse; end
|
881
|
+
|
861
882
|
# The request message for the text annotation API, which can perform multiple
|
862
883
|
# analysis types (sentiment, entities, and syntax) in one call.
|
863
884
|
# @!attribute [rw] document
|
@@ -884,6 +905,9 @@ module Google
|
|
884
905
|
# @!attribute [rw] extract_entity_sentiment
|
885
906
|
# @return [true, false]
|
886
907
|
# Extract entities and their associated sentiment.
|
908
|
+
# @!attribute [rw] classify_text
|
909
|
+
# @return [true, false]
|
910
|
+
# Classify the full document into categories.
|
887
911
|
class Features; end
|
888
912
|
end
|
889
913
|
|
@@ -891,26 +915,29 @@ module Google
|
|
891
915
|
# @!attribute [rw] sentences
|
892
916
|
# @return [Array<Google::Cloud::Language::V1beta2::Sentence>]
|
893
917
|
# Sentences in the input document. Populated if the user enables
|
894
|
-
# AnnotateTextRequest::Features#extract_syntax.
|
918
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}.
|
895
919
|
# @!attribute [rw] tokens
|
896
920
|
# @return [Array<Google::Cloud::Language::V1beta2::Token>]
|
897
921
|
# Tokens, along with their syntactic information, in the input document.
|
898
922
|
# Populated if the user enables
|
899
|
-
# AnnotateTextRequest::Features#extract_syntax.
|
923
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}.
|
900
924
|
# @!attribute [rw] entities
|
901
925
|
# @return [Array<Google::Cloud::Language::V1beta2::Entity>]
|
902
926
|
# Entities, along with their semantic information, in the input document.
|
903
927
|
# Populated if the user enables
|
904
|
-
# AnnotateTextRequest::Features#extract_entities.
|
928
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entities AnnotateTextRequest::Features#extract_entities}.
|
905
929
|
# @!attribute [rw] document_sentiment
|
906
930
|
# @return [Google::Cloud::Language::V1beta2::Sentiment]
|
907
931
|
# The overall sentiment for the document. Populated if the user enables
|
908
|
-
# AnnotateTextRequest::Features#extract_document_sentiment.
|
932
|
+
# {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment}.
|
909
933
|
# @!attribute [rw] language
|
910
934
|
# @return [String]
|
911
935
|
# The language of the text, which will be the same as the language specified
|
912
936
|
# in the request or, if not specified, the automatically-detected language.
|
913
|
-
# See Document#language field for more details.
|
937
|
+
# See {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details.
|
938
|
+
# @!attribute [rw] categories
|
939
|
+
# @return [Array<Google::Cloud::Language::V1beta2::ClassificationCategory>]
|
940
|
+
# Categories identified in the input document.
|
914
941
|
class AnnotateTextResponse; end
|
915
942
|
|
916
943
|
# Represents the text encoding that the caller uses to process the output.
|
@@ -28,6 +28,7 @@ require "pathname"
|
|
28
28
|
require "google/gax"
|
29
29
|
|
30
30
|
require "google/cloud/language/v1beta2/language_service_pb"
|
31
|
+
require "google/cloud/language/credentials"
|
31
32
|
|
32
33
|
module Google
|
33
34
|
module Cloud
|
@@ -55,17 +56,21 @@ module Google
|
|
55
56
|
"https://www.googleapis.com/auth/cloud-platform"
|
56
57
|
].freeze
|
57
58
|
|
58
|
-
# @param
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
59
|
+
# @param credentials
|
60
|
+
# [Google::Gax::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
61
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
62
|
+
# be many types.
|
63
|
+
# A `Google::Gax::Credentials` uses a the properties of its represented keyfile for
|
64
|
+
# authenticating requests made by this client.
|
65
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
66
|
+
# credentials for this client.
|
67
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
68
|
+
# credentials for this client.
|
69
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
70
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
71
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
72
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
73
|
+
# metadata for requests, generally, to give OAuth credentials.
|
69
74
|
# @param scopes [Array<String>]
|
70
75
|
# The OAuth scopes for this service. This parameter is ignored if
|
71
76
|
# an updater_proc is supplied.
|
@@ -82,11 +87,10 @@ module Google
|
|
82
87
|
channel: nil,
|
83
88
|
chan_creds: nil,
|
84
89
|
updater_proc: nil,
|
90
|
+
credentials: nil,
|
85
91
|
scopes: ALL_SCOPES,
|
86
92
|
client_config: {},
|
87
93
|
timeout: DEFAULT_TIMEOUT,
|
88
|
-
app_name: nil,
|
89
|
-
app_version: nil,
|
90
94
|
lib_name: nil,
|
91
95
|
lib_version: ""
|
92
96
|
# These require statements are intentionally placed here to initialize
|
@@ -95,9 +99,33 @@ module Google
|
|
95
99
|
require "google/gax/grpc"
|
96
100
|
require "google/cloud/language/v1beta2/language_service_services_pb"
|
97
101
|
|
102
|
+
if channel || chan_creds || updater_proc
|
103
|
+
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
104
|
+
"on 2017/09/08"
|
105
|
+
credentials ||= channel
|
106
|
+
credentials ||= chan_creds
|
107
|
+
credentials ||= updater_proc
|
108
|
+
end
|
109
|
+
if service_path || port
|
110
|
+
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
111
|
+
end
|
98
112
|
|
99
|
-
|
100
|
-
|
113
|
+
credentials ||= Google::Cloud::Language::Credentials.default
|
114
|
+
|
115
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
116
|
+
updater_proc = Google::Cloud::Language::Credentials.new(credentials).updater_proc
|
117
|
+
end
|
118
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
119
|
+
channel = credentials
|
120
|
+
end
|
121
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
122
|
+
chan_creds = credentials
|
123
|
+
end
|
124
|
+
if credentials.is_a?(Proc)
|
125
|
+
updater_proc = credentials
|
126
|
+
end
|
127
|
+
if credentials.is_a?(Google::Gax::Credentials)
|
128
|
+
updater_proc = credentials.updater_proc
|
101
129
|
end
|
102
130
|
|
103
131
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
@@ -147,6 +175,10 @@ module Google
|
|
147
175
|
@language_service_stub.method(:analyze_syntax),
|
148
176
|
defaults["analyze_syntax"]
|
149
177
|
)
|
178
|
+
@classify_text = Google::Gax.create_api_call(
|
179
|
+
@language_service_stub.method(:classify_text),
|
180
|
+
defaults["classify_text"]
|
181
|
+
)
|
150
182
|
@annotate_text = Google::Gax.create_api_call(
|
151
183
|
@language_service_stub.method(:annotate_text),
|
152
184
|
defaults["annotate_text"]
|
@@ -157,9 +189,10 @@ module Google
|
|
157
189
|
|
158
190
|
# Analyzes the sentiment of the provided text.
|
159
191
|
#
|
160
|
-
# @param document [Google::Cloud::Language::V1beta2::Document]
|
161
|
-
# Input document.
|
162
|
-
#
|
192
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
193
|
+
# Input document.
|
194
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
195
|
+
# can also be provided.
|
163
196
|
# @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType]
|
164
197
|
# The encoding type used by the API to calculate sentence offsets for the
|
165
198
|
# sentence sentiment.
|
@@ -171,21 +204,19 @@ module Google
|
|
171
204
|
# @example
|
172
205
|
# require "google/cloud/language/v1beta2"
|
173
206
|
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
# language_service_client = LanguageServiceClient.new
|
178
|
-
# document = Document.new
|
207
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
208
|
+
# document = {}
|
179
209
|
# response = language_service_client.analyze_sentiment(document)
|
180
210
|
|
181
211
|
def analyze_sentiment \
|
182
212
|
document,
|
183
213
|
encoding_type: nil,
|
184
214
|
options: nil
|
185
|
-
req =
|
215
|
+
req = {
|
186
216
|
document: document,
|
187
217
|
encoding_type: encoding_type
|
188
|
-
}.delete_if { |_, v| v.nil? }
|
218
|
+
}.delete_if { |_, v| v.nil? }
|
219
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest)
|
189
220
|
@analyze_sentiment.call(req, options)
|
190
221
|
end
|
191
222
|
|
@@ -193,8 +224,10 @@ module Google
|
|
193
224
|
# along with entity types, salience, mentions for each entity, and
|
194
225
|
# other properties.
|
195
226
|
#
|
196
|
-
# @param document [Google::Cloud::Language::V1beta2::Document]
|
227
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
197
228
|
# Input document.
|
229
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
230
|
+
# can also be provided.
|
198
231
|
# @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType]
|
199
232
|
# The encoding type used by the API to calculate offsets.
|
200
233
|
# @param options [Google::Gax::CallOptions]
|
@@ -205,31 +238,29 @@ module Google
|
|
205
238
|
# @example
|
206
239
|
# require "google/cloud/language/v1beta2"
|
207
240
|
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
# language_service_client = LanguageServiceClient.new
|
213
|
-
# document = Document.new
|
214
|
-
# encoding_type = EncodingType::NONE
|
215
|
-
# response = language_service_client.analyze_entities(document, encoding_type)
|
241
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
242
|
+
# document = {}
|
243
|
+
# response = language_service_client.analyze_entities(document)
|
216
244
|
|
217
245
|
def analyze_entities \
|
218
246
|
document,
|
219
|
-
encoding_type,
|
247
|
+
encoding_type: nil,
|
220
248
|
options: nil
|
221
|
-
req =
|
249
|
+
req = {
|
222
250
|
document: document,
|
223
251
|
encoding_type: encoding_type
|
224
|
-
}.delete_if { |_, v| v.nil? }
|
252
|
+
}.delete_if { |_, v| v.nil? }
|
253
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest)
|
225
254
|
@analyze_entities.call(req, options)
|
226
255
|
end
|
227
256
|
|
228
|
-
# Finds entities, similar to AnalyzeEntities in the text and analyzes
|
257
|
+
# Finds entities, similar to {Google::Cloud::Language::V1beta2::LanguageService::AnalyzeEntities AnalyzeEntities} in the text and analyzes
|
229
258
|
# sentiment associated with each entity and its mentions.
|
230
259
|
#
|
231
|
-
# @param document [Google::Cloud::Language::V1beta2::Document]
|
260
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
232
261
|
# Input document.
|
262
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
263
|
+
# can also be provided.
|
233
264
|
# @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType]
|
234
265
|
# The encoding type used by the API to calculate offsets.
|
235
266
|
# @param options [Google::Gax::CallOptions]
|
@@ -240,23 +271,19 @@ module Google
|
|
240
271
|
# @example
|
241
272
|
# require "google/cloud/language/v1beta2"
|
242
273
|
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
# language_service_client = LanguageServiceClient.new
|
248
|
-
# document = Document.new
|
249
|
-
# encoding_type = EncodingType::NONE
|
250
|
-
# response = language_service_client.analyze_entity_sentiment(document, encoding_type)
|
274
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
275
|
+
# document = {}
|
276
|
+
# response = language_service_client.analyze_entity_sentiment(document)
|
251
277
|
|
252
278
|
def analyze_entity_sentiment \
|
253
279
|
document,
|
254
|
-
encoding_type,
|
280
|
+
encoding_type: nil,
|
255
281
|
options: nil
|
256
|
-
req =
|
282
|
+
req = {
|
257
283
|
document: document,
|
258
284
|
encoding_type: encoding_type
|
259
|
-
}.delete_if { |_, v| v.nil? }
|
285
|
+
}.delete_if { |_, v| v.nil? }
|
286
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest)
|
260
287
|
@analyze_entity_sentiment.call(req, options)
|
261
288
|
end
|
262
289
|
|
@@ -264,8 +291,10 @@ module Google
|
|
264
291
|
# tokenization along with part of speech tags, dependency trees, and other
|
265
292
|
# properties.
|
266
293
|
#
|
267
|
-
# @param document [Google::Cloud::Language::V1beta2::Document]
|
294
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
268
295
|
# Input document.
|
296
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
297
|
+
# can also be provided.
|
269
298
|
# @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType]
|
270
299
|
# The encoding type used by the API to calculate offsets.
|
271
300
|
# @param options [Google::Gax::CallOptions]
|
@@ -276,33 +305,61 @@ module Google
|
|
276
305
|
# @example
|
277
306
|
# require "google/cloud/language/v1beta2"
|
278
307
|
#
|
279
|
-
#
|
280
|
-
#
|
281
|
-
#
|
282
|
-
#
|
283
|
-
# language_service_client = LanguageServiceClient.new
|
284
|
-
# document = Document.new
|
285
|
-
# encoding_type = EncodingType::NONE
|
286
|
-
# response = language_service_client.analyze_syntax(document, encoding_type)
|
308
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
309
|
+
# document = {}
|
310
|
+
# response = language_service_client.analyze_syntax(document)
|
287
311
|
|
288
312
|
def analyze_syntax \
|
289
313
|
document,
|
290
|
-
encoding_type,
|
314
|
+
encoding_type: nil,
|
291
315
|
options: nil
|
292
|
-
req =
|
316
|
+
req = {
|
293
317
|
document: document,
|
294
318
|
encoding_type: encoding_type
|
295
|
-
}.delete_if { |_, v| v.nil? }
|
319
|
+
}.delete_if { |_, v| v.nil? }
|
320
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest)
|
296
321
|
@analyze_syntax.call(req, options)
|
297
322
|
end
|
298
323
|
|
299
|
-
#
|
300
|
-
# features in one call.
|
324
|
+
# Classifies a document into categories.
|
301
325
|
#
|
302
|
-
# @param document [Google::Cloud::Language::V1beta2::Document]
|
326
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
303
327
|
# Input document.
|
304
|
-
#
|
328
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
329
|
+
# can also be provided.
|
330
|
+
# @param options [Google::Gax::CallOptions]
|
331
|
+
# Overrides the default settings for this call, e.g, timeout,
|
332
|
+
# retries, etc.
|
333
|
+
# @return [Google::Cloud::Language::V1beta2::ClassifyTextResponse]
|
334
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
335
|
+
# @example
|
336
|
+
# require "google/cloud/language/v1beta2"
|
337
|
+
#
|
338
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
339
|
+
# document = {}
|
340
|
+
# response = language_service_client.classify_text(document)
|
341
|
+
|
342
|
+
def classify_text \
|
343
|
+
document,
|
344
|
+
options: nil
|
345
|
+
req = {
|
346
|
+
document: document
|
347
|
+
}.delete_if { |_, v| v.nil? }
|
348
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::ClassifyTextRequest)
|
349
|
+
@classify_text.call(req, options)
|
350
|
+
end
|
351
|
+
|
352
|
+
# A convenience method that provides all syntax, sentiment, entity, and
|
353
|
+
# classification features in one call.
|
354
|
+
#
|
355
|
+
# @param document [Google::Cloud::Language::V1beta2::Document | Hash]
|
356
|
+
# Input document.
|
357
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::Document`
|
358
|
+
# can also be provided.
|
359
|
+
# @param features [Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features | Hash]
|
305
360
|
# The enabled features.
|
361
|
+
# A hash of the same form as `Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features`
|
362
|
+
# can also be provided.
|
306
363
|
# @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType]
|
307
364
|
# The encoding type used by the API to calculate offsets.
|
308
365
|
# @param options [Google::Gax::CallOptions]
|
@@ -313,27 +370,22 @@ module Google
|
|
313
370
|
# @example
|
314
371
|
# require "google/cloud/language/v1beta2"
|
315
372
|
#
|
316
|
-
#
|
317
|
-
#
|
318
|
-
#
|
319
|
-
#
|
320
|
-
#
|
321
|
-
# language_service_client = LanguageServiceClient.new
|
322
|
-
# document = Document.new
|
323
|
-
# features = Features.new
|
324
|
-
# encoding_type = EncodingType::NONE
|
325
|
-
# response = language_service_client.annotate_text(document, features, encoding_type)
|
373
|
+
# language_service_client = Google::Cloud::Language::V1beta2.new
|
374
|
+
# document = {}
|
375
|
+
# features = {}
|
376
|
+
# response = language_service_client.annotate_text(document, features)
|
326
377
|
|
327
378
|
def annotate_text \
|
328
379
|
document,
|
329
380
|
features,
|
330
|
-
encoding_type,
|
381
|
+
encoding_type: nil,
|
331
382
|
options: nil
|
332
|
-
req =
|
383
|
+
req = {
|
333
384
|
document: document,
|
334
385
|
features: features,
|
335
386
|
encoding_type: encoding_type
|
336
|
-
}.delete_if { |_, v| v.nil? }
|
387
|
+
}.delete_if { |_, v| v.nil? }
|
388
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnnotateTextRequest)
|
337
389
|
@annotate_text.call(req, options)
|
338
390
|
end
|
339
391
|
end
|
@@ -40,6 +40,11 @@
|
|
40
40
|
"retry_codes_name": "idempotent",
|
41
41
|
"retry_params_name": "default"
|
42
42
|
},
|
43
|
+
"ClassifyText": {
|
44
|
+
"timeout_millis": 30000,
|
45
|
+
"retry_codes_name": "idempotent",
|
46
|
+
"retry_params_name": "default"
|
47
|
+
},
|
43
48
|
"AnnotateText": {
|
44
49
|
"timeout_millis": 30000,
|
45
50
|
"retry_codes_name": "idempotent",
|
@@ -270,6 +270,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
270
270
|
optional :content, :string, 1
|
271
271
|
optional :begin_offset, :int32, 2
|
272
272
|
end
|
273
|
+
add_message "google.cloud.language.v1beta2.ClassificationCategory" do
|
274
|
+
optional :name, :string, 1
|
275
|
+
optional :confidence, :float, 2
|
276
|
+
end
|
273
277
|
add_message "google.cloud.language.v1beta2.AnalyzeSentimentRequest" do
|
274
278
|
optional :document, :message, 1, "google.cloud.language.v1beta2.Document"
|
275
279
|
optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType"
|
@@ -304,6 +308,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
304
308
|
repeated :tokens, :message, 2, "google.cloud.language.v1beta2.Token"
|
305
309
|
optional :language, :string, 3
|
306
310
|
end
|
311
|
+
add_message "google.cloud.language.v1beta2.ClassifyTextRequest" do
|
312
|
+
optional :document, :message, 1, "google.cloud.language.v1beta2.Document"
|
313
|
+
end
|
314
|
+
add_message "google.cloud.language.v1beta2.ClassifyTextResponse" do
|
315
|
+
repeated :categories, :message, 1, "google.cloud.language.v1beta2.ClassificationCategory"
|
316
|
+
end
|
307
317
|
add_message "google.cloud.language.v1beta2.AnnotateTextRequest" do
|
308
318
|
optional :document, :message, 1, "google.cloud.language.v1beta2.Document"
|
309
319
|
optional :features, :message, 2, "google.cloud.language.v1beta2.AnnotateTextRequest.Features"
|
@@ -314,6 +324,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
314
324
|
optional :extract_entities, :bool, 2
|
315
325
|
optional :extract_document_sentiment, :bool, 3
|
316
326
|
optional :extract_entity_sentiment, :bool, 4
|
327
|
+
optional :classify_text, :bool, 6
|
317
328
|
end
|
318
329
|
add_message "google.cloud.language.v1beta2.AnnotateTextResponse" do
|
319
330
|
repeated :sentences, :message, 1, "google.cloud.language.v1beta2.Sentence"
|
@@ -321,6 +332,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
321
332
|
repeated :entities, :message, 3, "google.cloud.language.v1beta2.Entity"
|
322
333
|
optional :document_sentiment, :message, 4, "google.cloud.language.v1beta2.Sentiment"
|
323
334
|
optional :language, :string, 5
|
335
|
+
repeated :categories, :message, 6, "google.cloud.language.v1beta2.ClassificationCategory"
|
324
336
|
end
|
325
337
|
add_enum "google.cloud.language.v1beta2.EncodingType" do
|
326
338
|
value :NONE, 0
|
@@ -359,6 +371,7 @@ module Google
|
|
359
371
|
EntityMention = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EntityMention").msgclass
|
360
372
|
EntityMention::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EntityMention.Type").enummodule
|
361
373
|
TextSpan = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.TextSpan").msgclass
|
374
|
+
ClassificationCategory = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationCategory").msgclass
|
362
375
|
AnalyzeSentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentRequest").msgclass
|
363
376
|
AnalyzeSentimentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentResponse").msgclass
|
364
377
|
AnalyzeEntitySentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest").msgclass
|
@@ -367,6 +380,8 @@ module Google
|
|
367
380
|
AnalyzeEntitiesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitiesResponse").msgclass
|
368
381
|
AnalyzeSyntaxRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSyntaxRequest").msgclass
|
369
382
|
AnalyzeSyntaxResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSyntaxResponse").msgclass
|
383
|
+
ClassifyTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassifyTextRequest").msgclass
|
384
|
+
ClassifyTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassifyTextResponse").msgclass
|
370
385
|
AnnotateTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextRequest").msgclass
|
371
386
|
AnnotateTextRequest::Features = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextRequest.Features").msgclass
|
372
387
|
AnnotateTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextResponse").msgclass
|
@@ -47,8 +47,10 @@ module Google
|
|
47
47
|
# tokenization along with part of speech tags, dependency trees, and other
|
48
48
|
# properties.
|
49
49
|
rpc :AnalyzeSyntax, AnalyzeSyntaxRequest, AnalyzeSyntaxResponse
|
50
|
-
#
|
51
|
-
|
50
|
+
# Classifies a document into categories.
|
51
|
+
rpc :ClassifyText, ClassifyTextRequest, ClassifyTextResponse
|
52
|
+
# A convenience method that provides all syntax, sentiment, entity, and
|
53
|
+
# classification features in one call.
|
52
54
|
rpc :AnnotateText, AnnotateTextRequest, AnnotateTextResponse
|
53
55
|
end
|
54
56
|
|
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.27.
|
4
|
+
version: 0.27.1
|
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: 2017-
|
12
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.6.
|
221
|
+
rubygems_version: 2.6.13
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
224
|
summary: API Client library for Google Cloud Natural Language API
|