aylien_text_api 0.4.0 → 0.5.0
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/Gemfile.lock +1 -1
- data/lib/aylien_text_api/client.rb +71 -30
- data/lib/aylien_text_api/connection.rb +7 -0
- data/lib/aylien_text_api/version.rb +1 -1
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_invalid_taxonomy.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/classify_with_invalid_params.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/classify_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/classify_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/classify_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/combined_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/combined_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/combined_with_text.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/combined_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/combined_with_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/combined_with_value_as_text.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/combined_with_value_as_valid_url.yml +77 -77
- data/spec/fixtures/aylien_text_api/client/concepts_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/concepts_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/concepts_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/concepts_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/concepts_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/concepts_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/concepts_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/entities_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/entities_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/entities_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/entities_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/entities_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/entities_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/entities_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/extract_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/extract_with_invalid_params.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/extract_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/extract_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/extract_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/extract_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/hashtags_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/hashtags_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/hashtags_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/hashtags_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/hashtags_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/hashtags_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/hashtags_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/image_tags_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/image_tags_with_invalid_params.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/image_tags_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/image_tags_with_valid_url.yml +8 -8
- data/spec/fixtures/aylien_text_api/client/image_tags_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/image_tags_with_value_as_valid_url.yml +8 -8
- data/spec/fixtures/aylien_text_api/client/language_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/language_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/language_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/language_with_valid_text.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/language_with_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/language_with_value_as_text.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/language_with_value_as_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/microformats_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/microformats_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/microformats_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/microformats_with_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/microformats_with_value_as_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/rate_limits.yml +53 -0
- data/spec/fixtures/aylien_text_api/client/rate_limits_with_invalid_client.yml +38 -0
- data/spec/fixtures/aylien_text_api/client/rate_limits_with_unauthenticated_client.yml +42 -0
- data/spec/fixtures/aylien_text_api/client/related_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/related_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/related_with_phrase.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/related_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/related_with_value_as_phrase.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/related_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/sentiment_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/sentiment_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/sentiment_with_text.yml +7 -7
- data/spec/fixtures/aylien_text_api/client/sentiment_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/sentiment_with_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/sentiment_with_value_as_text.yml +7 -7
- data/spec/fixtures/aylien_text_api/client/sentiment_with_value_as_valid_url.yml +6 -6
- data/spec/fixtures/aylien_text_api/client/summarize_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/summarize_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/summarize_with_title_and_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/summarize_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/summarize_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_text_and_title.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_text_and_without_title.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/summarize_with_value_as_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_params.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_unauthenticated_client.yml +3 -3
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_valid_url.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_text.yml +5 -5
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_valid_url.yml +5 -5
- data/spec/lib/aylien_text_api/classify.rb +1 -1
- data/spec/lib/aylien_text_api/client_spec.rb +1 -0
- data/spec/lib/aylien_text_api/rate_limits.rb +26 -0
- metadata +11 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32241b5e504b3607cd03ba3ce52b6ff041293fe5
|
|
4
|
+
data.tar.gz: d9afa0e66071345e5bf7ccfa8f4a846ead1fd01f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aea76530a27c218f2056f63da306f87bdb6583e8edbd6313242a2099f51da29c83c57bc426daafe3d40e1a014034c7f6230e53fe839d7196c182bb5cc2ee5dcc
|
|
7
|
+
data.tar.gz: 94bdff655d8b484500462919017f69a1ce84c4f480c89afb654130aeff638c22ee1b43a275f7ce360f5f8d9b05e3829ae17dc40ca33c162bfe036f089f0d327e
|
data/Gemfile.lock
CHANGED
|
@@ -49,7 +49,8 @@ module AylienTextApi
|
|
|
49
49
|
def extract(value=nil, params={})
|
|
50
50
|
endpoint, params, config = common_endpoint(value, params,
|
|
51
51
|
Configuration::ENDPOINTS[:extract])
|
|
52
|
-
Connection.new(endpoint, params, config)
|
|
52
|
+
@connection = Connection.new(endpoint, params, config)
|
|
53
|
+
@connection.request
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
# Like extract, but calls request! so an exception is raised
|
|
@@ -58,10 +59,11 @@ module AylienTextApi
|
|
|
58
59
|
def extract!(value=nil, params={})
|
|
59
60
|
endpoint, params, config = common_endpoint(value, params,
|
|
60
61
|
Configuration::ENDPOINTS[:extract])
|
|
61
|
-
Connection.new(endpoint, params, config)
|
|
62
|
+
@connection = Connection.new(endpoint, params, config)
|
|
63
|
+
@connection.request!
|
|
62
64
|
end
|
|
63
65
|
|
|
64
|
-
# Classifies a piece of text according to
|
|
66
|
+
# Classifies a piece of text according to the specified taxonomy.
|
|
65
67
|
#
|
|
66
68
|
# @param [String] value (nil) URL or Text
|
|
67
69
|
# @param [Hash] params The classify endpoint options
|
|
@@ -78,7 +80,8 @@ module AylienTextApi
|
|
|
78
80
|
def classify_by_taxonomy(value=nil, params={})
|
|
79
81
|
endpoint, params, config = common_endpoint(value, params,
|
|
80
82
|
Configuration::ENDPOINTS[:classify_by_taxonomy])
|
|
81
|
-
Connection.new(endpoint, params, config)
|
|
83
|
+
@connection = Connection.new(endpoint, params, config)
|
|
84
|
+
@connection.request
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
# Like classify_by_taxonomy, but calls request! so an exception is raised
|
|
@@ -87,7 +90,8 @@ module AylienTextApi
|
|
|
87
90
|
def classify_by_taxonomy!(value=nil, params={})
|
|
88
91
|
endpoint, params, config = common_endpoint(value, params,
|
|
89
92
|
Configuration::ENDPOINTS[:classify_by_taxonomy])
|
|
90
|
-
Connection.new(endpoint, params, config)
|
|
93
|
+
@connection = Connection.new(endpoint, params, config)
|
|
94
|
+
@connection.request!
|
|
91
95
|
end
|
|
92
96
|
|
|
93
97
|
# Classifies a piece of text according to IPTC NewsCode standard.
|
|
@@ -107,7 +111,8 @@ module AylienTextApi
|
|
|
107
111
|
def classify(value=nil, params={})
|
|
108
112
|
endpoint, params, config = common_endpoint(value, params,
|
|
109
113
|
Configuration::ENDPOINTS[:classify])
|
|
110
|
-
Connection.new(endpoint, params, config)
|
|
114
|
+
@connection = Connection.new(endpoint, params, config)
|
|
115
|
+
@connection.request
|
|
111
116
|
end
|
|
112
117
|
|
|
113
118
|
# Like classify, but calls request! so an exception is raised
|
|
@@ -116,7 +121,8 @@ module AylienTextApi
|
|
|
116
121
|
def classify!(value=nil, params={})
|
|
117
122
|
endpoint, params, config = common_endpoint(value, params,
|
|
118
123
|
Configuration::ENDPOINTS[:classify])
|
|
119
|
-
Connection.new(endpoint, params, config)
|
|
124
|
+
@connection = Connection.new(endpoint, params, config)
|
|
125
|
+
@connection.request!
|
|
120
126
|
end
|
|
121
127
|
|
|
122
128
|
# Extracts named entities mentioned in a document, disambiguates
|
|
@@ -138,7 +144,8 @@ module AylienTextApi
|
|
|
138
144
|
def concepts(value=nil, params={})
|
|
139
145
|
endpoint, params, config = common_endpoint(value, params,
|
|
140
146
|
Configuration::ENDPOINTS[:concepts])
|
|
141
|
-
Connection.new(endpoint, params, config)
|
|
147
|
+
@connection = Connection.new(endpoint, params, config)
|
|
148
|
+
@connection.request
|
|
142
149
|
end
|
|
143
150
|
|
|
144
151
|
# Like concepts, but calls request! so an exception is raised
|
|
@@ -147,7 +154,8 @@ module AylienTextApi
|
|
|
147
154
|
def concepts!(value=nil, params={})
|
|
148
155
|
endpoint, params, config = common_endpoint(value, params,
|
|
149
156
|
Configuration::ENDPOINTS[:concepts])
|
|
150
|
-
Connection.new(endpoint, params, config)
|
|
157
|
+
@connection = Connection.new(endpoint, params, config)
|
|
158
|
+
@connection.request!
|
|
151
159
|
end
|
|
152
160
|
|
|
153
161
|
# Suggests hashtags describing the document.
|
|
@@ -167,7 +175,8 @@ module AylienTextApi
|
|
|
167
175
|
def hashtags(value=nil, params={})
|
|
168
176
|
endpoint, params, config = common_endpoint(value, params,
|
|
169
177
|
Configuration::ENDPOINTS[:hashtags])
|
|
170
|
-
Connection.new(endpoint, params, config)
|
|
178
|
+
@connection = Connection.new(endpoint, params, config)
|
|
179
|
+
@connection.request
|
|
171
180
|
end
|
|
172
181
|
|
|
173
182
|
# Like hashtags, but calls request! so an exception is raised
|
|
@@ -176,7 +185,8 @@ module AylienTextApi
|
|
|
176
185
|
def hashtags!(value=nil, params={})
|
|
177
186
|
endpoint, params, config = common_endpoint(value, params,
|
|
178
187
|
Configuration::ENDPOINTS[:hashtags])
|
|
179
|
-
Connection.new(endpoint, params, config)
|
|
188
|
+
@connection = Connection.new(endpoint, params, config)
|
|
189
|
+
@connection.request!
|
|
180
190
|
end
|
|
181
191
|
|
|
182
192
|
# Extracts named entities (people, organizations and locations) and
|
|
@@ -198,7 +208,8 @@ module AylienTextApi
|
|
|
198
208
|
def entities(value=nil, params={})
|
|
199
209
|
endpoint, params, config = common_endpoint(value, params,
|
|
200
210
|
Configuration::ENDPOINTS[:entities])
|
|
201
|
-
Connection.new(endpoint, params, config)
|
|
211
|
+
@connection = Connection.new(endpoint, params, config)
|
|
212
|
+
@connection.request
|
|
202
213
|
end
|
|
203
214
|
|
|
204
215
|
# Like entities, but calls request! so an exception is raised
|
|
@@ -207,7 +218,8 @@ module AylienTextApi
|
|
|
207
218
|
def entities!(value=nil, params={})
|
|
208
219
|
endpoint, params, config = common_endpoint(value, params,
|
|
209
220
|
Configuration::ENDPOINTS[:entities])
|
|
210
|
-
Connection.new(endpoint, params, config)
|
|
221
|
+
@connection = Connection.new(endpoint, params, config)
|
|
222
|
+
@connection.request!
|
|
211
223
|
end
|
|
212
224
|
|
|
213
225
|
# Detects the main language a document is written in and returns it
|
|
@@ -225,7 +237,8 @@ module AylienTextApi
|
|
|
225
237
|
def language(value=nil, params={})
|
|
226
238
|
endpoint, params, config = common_endpoint(value, params,
|
|
227
239
|
Configuration::ENDPOINTS[:language])
|
|
228
|
-
Connection.new(endpoint, params, config)
|
|
240
|
+
@connection = Connection.new(endpoint, params, config)
|
|
241
|
+
@connection.request
|
|
229
242
|
end
|
|
230
243
|
|
|
231
244
|
# Like language, but calls request! so an exception is raised
|
|
@@ -234,7 +247,8 @@ module AylienTextApi
|
|
|
234
247
|
def language!(value=nil, params={})
|
|
235
248
|
endpoint, params, config = common_endpoint(value, params,
|
|
236
249
|
Configuration::ENDPOINTS[:language])
|
|
237
|
-
Connection.new(endpoint, params, config)
|
|
250
|
+
@connection = Connection.new(endpoint, params, config)
|
|
251
|
+
@connection.request!
|
|
238
252
|
end
|
|
239
253
|
|
|
240
254
|
# Detects sentiment of a document in terms of
|
|
@@ -255,7 +269,8 @@ module AylienTextApi
|
|
|
255
269
|
def sentiment(value=nil, params={})
|
|
256
270
|
endpoint, params, config = common_endpoint(value, params,
|
|
257
271
|
Configuration::ENDPOINTS[:sentiment])
|
|
258
|
-
Connection.new(endpoint, params, config)
|
|
272
|
+
@connection = Connection.new(endpoint, params, config)
|
|
273
|
+
@connection.request
|
|
259
274
|
end
|
|
260
275
|
|
|
261
276
|
# Like sentiment, but calls request! so an exception is raised
|
|
@@ -264,7 +279,8 @@ module AylienTextApi
|
|
|
264
279
|
def sentiment!(value=nil, params={})
|
|
265
280
|
endpoint, params, config = common_endpoint(value, params,
|
|
266
281
|
Configuration::ENDPOINTS[:sentiment])
|
|
267
|
-
Connection.new(endpoint, params, config)
|
|
282
|
+
@connection = Connection.new(endpoint, params, config)
|
|
283
|
+
@connection.request!
|
|
268
284
|
end
|
|
269
285
|
# Summarizes an article into a few key sentences.
|
|
270
286
|
#
|
|
@@ -293,7 +309,8 @@ module AylienTextApi
|
|
|
293
309
|
def summarize(value=nil, params={})
|
|
294
310
|
endpoint, params, config = common_endpoint(value, params,
|
|
295
311
|
Configuration::ENDPOINTS[:summarize])
|
|
296
|
-
Connection.new(endpoint, params, config)
|
|
312
|
+
@connection = Connection.new(endpoint, params, config)
|
|
313
|
+
@connection.request
|
|
297
314
|
end
|
|
298
315
|
|
|
299
316
|
# Like summarize, but calls request! so an exception is raised
|
|
@@ -302,7 +319,8 @@ module AylienTextApi
|
|
|
302
319
|
def summarize!(value=nil, params={})
|
|
303
320
|
endpoint, params, config = common_endpoint(value, params,
|
|
304
321
|
Configuration::ENDPOINTS[:summarize])
|
|
305
|
-
Connection.new(endpoint, params, config)
|
|
322
|
+
@connection = Connection.new(endpoint, params, config)
|
|
323
|
+
@connection.request!
|
|
306
324
|
end
|
|
307
325
|
|
|
308
326
|
# Returns phrases related to the provided unigram, or bigram.
|
|
@@ -320,7 +338,8 @@ module AylienTextApi
|
|
|
320
338
|
def related(value=nil, params={})
|
|
321
339
|
endpoint, params, config = common_endpoint(value, params,
|
|
322
340
|
Configuration::ENDPOINTS[:related])
|
|
323
|
-
Connection.new(endpoint, params, config)
|
|
341
|
+
@connection = Connection.new(endpoint, params, config)
|
|
342
|
+
@connection.request
|
|
324
343
|
end
|
|
325
344
|
|
|
326
345
|
# Like related, but calls request! so an exception is raised
|
|
@@ -329,7 +348,8 @@ module AylienTextApi
|
|
|
329
348
|
def related!(value=nil, params={})
|
|
330
349
|
endpoint, params, config = common_endpoint(value, params,
|
|
331
350
|
Configuration::ENDPOINTS[:related])
|
|
332
|
-
Connection.new(endpoint, params, config)
|
|
351
|
+
@connection = Connection.new(endpoint, params, config)
|
|
352
|
+
@connection.request!
|
|
333
353
|
end
|
|
334
354
|
|
|
335
355
|
# Return Microformats.
|
|
@@ -348,7 +368,8 @@ module AylienTextApi
|
|
|
348
368
|
def microformats(value=nil, params={})
|
|
349
369
|
endpoint, params, config = common_endpoint(value, params,
|
|
350
370
|
Configuration::ENDPOINTS[:microformats])
|
|
351
|
-
Connection.new(endpoint, params, config)
|
|
371
|
+
@connection = Connection.new(endpoint, params, config)
|
|
372
|
+
@connection.request
|
|
352
373
|
end
|
|
353
374
|
|
|
354
375
|
# Like microformats, but calls request! so an exception is raised
|
|
@@ -357,7 +378,8 @@ module AylienTextApi
|
|
|
357
378
|
def microformats!(value=nil, params={})
|
|
358
379
|
endpoint, params, config = common_endpoint(value, params,
|
|
359
380
|
Configuration::ENDPOINTS[:microformats])
|
|
360
|
-
Connection.new(endpoint, params, config)
|
|
381
|
+
@connection = Connection.new(endpoint, params, config)
|
|
382
|
+
@connection.request!
|
|
361
383
|
end
|
|
362
384
|
|
|
363
385
|
# Return Unsupervised Classify.
|
|
@@ -377,7 +399,8 @@ module AylienTextApi
|
|
|
377
399
|
def unsupervised_classify(value=nil, params={})
|
|
378
400
|
endpoint, params, config = common_endpoint(value, params,
|
|
379
401
|
Configuration::ENDPOINTS[:unsupervised_classify])
|
|
380
|
-
Connection.new(endpoint, params, config)
|
|
402
|
+
@connection = Connection.new(endpoint, params, config)
|
|
403
|
+
@connection.request
|
|
381
404
|
end
|
|
382
405
|
|
|
383
406
|
# Like unsupervised_classify, but calls request! so an exception is raised
|
|
@@ -386,7 +409,8 @@ module AylienTextApi
|
|
|
386
409
|
def unsupervised_classify!(value=nil, params={})
|
|
387
410
|
endpoint, params, config = common_endpoint(value, params,
|
|
388
411
|
Configuration::ENDPOINTS[:unsupervised_classify])
|
|
389
|
-
Connection.new(endpoint, params, config)
|
|
412
|
+
@connection = Connection.new(endpoint, params, config)
|
|
413
|
+
@connection.request!
|
|
390
414
|
end
|
|
391
415
|
|
|
392
416
|
# Runs multiple analysis operations in one API call.
|
|
@@ -404,7 +428,8 @@ module AylienTextApi
|
|
|
404
428
|
def combined(value=nil, params={})
|
|
405
429
|
endpoint, params, config = common_endpoint(value, params,
|
|
406
430
|
Configuration::ENDPOINTS[:combined])
|
|
407
|
-
Connection.new(endpoint, params, config)
|
|
431
|
+
@connection = Connection.new(endpoint, params, config)
|
|
432
|
+
@connection.request
|
|
408
433
|
end
|
|
409
434
|
|
|
410
435
|
# Like combined, but calls request! so an exception is raised
|
|
@@ -413,8 +438,10 @@ module AylienTextApi
|
|
|
413
438
|
def combined!(value=nil, params={})
|
|
414
439
|
endpoint, params, config = common_endpoint(value, params,
|
|
415
440
|
Configuration::ENDPOINTS[:combined])
|
|
416
|
-
Connection.new(endpoint, params, config)
|
|
441
|
+
@connection = Connection.new(endpoint, params, config)
|
|
442
|
+
@connection.request!
|
|
417
443
|
end
|
|
444
|
+
|
|
418
445
|
# Assigns relevant tags to an image.
|
|
419
446
|
#
|
|
420
447
|
# @param [String] value (nil) URL
|
|
@@ -427,7 +454,8 @@ module AylienTextApi
|
|
|
427
454
|
def image_tags(value=nil, params={})
|
|
428
455
|
endpoint, params, config = common_endpoint(value, params,
|
|
429
456
|
Configuration::ENDPOINTS[:image_tags])
|
|
430
|
-
Connection.new(endpoint, params, config)
|
|
457
|
+
@connection = Connection.new(endpoint, params, config)
|
|
458
|
+
@connection.request
|
|
431
459
|
end
|
|
432
460
|
|
|
433
461
|
# Like image_tags, but calls request! so an exception is raised
|
|
@@ -436,9 +464,22 @@ module AylienTextApi
|
|
|
436
464
|
def image_tags!(value=nil, params={})
|
|
437
465
|
endpoint, params, config = common_endpoint(value, params,
|
|
438
466
|
Configuration::ENDPOINTS[:image_tags])
|
|
439
|
-
Connection.new(endpoint, params, config)
|
|
467
|
+
@connection = Connection.new(endpoint, params, config)
|
|
468
|
+
@connection.request!
|
|
440
469
|
end
|
|
441
|
-
|
|
470
|
+
|
|
471
|
+
# Returns current client's rate limit values. If it gets failed,
|
|
472
|
+
# nil will be returned.
|
|
473
|
+
#
|
|
474
|
+
# @return [Hash, nil] A hash of result. See
|
|
475
|
+
# http://docs.aylien.com/docs/rate-limits for more information
|
|
476
|
+
# on the data returned.
|
|
477
|
+
def rate_limits
|
|
478
|
+
self.language text: "Hello world!" unless defined?(@connection)
|
|
479
|
+
|
|
480
|
+
(@connection || {}).rate_limits
|
|
481
|
+
end
|
|
482
|
+
|
|
442
483
|
private
|
|
443
484
|
|
|
444
485
|
def validate_uri(value)
|
|
@@ -19,6 +19,8 @@ require 'net/http'
|
|
|
19
19
|
|
|
20
20
|
module AylienTextApi
|
|
21
21
|
class Connection
|
|
22
|
+
attr_reader :rate_limits
|
|
23
|
+
|
|
22
24
|
def initialize(endpoint, params, config)
|
|
23
25
|
@config = config
|
|
24
26
|
@uri = URI.join(@config[:base_uri], endpoint)
|
|
@@ -41,6 +43,11 @@ module AylienTextApi
|
|
|
41
43
|
Net::HTTP.start(@uri.host, @uri.port, use_ssl: (@uri.scheme == 'https')) do |http|
|
|
42
44
|
response = http.request(@request)
|
|
43
45
|
if response.kind_of?(Net::HTTPSuccess)
|
|
46
|
+
@rate_limits = {
|
|
47
|
+
limit: response["X-RateLimit-Limit"],
|
|
48
|
+
remaining: response["X-RateLimit-Remaining"],
|
|
49
|
+
reset: response["X-RateLimit-Reset"]
|
|
50
|
+
}
|
|
44
51
|
JSON.parse(response.body, :symbolize_names => true)
|
|
45
52
|
else
|
|
46
53
|
klass = AylienTextApi::Error::ERRORS[response.code.to_i]
|
|
@@ -21,9 +21,9 @@ http_interactions:
|
|
|
21
21
|
message: Forbidden
|
|
22
22
|
headers:
|
|
23
23
|
Server:
|
|
24
|
-
- openresty/1.
|
|
24
|
+
- openresty/1.9.3.2
|
|
25
25
|
Date:
|
|
26
|
-
-
|
|
26
|
+
- Fri, 22 Jan 2016 13:17:57 GMT
|
|
27
27
|
Content-Type:
|
|
28
28
|
- text/plain; charset=us-ascii
|
|
29
29
|
Transfer-Encoding:
|
|
@@ -34,5 +34,5 @@ http_interactions:
|
|
|
34
34
|
encoding: UTF-8
|
|
35
35
|
string: Authentication parameters missing
|
|
36
36
|
http_version:
|
|
37
|
-
recorded_at:
|
|
37
|
+
recorded_at: Fri, 22 Jan 2016 13:17:57 GMT
|
|
38
38
|
recorded_with: VCR 2.9.3
|
|
@@ -25,9 +25,9 @@ http_interactions:
|
|
|
25
25
|
message: Bad Request
|
|
26
26
|
headers:
|
|
27
27
|
Server:
|
|
28
|
-
- openresty/1.
|
|
28
|
+
- openresty/1.9.3.2
|
|
29
29
|
Date:
|
|
30
|
-
-
|
|
30
|
+
- Fri, 22 Jan 2016 13:18:01 GMT
|
|
31
31
|
Content-Type:
|
|
32
32
|
- application/json;charset=UTF-8
|
|
33
33
|
Content-Length:
|
|
@@ -37,9 +37,9 @@ http_interactions:
|
|
|
37
37
|
X-Ratelimit-Limit:
|
|
38
38
|
- '207000'
|
|
39
39
|
X-Ratelimit-Remaining:
|
|
40
|
-
- '
|
|
40
|
+
- '206338'
|
|
41
41
|
X-Ratelimit-Reset:
|
|
42
|
-
- '
|
|
42
|
+
- '1453507200'
|
|
43
43
|
body:
|
|
44
44
|
encoding: UTF-8
|
|
45
45
|
string: |-
|
|
@@ -53,5 +53,5 @@ http_interactions:
|
|
|
53
53
|
}]
|
|
54
54
|
}
|
|
55
55
|
http_version:
|
|
56
|
-
recorded_at:
|
|
56
|
+
recorded_at: Fri, 22 Jan 2016 13:18:01 GMT
|
|
57
57
|
recorded_with: VCR 2.9.3
|
|
@@ -25,9 +25,9 @@ http_interactions:
|
|
|
25
25
|
message: Not Found
|
|
26
26
|
headers:
|
|
27
27
|
Server:
|
|
28
|
-
- openresty/1.
|
|
28
|
+
- openresty/1.9.3.2
|
|
29
29
|
Date:
|
|
30
|
-
-
|
|
30
|
+
- Fri, 22 Jan 2016 13:17:57 GMT
|
|
31
31
|
Content-Type:
|
|
32
32
|
- text/plain;charset=UTF-8
|
|
33
33
|
Content-Length:
|
|
@@ -37,12 +37,12 @@ http_interactions:
|
|
|
37
37
|
X-Ratelimit-Limit:
|
|
38
38
|
- '207000'
|
|
39
39
|
X-Ratelimit-Remaining:
|
|
40
|
-
- '
|
|
40
|
+
- '206351'
|
|
41
41
|
X-Ratelimit-Reset:
|
|
42
|
-
- '
|
|
42
|
+
- '1453507200'
|
|
43
43
|
body:
|
|
44
44
|
encoding: UTF-8
|
|
45
45
|
string: The requested resource could not be found.
|
|
46
46
|
http_version:
|
|
47
|
-
recorded_at:
|
|
47
|
+
recorded_at: Fri, 22 Jan 2016 13:17:57 GMT
|
|
48
48
|
recorded_with: VCR 2.9.3
|
|
@@ -25,9 +25,9 @@ http_interactions:
|
|
|
25
25
|
message: OK
|
|
26
26
|
headers:
|
|
27
27
|
Server:
|
|
28
|
-
- openresty/1.
|
|
28
|
+
- openresty/1.9.3.2
|
|
29
29
|
Date:
|
|
30
|
-
-
|
|
30
|
+
- Fri, 22 Jan 2016 13:18:02 GMT
|
|
31
31
|
Content-Type:
|
|
32
32
|
- application/json;charset=UTF-8
|
|
33
33
|
Content-Length:
|
|
@@ -37,9 +37,9 @@ http_interactions:
|
|
|
37
37
|
X-Ratelimit-Limit:
|
|
38
38
|
- '207000'
|
|
39
39
|
X-Ratelimit-Remaining:
|
|
40
|
-
- '
|
|
40
|
+
- '206337'
|
|
41
41
|
X-Ratelimit-Reset:
|
|
42
|
-
- '
|
|
42
|
+
- '1453507200'
|
|
43
43
|
body:
|
|
44
44
|
encoding: UTF-8
|
|
45
45
|
string: |-
|
|
@@ -71,5 +71,5 @@ http_interactions:
|
|
|
71
71
|
}]
|
|
72
72
|
}
|
|
73
73
|
http_version:
|
|
74
|
-
recorded_at:
|
|
74
|
+
recorded_at: Fri, 22 Jan 2016 13:18:02 GMT
|
|
75
75
|
recorded_with: VCR 2.9.3
|
data/spec/fixtures/aylien_text_api/client/classify_by_taxonomy_with_unauthenticated_client.yml
CHANGED
|
@@ -25,9 +25,9 @@ http_interactions:
|
|
|
25
25
|
message: Forbidden
|
|
26
26
|
headers:
|
|
27
27
|
Server:
|
|
28
|
-
- openresty/1.
|
|
28
|
+
- openresty/1.9.3.2
|
|
29
29
|
Date:
|
|
30
|
-
-
|
|
30
|
+
- Fri, 22 Jan 2016 13:17:59 GMT
|
|
31
31
|
Content-Type:
|
|
32
32
|
- text/plain; charset=us-ascii
|
|
33
33
|
Transfer-Encoding:
|
|
@@ -38,5 +38,5 @@ http_interactions:
|
|
|
38
38
|
encoding: UTF-8
|
|
39
39
|
string: Authentication failed
|
|
40
40
|
http_version:
|
|
41
|
-
recorded_at:
|
|
41
|
+
recorded_at: Fri, 22 Jan 2016 13:17:59 GMT
|
|
42
42
|
recorded_with: VCR 2.9.3
|