rosette_api 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 043eec6c3ad8b685d39a800f0ac35e3cc4eed855
4
- data.tar.gz: cae1f598d5dcc1d8a3253af1479aa9f2c180ebdf
3
+ metadata.gz: c0e44fba62441db386c9de6162b96d0ef5ee5d53
4
+ data.tar.gz: 37709ba67b19f1f2adf6b7935a13381b87e3b96e
5
5
  SHA512:
6
- metadata.gz: 7772af70981b1b2d49ecd0249a587ecbaeb800696f66527c0efb7b4d34ece71eaf56281a7e92ab75bb2c6ca936d5cfcaa328712eb45ce0fdea7738e30e5daf7d
7
- data.tar.gz: d30c2a814a7dcfedb1e6aacfd720fa0e16925707cc537e68ada5b4c69a572353ba6a2f640ecd0c610d16f765923222862925b26963b7a3ae44e07f28b97f5ce8
6
+ metadata.gz: 26a24f30812075f6d8d19f397751ac4f5fa3f9ae3c1ffb7adcd558a9da88dd61d1c3a9568756c967fbc6ec4c3a09b12a538441d147a7aeb2c05d66997210666a
7
+ data.tar.gz: d45e7ef7849f7e4fc05f60d202640b92251854c8606c4caf6a08cd08d1ed96ceb84f7e5bae402cb0c2ccc418da7bc66c48925c2b495d4ce6acc70d8c90dda5c1
@@ -24,7 +24,6 @@ class RequestBuilder
24
24
  @alternate_url = alternate_url
25
25
  @http_client = http_client
26
26
  @params = params
27
- @retries = 5
28
27
  @binding_version = binding_version
29
28
 
30
29
  end
@@ -173,17 +172,7 @@ class RequestBuilder
173
172
  if response.code != '200'
174
173
  message = JSON.parse(response.body)['message']
175
174
  code = JSON.parse(response.body)['code']
176
- if response.code == '429'
177
- if @retries != 0
178
- @retries = @retries - 1
179
- sleep 15
180
- self.get_response(http, request)
181
- else
182
- raise RosetteAPIError.new code, message
183
- end
184
- else
185
- raise RosetteAPIError.new code, message
186
- end
175
+ raise RosetteAPIError.new code, message
187
176
  else
188
177
  response_headers = {}
189
178
  response.header.each_header { |key, value| response_headers[key] = value }
data/lib/rosette_api.rb CHANGED
@@ -9,7 +9,7 @@ require_relative 'bad_request_format_error'
9
9
  # This class allows you to access all Rosette API endpoints.
10
10
  class RosetteAPI
11
11
  # Version of Ruby binding
12
- BINDING_VERSION = '1.3.0'
12
+ BINDING_VERSION = '1.4.0'
13
13
  # Rosette API language endpoint
14
14
  LANGUAGE_ENDPOINT = '/language'
15
15
  # Rosette API morphology endpoint
@@ -36,6 +36,8 @@ class RosetteAPI
36
36
  PING = '/ping'
37
37
  # Text Embedding endpoint
38
38
  TEXT_EMBEDDING = '/text-embedding'
39
+ # Syntactic Dependencies endpoint
40
+ SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'
39
41
 
40
42
  # Rosette API key
41
43
  attr_accessor :user_key
@@ -323,6 +325,23 @@ class RosetteAPI
323
325
  .send_post_request
324
326
  end
325
327
 
328
+ #
329
+ # Returns the vectors associated with the text
330
+ #
331
+ # ==== Attributes
332
+ #
333
+ # * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
334
+ #
335
+ # Returns list of linguistic sentences of the input.
336
+ def get_syntax_dependencies(params)
337
+ check_params params
338
+
339
+ params = params.load_params
340
+
341
+ RequestBuilder.new(@user_key, @alternate_url + SYNTACTIC_DEPENDENCIES_ENDPOINT, @http_client, params, BINDING_VERSION)
342
+ .send_post_request
343
+ end
344
+
326
345
  # Gets information about the Rosette API, returns name, build number
327
346
  # and build time.
328
347
  def info
data/tests/tests_spec.rb CHANGED
@@ -21,7 +21,7 @@ describe RosetteAPI do
21
21
  'User-Agent' => 'Ruby',
