rosette_api 1.9.2 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rosette_api.rb +40 -3
- data/tests/tests_spec.rb +45 -25
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d65a80d194b5956cf0a742db19a6076b05aace36a082697ab01a27fb9be14a2a
|
4
|
+
data.tar.gz: 22f92f9b67f0533c042d32a5c1ee249b5ac4034ba1abab66d317b3ee8658c78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca25172ef0ef615051922a8a849c3d7d11755b806f004df9eb2c0c6a131a8a203cac560aeb72c88224e0078c759553048548883cf74640f4c63168618380cf92
|
7
|
+
data.tar.gz: a3d64fd9539dbacb98489e60ac19d45b6eac4e1f80edf2e8bfc433d3f8713a966448d2ddbbaf87e62a86b6fe76f23189c794a9984a957bfdf207968463882acd
|
data/lib/rosette_api.rb
CHANGED
@@ -10,7 +10,7 @@ require_relative 'bad_request_format_error'
|
|
10
10
|
# This class allows you to access all Rosette API endpoints.
|
11
11
|
class RosetteAPI
|
12
12
|
# Version of Ruby binding
|
13
|
-
BINDING_VERSION = '1.
|
13
|
+
BINDING_VERSION = '1.12.1'
|
14
14
|
# Rosette API language endpoint
|
15
15
|
LANGUAGE_ENDPOINT = '/language'.freeze
|
16
16
|
# Rosette API morphology endpoint
|
@@ -37,8 +37,12 @@ class RosetteAPI
|
|
37
37
|
INFO = '/info'.freeze
|
38
38
|
# Rosette API ping endpoint
|
39
39
|
PING = '/ping'.freeze
|
40
|
-
# Text Embedding endpoint
|
40
|
+
# Text Embedding endpoint (deprecated)
|
41
41
|
TEXT_EMBEDDING = '/text-embedding'.freeze
|
42
|
+
# Semantic Vectors endpoint (replaces /text-embedding)
|
43
|
+
SEMANTIC_VECTORS = '/semantics/vector'.freeze
|
44
|
+
# Similar Terms endpoint
|
45
|
+
SIMILAR_TERMS_ENDPOINT = '/semantics/similar'.freeze
|
42
46
|
# Syntactic Dependencies endpoint
|
43
47
|
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'.freeze
|
44
48
|
# Transliteration endpoint
|
@@ -320,11 +324,13 @@ class RosetteAPI
|
|
320
324
|
#
|
321
325
|
# Returns the vectors associated with the text
|
322
326
|
#
|
327
|
+
# Deprecated. Please use `get_semantic_vectors` instead
|
328
|
+
#
|
323
329
|
# ==== Attributes
|
324
330
|
#
|
325
331
|
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
326
332
|
#
|
327
|
-
# Returns
|
333
|
+
# Returns the text embedding representation of the input.
|
328
334
|
def get_text_embedding(params)
|
329
335
|
check_params params
|
330
336
|
|
@@ -341,6 +347,21 @@ class RosetteAPI
|
|
341
347
|
#
|
342
348
|
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
343
349
|
#
|
350
|
+
# Returns the text embedding representation of the input.
|
351
|
+
def get_semantic_vectors(params)
|
352
|
+
check_params params
|
353
|
+
params = params.load_params
|
354
|
+
RequestBuilder.new(@user_key, @alternate_url + SEMANTIC_VECTORS, @http_client, params, @url_parameters, BINDING_VERSION)
|
355
|
+
.send_post_request
|
356
|
+
end
|
357
|
+
|
358
|
+
#
|
359
|
+
# Returns the syntactic structure of the text
|
360
|
+
#
|
361
|
+
# ==== Attributes
|
362
|
+
#
|
363
|
+
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
364
|
+
#
|
344
365
|
# Returns list of linguistic sentences of the input.
|
345
366
|
def get_syntax_dependencies(params)
|
346
367
|
check_params params
|
@@ -384,6 +405,22 @@ class RosetteAPI
|
|
384
405
|
.send_post_request
|
385
406
|
end
|
386
407
|
|
408
|
+
# Returns the terms similar to the input
|
409
|
+
#
|
410
|
+
# ==== Attributes
|
411
|
+
#
|
412
|
+
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
413
|
+
#
|
414
|
+
# Returns a mapping of languageCode to similar terms
|
415
|
+
def get_similar_terms(params)
|
416
|
+
check_params params
|
417
|
+
|
418
|
+
params = params.load_params
|
419
|
+
|
420
|
+
RequestBuilder.new(@user_key, @alternate_url + SIMILAR_TERMS_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
421
|
+
.send_post_request
|
422
|
+
end
|
423
|
+
|
387
424
|
# Gets information about the Rosette API, returns name, build number
|
388
425
|
# and build time.
|
389
426
|
def info
|
data/tests/tests_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe RosetteAPI do
|
|
29
29
|
'User-Agent' => @user_agent,
|
30
30
|
'X-Rosetteapi-Key' => '0123456789',
|
31
31
|
'X-Rosetteapi-Binding' => 'ruby',
|
32
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
32
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
33
33
|
.to_return(status: 200, body: '{"test": "language"}', headers: {})
|
34
34
|
end
|
35
35
|
it 'test language' do
|
@@ -63,7 +63,7 @@ describe RosetteAPI do
|
|
63
63
|
'User-Agent' => @user_agent,
|
64
64
|
'X-Rosetteapi-Key' => '0123456789',
|
65
65
|
'X-Rosetteapi-Binding' => 'ruby',
|
66
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
66
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
67
67
|
.to_return(status: 200, body: '{"test": "morphology/complete"}', headers: {})
|
68
68
|
end
|
69
69
|
it 'test morphology complete' do
|
@@ -84,7 +84,7 @@ describe RosetteAPI do
|
|
84
84
|
'User-Agent' => @user_agent,
|
85
85
|
'X-Rosetteapi-Key' => '0123456789',
|
86
86
|
'X-Rosetteapi-Binding' => 'ruby',
|
87
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
87
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
88
88
|
.to_return(status: 200, body: '{"test": "morphology/compound-components"}', headers: {})
|
89
89
|
end
|
90
90
|
it 'test morphology compound components' do
|
@@ -105,7 +105,7 @@ describe RosetteAPI do
|
|
105
105
|
'User-Agent' => @user_agent,
|
106
106
|
'X-Rosetteapi-Key' => '0123456789',
|
107
107
|
'X-Rosetteapi-Binding' => 'ruby',
|
108
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
108
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
109
109
|
.to_return(status: 200, body: '{"test": "morphology/han-readings"}', headers: {})
|
110
110
|
end
|
111
111
|
it 'test morphology han readings' do
|
@@ -126,7 +126,7 @@ describe RosetteAPI do
|
|
126
126
|
'User-Agent' => @user_agent,
|
127
127
|
'X-Rosetteapi-Key' => '0123456789',
|
128
128
|
'X-Rosetteapi-Binding' => 'ruby',
|
129
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
129
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
130
130
|
.to_return(status: 200, body: '{"test": "morphology/parts-of-speech"}', headers: {})
|
131
131
|
end
|
132
132
|
it 'test morphology parts of speech' do
|
@@ -147,7 +147,7 @@ describe RosetteAPI do
|
|
147
147
|
'User-Agent' => @user_agent,
|
148
148
|
'X-Rosetteapi-Key' => '0123456789',
|
149
149
|
'X-Rosetteapi-Binding' => 'ruby',
|
150
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
150
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
151
151
|
.to_return(status: 200, body: '{"test": "morphology/lemmas"}', headers: {})
|
152
152
|
end
|
153
153
|
it 'test morphology lemmas' do
|
@@ -168,7 +168,7 @@ describe RosetteAPI do
|
|
168
168
|
'User-Agent' => @user_agent,
|
169
169
|
'X-Rosetteapi-Key' => '0123456789',
|
170
170
|
'X-Rosetteapi-Binding' => 'ruby',
|
171
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
171
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
172
172
|
.to_return(status: 200, body: '{"test": "entities"}', headers: {})
|
173
173
|
end
|
174
174
|
it 'test entities' do
|
@@ -190,7 +190,7 @@ describe RosetteAPI do
|
|
190
190
|
'User-Agent' => @user_agent,
|
191
191
|
'X-Rosetteapi-Key' => '0123456789',
|
192
192
|
'X-Rosetteapi-Binding' => 'ruby',
|
193
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
193
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
194
194
|
.to_return(status: 200, body: '{"test": "entities"}', headers: {})
|
195
195
|
end
|
196
196
|
it 'test entities without qids' do
|
@@ -221,7 +221,7 @@ describe RosetteAPI do
|
|
221
221
|
'User-Agent' => @user_agent,
|
222
222
|
'X-Rosetteapi-Key' => '0123456789',
|
223
223
|
'X-Rosetteapi-Binding' => 'ruby',
|
224
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
224
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
225
225
|
.to_return(status: 200, body: '{"test": "categories"}', headers: {})
|
226
226
|
end
|
227
227
|
it 'test categories' do
|
@@ -242,7 +242,7 @@ describe RosetteAPI do
|
|
242
242
|
'User-Agent' => @user_agent,
|
243
243
|
'X-Rosetteapi-Key' => '0123456789',
|
244
244
|
'X-Rosetteapi-Binding' => 'ruby',
|
245
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
245
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
246
246
|
.to_return(status: 200, body: '{"test": "relationships"}', headers: {})
|
247
247
|
end
|
248
248
|
it 'test relationships' do
|
@@ -264,7 +264,7 @@ describe RosetteAPI do
|
|
264
264
|
'User-Agent' => @user_agent,
|
265
265
|
'X-Rosetteapi-Key' => '0123456789',
|
266
266
|
'X-Rosetteapi-Binding' => 'ruby',
|
267
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
267
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
268
268
|
.to_return(status: 200, body: '{"test": "name-translation"}', headers: {})
|
269
269
|
end
|
270
270
|
it 'test name translation' do
|
@@ -291,7 +291,7 @@ describe RosetteAPI do
|
|
291
291
|
'User-Agent' => @user_agent,
|
292
292
|
'X-Rosetteapi-Key' => '0123456789',
|
293
293
|
'X-Rosetteapi-Binding' => 'ruby',
|
294
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
294
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
295
295
|
.to_return(status: 200, body: '{"test": "name-similarity"}', headers: {})
|
296
296
|
end
|
297
297
|
it 'test name similarity' do
|
@@ -329,7 +329,7 @@ describe RosetteAPI do
|
|
329
329
|
'User-Agent' => @user_agent,
|
330
330
|
'X-Rosetteapi-Key' => '0123456789',
|
331
331
|
'X-Rosetteapi-Binding' => 'ruby',
|
332
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
332
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
333
333
|
.to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {})
|
334
334
|
|
335
335
|
nothresh_json = { names: names.map(&:load_param) }.to_json
|
@@ -342,7 +342,7 @@ describe RosetteAPI do
|
|
342
342
|
'User-Agent' => @user_agent,
|
343
343
|
'X-Rosetteapi-Key' => '0123456789',
|
344
344
|
'X-Rosetteapi-Binding' => 'ruby',
|
345
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
345
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
346
346
|
.to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {})
|
347
347
|
end
|
348
348
|
it 'test name deduplication' do
|
@@ -393,7 +393,7 @@ describe RosetteAPI do
|
|
393
393
|
'User-Agent' => @user_agent,
|
394
394
|
'X-Rosetteapi-Key' => '0123456789',
|
395
395
|
'X-Rosetteapi-Binding' => 'ruby',
|
396
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
396
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
397
397
|
.to_return(status: 200, body: '{"test": "transliteration"}', headers: {})
|
398
398
|
end
|
399
399
|
it 'test transliteration' do
|
@@ -426,7 +426,7 @@ describe RosetteAPI do
|
|
426
426
|
'User-Agent' => @user_agent,
|
427
427
|
'X-Rosetteapi-Key' => '0123456789',
|
428
428
|
'X-Rosetteapi-Binding' => 'ruby',
|
429
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
429
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
430
430
|
.to_return(status: 200, body: '{"test": "tokens"}', headers: {})
|
431
431
|
end
|
432
432
|
it 'test tokens' do
|
@@ -447,7 +447,7 @@ describe RosetteAPI do
|
|
447
447
|
'User-Agent' => @user_agent,
|
448
448
|
'X-Rosetteapi-Key' => '0123456789',
|
449
449
|
'X-Rosetteapi-Binding' => 'ruby',
|
450
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
450
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
451
451
|
.to_return(status: 200, body: '{"test": "topics"}', headers: {})
|
452
452
|
end
|
453
453
|
it 'test topics' do
|
@@ -468,7 +468,7 @@ describe RosetteAPI do
|
|
468
468
|
'User-Agent' => @user_agent,
|
469
469
|
'X-Rosetteapi-Key' => '0123456789',
|
470
470
|
'X-Rosetteapi-Binding' => 'ruby',
|
471
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
471
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
472
472
|
.to_return(status: 200, body: '{"test": "sentences"}', headers: {})
|
473
473
|
end
|
474
474
|
it 'test sentences' do
|
@@ -519,7 +519,7 @@ describe RosetteAPI do
|
|
519
519
|
'User-Agent' => @user_agent,
|
520
520
|
'X-Rosetteapi-Key' => '0123456789',
|
521
521
|
'X-Rosetteapi-Binding' => 'ruby',
|
522
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
522
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1',
|
523
523
|
'X-RosetteApi-App' => 'ruby-app' })
|
524
524
|
.to_return(status: 200, body: '{"test": "language"}', headers: {})
|
525
525
|
end
|
@@ -546,9 +546,9 @@ describe RosetteAPI do
|
|
546
546
|
end
|
547
547
|
end
|
548
548
|
|
549
|
-
describe '.
|
549
|
+
describe '.get_similar_terms' do
|
550
550
|
before do
|
551
|
-
stub_request(:post, 'https://api.rosette.com/rest/v1/
|
551
|
+
stub_request(:post, 'https://api.rosette.com/rest/v1/semantics/similar')
|
552
552
|
.with(body: @json,
|
553
553
|
headers: { 'Accept' => 'application/json',
|
554
554
|
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
@@ -556,13 +556,33 @@ describe RosetteAPI do
|
|
556
556
|
'User-Agent' => @user_agent,
|
557
557
|
'X-Rosetteapi-Key' => '0123456789',
|
558
558
|
'X-Rosetteapi-Binding' => 'ruby',
|
559
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
559
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
560
560
|
.to_return(status: 200, body: '{"test": "language"}', headers: {})
|
561
561
|
end
|
562
|
-
it 'test
|
562
|
+
it 'test similar_terms' do
|
563
|
+
params = DocumentParameters.new(content: @content, options: { "resultLanguages" => [ "spa", "deu", "jpn" ] })
|
564
|
+
response = RosetteAPI.new('0123456789').get_similar_terms(params)
|
565
|
+
expect(response).instance_of? Hash
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
describe '.get_semantic_vectors' do
|
570
|
+
before do
|
571
|
+
stub_request(:post, 'https://api.rosette.com/rest/v1/semantics/vector')
|
572
|
+
.with(body: @json,
|
573
|
+
headers: { 'Accept' => 'application/json',
|
574
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
575
|
+
'Content-Type' => 'application/json',
|
576
|
+
'User-Agent' => @user_agent,
|
577
|
+
'X-Rosetteapi-Key' => '0123456789',
|
578
|
+
'X-Rosetteapi-Binding' => 'ruby',
|
579
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
580
|
+
.to_return(status: 200, body: '{"test": "language"}', headers: {})
|
581
|
+
end
|
582
|
+
it 'test semantic_vectors' do
|
563
583
|
params = DocumentParameters.new
|
564
584
|
params.content = @content
|
565
|
-
response = RosetteAPI.new('0123456789').
|
585
|
+
response = RosetteAPI.new('0123456789').get_semantic_vectors(params)
|
566
586
|
expect(response).instance_of? Hash
|
567
587
|
end
|
568
588
|
end
|
@@ -577,7 +597,7 @@ describe RosetteAPI do
|
|
577
597
|
'User-Agent' => @user_agent,
|
578
598
|
'X-Rosetteapi-Key' => '0123456789',
|
579
599
|
'X-Rosetteapi-Binding' => 'ruby',
|
580
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
600
|
+
'X-Rosetteapi-Binding-Version' => '1.12.1' })
|
581
601
|
.to_return(status: 200, body: '{"test": "language"}', headers: {})
|
582
602
|
end
|
583
603
|
it 'test syntax_dependencies' do
|
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.
|
4
|
+
version: 1.12.1
|
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:
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubysl-securerandom
|
@@ -62,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
|
-
|
66
|
-
rubygems_version: 2.7.3
|
65
|
+
rubygems_version: 3.0.1
|
67
66
|
signing_key:
|
68
67
|
specification_version: 2
|
69
68
|
summary: Rosette API gem that supports multilingual text-analytics.
|