rosette_api 1.0.2 → 1.0.3
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 +3 -1
- data/tests/tests_spec.rb +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53c127d939917c66e9f18732487666ed38e146e
|
4
|
+
data.tar.gz: df1aa05f967fb4c6c4839896fe80ce786abdcc4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14c981a94e40839716b1d2a4f818378e58836944ae23a898fddada1fccdb85e198f190c2a40000d28bb7ccb62e28609ccacc2dc2b186fa06a9434c2c6fe5daed
|
7
|
+
data.tar.gz: dfc63f43667b3bb60ca419eb1065546a5c402845236cde3ba09118e320cd3fe1acd55e63b05d3abcd51140d573843e0150564f5dfa97f621e34b7b60cef7df19
|
data/lib/rosette_api.rb
CHANGED
@@ -177,6 +177,8 @@ class RosetteAPI
|
|
177
177
|
def get_entities(params, resolve_entities = false)
|
178
178
|
check_params params
|
179
179
|
|
180
|
+
raise BadRequestError.new('Expects boolean for resolve_entities') unless !!resolve_entities == resolve_entities
|
181
|
+
|
180
182
|
params = params.load_params
|
181
183
|
|
182
184
|
endpoint = resolve_entities ? (ENTITIES_ENDPOINT + '/linked') : ENTITIES_ENDPOINT
|
@@ -330,7 +332,7 @@ class RosetteAPI
|
|
330
332
|
|
331
333
|
# Checks that the right parameter type is being passed in.
|
332
334
|
def check_params(params, message = 'Expects a DocumentParameters type as an argument', type = DocumentParameters)
|
333
|
-
raise
|
335
|
+
raise BadRequestError.new message unless params.is_a? type
|
334
336
|
end
|
335
337
|
end
|
336
338
|
|
data/tests/tests_spec.rb
CHANGED
@@ -242,9 +242,16 @@ describe RosetteAPI do
|
|
242
242
|
params = DocumentParameters.new
|
243
243
|
params.content = 'Last month director Paul Feig announced the movie will have an all-star female cast including' \
|
244
244
|
' Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.'
|
245
|
-
response = RosetteAPI.new('0123456789').
|
245
|
+
response = RosetteAPI.new('0123456789').get_entities(params, true)
|
246
246
|
expect(response).instance_of? Hash
|
247
247
|
end
|
248
|
+
|
249
|
+
it 'test entities linked for resolve_entities is not a boolean' do
|
250
|
+
params = DocumentParameters.new
|
251
|
+
params.content = 'Last month director Paul Feig announced the movie will have an all-star female cast including' \
|
252
|
+
' Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.'
|
253
|
+
expect { RosetteAPI.new('0123456789').get_entities(params, 'smth') }.to raise_error(BadRequestError)
|
254
|
+
end
|
248
255
|
end
|
249
256
|
|
250
257
|
describe '.get_categories' do
|
@@ -329,6 +336,11 @@ describe RosetteAPI do
|
|
329
336
|
response = RosetteAPI.new('0123456789').name_translation(params)
|
330
337
|
expect(response).instance_of? Hash
|
331
338
|
end
|
339
|
+
|
340
|
+
it 'badRequest: Expects NameTransaltionParameters type as an argument' do
|
341
|
+
params = NameSimilarityParameters.new('Michael Jackson', '迈克尔·杰克逊')
|
342
|
+
expect { RosetteAPI.new('0123456789').name_translation(params) }.to raise_error(BadRequestError)
|
343
|
+
end
|
332
344
|
end
|
333
345
|
|
334
346
|
describe '.name_similarity' do
|
@@ -357,10 +369,20 @@ describe RosetteAPI do
|
|
357
369
|
expect(response).instance_of? Hash
|
358
370
|
end
|
359
371
|
|
372
|
+
it 'badRequestFormat: name1 option can only be an instance of a String or NameParameter' do
|
373
|
+
params = NameSimilarityParameters.new(123, 'Michael Jackson')
|
374
|
+
expect { RosetteAPI.new('0123456789').name_similarity(params) }.to raise_error(BadRequestError)
|
375
|
+
end
|
376
|
+
|
360
377
|
it 'badRequestFormat: name2 option can only be an instance of a String or NameParameter' do
|
361
378
|
params = NameSimilarityParameters.new('Michael Jackson', 123)
|
362
379
|
expect { RosetteAPI.new('0123456789').name_similarity(params) }.to raise_error(BadRequestError)
|
363
380
|
end
|
381
|
+
|
382
|
+
it 'badRequest: Expects NameSimilarityParameters type as an argument' do
|
383
|
+
params = NameTranslationParameters.new('معمر محمد أبو منيار القذاف'.encode('UTF-8'), 'eng')
|
384
|
+
expect { RosetteAPI.new('0123456789').name_similarity(params) }.to raise_error(BadRequestError)
|
385
|
+
end
|
364
386
|
end
|
365
387
|
|
366
388
|
describe '.get_tokens' 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.0.
|
4
|
+
version: 1.0.3
|
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-
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubysl-securerandom
|