22
22
  'X-Rosetteapi-Key' => '0123456789',
23
23
  'X-Rosetteapi-Binding' => 'ruby',
24
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
24
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
25
25
  to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
26
26
  end
27
27
  it 'test language' do
@@ -57,7 +57,7 @@ describe RosetteAPI do
57
57
  'User-Agent' => 'Ruby',
58
58
  'X-Rosetteapi-Key' => '0123456789',
59
59
  'X-Rosetteapi-Binding' => 'ruby',
60
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
60
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
61
61
  to_return(:status => 200, :body => "{\"test\": \"morphology/complete\"}", :headers => {})
62
62
  end
63
63
  it 'test morphology complete' do
@@ -78,7 +78,7 @@ describe RosetteAPI do
78
78
  'User-Agent' => 'Ruby',
79
79
  'X-Rosetteapi-Key' => '0123456789',
80
80
  'X-Rosetteapi-Binding' => 'ruby',
81
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
81
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
82
82
  to_return(:status => 200, :body => "{\"test\": \"morphology/compound-components\"}", :headers => {})
83
83
  end
84
84
  it 'test morphology compound components' do
@@ -99,7 +99,7 @@ describe RosetteAPI do
99
99
  'User-Agent' => 'Ruby',
100
100
  'X-Rosetteapi-Key' => '0123456789',
101
101
  'X-Rosetteapi-Binding' => 'ruby',
102
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
102
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
103
103
  to_return(:status => 200, :body => "{\"test\": \"morphology/han-readings\"}", :headers => {})
104
104
  end
105
105
  it 'test morphology han readings' do
@@ -120,7 +120,7 @@ describe RosetteAPI do
120
120
  'User-Agent' => 'Ruby',
121
121
  'X-Rosetteapi-Key' => '0123456789',
122
122
  'X-Rosetteapi-Binding' => 'ruby',
123
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
123
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
124
124
  to_return(:status => 200, :body => "{\"test\": \"morphology/parts-of-speech\"}", :headers => {})
125
125
  end
126
126
  it 'test morphology parts of speech' do
@@ -141,7 +141,7 @@ describe RosetteAPI do
141
141
  'User-Agent' => 'Ruby',
142
142
  'X-Rosetteapi-Key' => '0123456789',
143
143
  'X-Rosetteapi-Binding' => 'ruby',
144
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
144
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
145
145
  to_return(:status => 200, :body => "{\"test\": \"morphology/lemmas\"}", :headers => {})
146
146
  end
147
147
  it 'test morphology lemmas' do
@@ -162,7 +162,7 @@ describe RosetteAPI do
162
162
  'User-Agent' => 'Ruby',
163
163
  'X-Rosetteapi-Key' => '0123456789',
164
164
  'X-Rosetteapi-Binding' => 'ruby',
165
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
165
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
166
166
  to_return(:status => 200, :body => "{\"test\": \"entities\"}", :headers => {})
167
167
  end
168
168
  it 'test entities' do
@@ -184,7 +184,7 @@ describe RosetteAPI do
184
184
  'User-Agent' => 'Ruby',
185
185
  'X-Rosetteapi-Key' => '0123456789',
186
186
  'X-Rosetteapi-Binding' => 'ruby',
187
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
187
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
188
188
  to_return(:status => 200, :body => "{\"test\": \"entities\"}", :headers => {})
189
189
  end
190
190
  it 'test entities without qids' do
@@ -215,7 +215,7 @@ describe RosetteAPI do
215
215
  'User-Agent' => 'Ruby',
216
216
  'X-Rosetteapi-Key' => '0123456789',
217
217
  'X-Rosetteapi-Binding' => 'ruby',
218
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
218
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
219
219
  to_return(:status => 200, :body => "{\"test\": \"categories\"}", :headers => {})
220
220
  end
221
221
  it 'test categories' do
@@ -236,7 +236,7 @@ describe RosetteAPI do
236
236
  'User-Agent' => 'Ruby',
237
237
  'X-Rosetteapi-Key' => '0123456789',
238
238
  'X-Rosetteapi-Binding' => 'ruby',
239
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
239
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
240
240
  to_return(:status => 200, :body => "{\"test\": \"relationships\"}", :headers => {})
241
241
  end
242
242
  it 'test relationships' do
@@ -258,7 +258,7 @@ describe RosetteAPI do
258
258
  'User-Agent' => 'Ruby',
259
259
  'X-Rosetteapi-Key' => '0123456789',
260
260
  'X-Rosetteapi-Binding' => 'ruby',
261
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
261
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
262
262
  to_return(:status => 200, :body => "{\"test\": \"name-translation\"}", :headers => {})
263
263
  end
264
264
  it 'test name translation' do
@@ -285,7 +285,7 @@ describe RosetteAPI do
285
285
  'User-Agent' => 'Ruby',
286
286
  'X-Rosetteapi-Key' => '0123456789',
287
287
  'X-Rosetteapi-Binding' => 'ruby',
288
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
288
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
289
289
  to_return(:status => 200, :body => "{\"test\": \"name-similarity\"}", :headers => {})
290
290
  end
291
291
  it 'test name similarity' do
@@ -320,7 +320,7 @@ describe RosetteAPI do
320
320
  'User-Agent' => 'Ruby',
321
321
  'X-Rosetteapi-Key' => '0123456789',
322
322
  'X-Rosetteapi-Binding' => 'ruby',
323
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
323
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
324
324
  to_return(:status => 200, :body => "{\"test\": \"tokens\"}", :headers => {})
325
325
  end
326
326
  it 'test tokens' do
@@ -341,7 +341,7 @@ describe RosetteAPI do
341
341
  'User-Agent' => 'Ruby',
342
342
  'X-Rosetteapi-Key' => '0123456789',
343
343
  'X-Rosetteapi-Binding' => 'ruby',
344
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
344
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
345
345
  to_return(:status => 200, :body => "{\"test\": \"sentences\"}", :headers => {})
346
346
  end
347
347
  it 'test sentences' do
@@ -392,7 +392,7 @@ describe RosetteAPI do
392
392
  'User-Agent' => 'Ruby',
393
393
  'X-Rosetteapi-Key' => '0123456789',
394
394
  'X-Rosetteapi-Binding' => 'ruby',
395
- 'X-Rosetteapi-Binding-Version' => '1.3.0',
395
+ 'X-Rosetteapi-Binding-Version' => '1.4.0',
396
396
  'X-RosetteApi-App' => 'ruby-app'}).
397
397
  to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
398
398
  end
@@ -429,7 +429,7 @@ describe RosetteAPI do
429
429
  'User-Agent' => 'Ruby',
430
430
  'X-Rosetteapi-Key' => '0123456789',
431
431
  'X-Rosetteapi-Binding' => 'ruby',
432
- 'X-Rosetteapi-Binding-Version' => '1.3.0'}).
432
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
433
433
  to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
434
434
  end
435
435
  it 'test text_embedding' do
@@ -440,5 +440,25 @@ describe RosetteAPI do
440
440
  end
441
441
  end
442
442
 
443
+ describe '.get_syntax_dependencies' do
444
+ before do
445
+ stub_request(:post, 'https://api.rosette.com/rest/v1/syntax/dependencies').
446
+ with(:body => @json,
447
+ :headers => {'Accept' => 'application/json',
448
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
449
+ 'Content-Type' => 'application/json',
450
+ 'User-Agent' => 'Ruby',
451
+ 'X-Rosetteapi-Key' => '0123456789',
452
+ 'X-Rosetteapi-Binding' => 'ruby',
453
+ 'X-Rosetteapi-Binding-Version' => '1.4.0'}).
454
+ to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
455
+ end
456
+ it 'test syntax_dependencies' do
457
+ params = DocumentParameters.new
458
+ params.content = @content
459
+ response = RosetteAPI.new('0123456789').get_syntax_dependencies(params)
460
+ expect(response).instance_of? Hash
461
+ end
462
+ end
443
463
 
444
464
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosette_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Basis Technology Corp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubysl-securerandom
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.6.6
64
+ rubygems_version: 2.6.7
65
65
  signing_key:
66
66
  specification_version: 2
67
67
  summary: Rosette API gem that supports multilingual text-analytics.