rosette_api 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fb0e575bb0ab5a99e515c1e6ef7ecc1b80e56c6
4
- data.tar.gz: d15e93ae20534d699a06aaa485a234c9537dd1ba
3
+ metadata.gz: 88f0e8f31c2c5696a737213354d861c0fd3d5a16
4
+ data.tar.gz: 7657d8ffc4872373740434bc692244b59959b8bb
5
5
  SHA512:
6
- metadata.gz: 6a9b8cb27a34c9dfb5a0e6b5d55e591909c741379b25359fba22b3ac8c176daa4d47b8f54ec13a8c00557d291d9cb1f39732875e85874b84ca18b2426aa83efd
7
- data.tar.gz: 2d4ba4fe3d5443be4778af79cab2793641a9633c5033bb08cb8d4ddeb1f866e71db1b398b2a5c635eaca82a3c89f607eb41d572b3d8535c4b86c3bd3aa87b6af
6
+ metadata.gz: c530c37402657fcd5f08ed7a60ed16ec4601ff115726ce60d90631641e154787be5d9cc29d82f4c021d87d174bb160c36a440cf589f9ed1a76c9e681c0dfe810
7
+ data.tar.gz: 3c953873facf49cbf97997612111184978ae001830187d2d1bd62384ff1872dde4d8cfc5395ae27a29e12d3306cc650c7343dad8276244a3a271bfe95cde351f
@@ -13,6 +13,8 @@ class DocumentParameters
13
13
  attr_accessor :genre
14
14
  # ISO 639-3 language code of the provided content (optional)
15
15
  attr_accessor :language
16
+ # Rosette API options (optional, should be a hash)
17
+ attr_accessor :rosette_options
16
18
 
17
19
  def initialize(options = {}) #:notnew:
18
20
  options = {
@@ -20,13 +22,15 @@ class DocumentParameters
20
22
  content_uri: nil,
21
23
  file_path: nil,
22
24
  genre: nil,
23
- language: nil
25
+ language: nil,
26
+ rosette_options: nil
24
27
  }.update options
25
28
  @content = options[:content]
26
29
  @content_uri = options[:content_uri]
27
30
  @file_path = options[:file_path]
28
31
  @genre = options[:genre]
29
32
  @language = options[:language]
33
+ @rosette_options = options[:rosette_options]
30
34
  end
31
35
 
32
36
  # Validates the parameters by checking if there are multiple content sources
@@ -61,7 +65,8 @@ class DocumentParameters
61
65
  content_uri: @content_uri,
62
66
  file_path: @file_path,
63
67
  genre: @genre,
64
- language: @language
68
+ language: @language,
69
+ options: @rosette_options
65
70
  }
66
71
  end
67
72
  end
@@ -6,6 +6,8 @@ require_relative 'name_parameter'
6
6
  class NameSimilarityParameters
7
7
  # genre to categorize the input data
8
8
  attr_accessor :genre
9
+ # Rosette API options (optional, should be a hash)
10
+ attr_accessor :rosette_options
9
11
  # Name to be compared to name2
10
12
  attr_accessor :name1
11
13
  # Name to be compared to name1
@@ -13,7 +15,8 @@ class NameSimilarityParameters
13
15
 
14
16
  def initialize(name1, name2, options = {}) #:notnew:
15
17
  options = {
16
- genre: nil
18
+ genre: nil,
19
+ rosette_options: nil
17
20
  }.update options
18
21
  @genre = options[:genre]
19
22
  @name1 = name1
@@ -47,7 +50,8 @@ class NameSimilarityParameters
47
50
  {
48
51
  genre: @genre,
49
52
  name1: @name1.is_a?(NameParameter) ? @name1.load_param : @name1,
50
- name2: @name2.is_a?(NameParameter) ? @name2.load_param : @name2
53
+ name2: @name2.is_a?(NameParameter) ? @name2.load_param : @name2,
54
+ options: @rosette_options
51
55
  }
52
56
  end
53
57
  end
@@ -9,6 +9,8 @@ class NameTranslationParameters
9
9
  attr_accessor :genre
10
10
  # Name to translate
11
11
  attr_accessor :name
12
+ # Rosette API options (optional, should be a hash)
13
+ attr_accessor :rosette_options
12
14
  # ISO 693-3 code of the name's native language the name originates in (optional)
13
15
  attr_accessor :source_language_of_origin
14
16
  # ISO 693-3 code of the name's language of use (optional)
@@ -26,6 +28,7 @@ class NameTranslationParameters
26
28
  options = {
27
29
  entity_type: nil,
28
30
  genre: nil,
31
+ rosette_options: nil,
29
32
  source_language_of_origin: nil,
30
33
  source_language_of_use: nil,
31
34
  source_script: nil,
@@ -35,6 +38,7 @@ class NameTranslationParameters
35
38
  @name = name
36
39
  @entity_type = options[:entity_type]
37
40
  @genre = options[:genre]
41
+ @rosette_options = options[:rosette_options]
38
42
  @source_language_of_origin = options[:source_language_of_origin]
39
43
  @source_language_of_use = options[:source_language_of_use]
40
44
  @source_script = options[:source_script]
@@ -60,6 +64,7 @@ class NameTranslationParameters
60
64
  entity_type: @entity_type,
61
65
  genre: @genre,
62
66
  name: @name,
67
+ options: @rosette_options,
63
68
  source_language_of_origin: @source_language_of_origin,
64
69
  source_language_of_use: @source_language_of_use,
65
70
  source_script: @source_script,
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'net/http'
2
3
  require 'net/https'
3
4
  require 'json'
@@ -12,12 +13,15 @@ class RequestBuilder
12
13
  attr_accessor :params
13
14
  # Rosette API key
14
15
  attr_accessor :user_key
16
+ # Rosette API binding version
17
+ attr_accessor :binding_version
15
18
 
16
- def initialize(user_key, alternate_url, params = {}) #:notnew:
19
+ def initialize(user_key, alternate_url, params = {}, binding_version) #:notnew:
17
20
  @user_key = user_key
18
21
  @alternate_url = alternate_url
19
22
  @params = params
20
23
  @retries = 5
24
+ @binding_version = binding_version
21
25
  end
22
26
 
23
27
  # Prepares a plain POST request for Rosette API.
@@ -40,6 +44,8 @@ class RequestBuilder
40
44
  request['X-RosetteAPI-Key'] = @user_key
41
45
  request['Content-Type'] = 'application/json'
42
46
  request['Accept'] = 'application/json'
47
+ request['X-RosetteAPI-Binding'] = 'ruby'
48
+ request['X-RosetteAPI-Binding-Version'] = @binding_version
43
49
  request.body = params.to_json
44
50
 
45
51
  [http, request]
@@ -78,12 +84,19 @@ class RequestBuilder
78
84
  post_body << "\r\n\r\n--#{boundary}--\r\n"
79
85
 
80
86
  # Create the HTTP objects
81
- uri = URI.parse @alternate_url
82
- http = Net::HTTP.new uri.host, uri.port
83
- http.use_ssl = uri.scheme == 'https'
84
- request = Net::HTTP::Post.new uri.request_uri
87
+ begin
88
+ uri = URI.parse @alternate_url
89
+ http = Net::HTTP.new uri.host, uri.port
90
+ http.use_ssl = uri.scheme == 'https'
91
+ request = Net::HTTP::Post.new uri.request_uri
92
+ rescue
93
+ raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
94
+ end
95
+
85
96
  request.add_field 'Content-Type', "multipart/form-data; boundary=#{boundary}"
86
97
  request.add_field 'X-RosetteAPI-Key', @user_key
98
+ request.add_field 'X-RosetteAPI-Binding', 'ruby'
99
+ request.add_field 'X-RosetteAPI-Binding-Version', @binding_version
87
100
  request.body = post_body.join
88
101
 
89
102
  [http, request]
@@ -93,11 +106,15 @@ class RequestBuilder
93
106
  #
94
107
  # Returns JSON response or raises RosetteAPIError if encountered.
95
108
  def send_get_request
96
- uri = URI.parse @alternate_url
97
- http = Net::HTTP.new uri.host, uri.port
98
- http.use_ssl = uri.scheme == 'https'
109
+ begin
110
+ uri = URI.parse @alternate_url
111
+ http = Net::HTTP.new uri.host, uri.port
112
+ http.use_ssl = uri.scheme == 'https'
99
113
 
100
- request = Net::HTTP::Get.new uri.request_uri
114
+ request = Net::HTTP::Get.new uri.request_uri
115
+ rescue
116
+ raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
117
+ end
101
118
  request['X-RosetteAPI-Key'] = @user_key
102
119
 
103
120
  self.get_response http, request
@@ -107,8 +124,6 @@ class RequestBuilder
107
124
  #
108
125
  # Returns JSON response or raises RosetteAPIError if encountered.
109
126
  def send_post_request
110
- params = (@alternate_url.to_s.include? '/info?clientVersion=') ? '{"body": "version check"}' : @params
111
-
112
127
  if !params['filePath'].nil?
113
128
  http, request = self.prepare_multipart_request params
114
129
  else
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.0.2'
12
+ BINDING_VERSION = '1.0.5'
13
13
  # Rosette API language endpoint
14
14
  LANGUAGE_ENDPOINT = '/language'
15
15
  # Rosette API morphology endpoint
@@ -32,8 +32,6 @@ class RosetteAPI
32
32
  SENTENCES_ENDPOINT = '/sentences'
33
33
  # Rosette API info endpoint
34
34
  INFO = '/info'
35
- # Rosette API version check endpoint
36
- VERSION_CHECK = '/info?clientVersion=' + BINDING_VERSION
37
35
  # Rosette API ping endpoint
38
36
  PING = '/ping'
39
37
 
@@ -49,20 +47,6 @@ class RosetteAPI
49
47
  if @alternate_url.to_s.end_with?('/')
50
48
  @alternate_url = alternate_url.to_s.slice(0..-2)
51
49
  end
52
-
53
- self.check_version_compatibility
54
- end
55
-
56
- # Checks binding version compatibility against the Rosette API server.
57
- def check_version_compatibility
58
- response = RequestBuilder.new(@user_key, @alternate_url + VERSION_CHECK)
59
- .send_post_request
60
-
61
- unless response['versionChecked']
62
- puts JSON.pretty_generate(response)
63
-
64
- exit
65
- end
66
50
  end
67
51
 
68
52
  # Identifies in which language(s) the input is written.
@@ -77,7 +61,7 @@ class RosetteAPI
77
61
 
78
62
  params = params.load_params
79
63
 
80
- RequestBuilder.new(@user_key, @alternate_url + LANGUAGE_ENDPOINT, params)
64
+ RequestBuilder.new(@user_key, @alternate_url + LANGUAGE_ENDPOINT, params, BINDING_VERSION)
81
65
  .send_post_request
82
66
  end
83
67
 
@@ -95,7 +79,7 @@ class RosetteAPI
95
79
 
96
80
  params = params.load_params
97
81
 
98
- RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/complete', params)
82
+ RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/complete', params, BINDING_VERSION)
99
83
  .send_post_request
100
84
  end
101
85
 
@@ -112,7 +96,7 @@ class RosetteAPI
112
96
 
113
97
  params = params.load_params
114
98
 
115
- RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/compound-components', params)
99
+ RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/compound-components', params, BINDING_VERSION)
116
100
  .send_post_request
117
101
  end
118
102
 
@@ -129,7 +113,7 @@ class RosetteAPI
129
113
 
130
114
  params = params.load_params
131
115
 
132
- RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/han-readings', params)
116
+ RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/han-readings', params, BINDING_VERSION)
133
117
  .send_post_request
134
118
  end
135
119
 
@@ -145,7 +129,7 @@ class RosetteAPI
145
129
 
146
130
  params = params.load_params
147
131
 
148
- RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/lemmas', params)
132
+ RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/lemmas', params, BINDING_VERSION)
149
133
  .send_post_request
150
134
  end
151
135
 
@@ -162,7 +146,7 @@ class RosetteAPI
162
146
 
163
147
  params = params.load_params
164
148
 
165
- RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/parts-of-speech', params)
149
+ RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/parts-of-speech', params, BINDING_VERSION)
166
150
  .send_post_request
167
151
  end
168
152
 
@@ -183,7 +167,7 @@ class RosetteAPI
183
167
 
184
168
  endpoint = resolve_entities ? (ENTITIES_ENDPOINT + '/linked') : ENTITIES_ENDPOINT
185
169
 
186
- RequestBuilder.new(@user_key, @alternate_url + endpoint, params)
170
+ RequestBuilder.new(@user_key, @alternate_url + endpoint, params, BINDING_VERSION)
187
171
  .send_post_request
188
172
  end
189
173
 
@@ -213,7 +197,7 @@ class RosetteAPI
213
197
 
214
198
  params = params.load_params
215
199
 
216
- RequestBuilder.new(@user_key, @alternate_url + CATEGORIES_ENDPOINT, params)
200
+ RequestBuilder.new(@user_key, @alternate_url + CATEGORIES_ENDPOINT, params, BINDING_VERSION)
217
201
  .send_post_request
218
202
  end
219
203
 
@@ -229,7 +213,7 @@ class RosetteAPI
229
213
 
230
214
  params = params.load_params
231
215
 
232
- RequestBuilder.new(@user_key, @alternate_url + RELATIONSHIPS_ENDPOINT, params)
216
+ RequestBuilder.new(@user_key, @alternate_url + RELATIONSHIPS_ENDPOINT, params, BINDING_VERSION)
233
217
  .send_post_request
234
218
  end
235
219
 
@@ -245,7 +229,7 @@ class RosetteAPI
245
229
 
246
230
  params = params.load_params
247
231
 
248
- RequestBuilder.new(@user_key, @alternate_url + SENTIMENT_ENDPOINT, params)
232
+ RequestBuilder.new(@user_key, @alternate_url + SENTIMENT_ENDPOINT, params, BINDING_VERSION)
249
233
  .send_post_request
250
234
  end
251
235
 
@@ -261,7 +245,7 @@ class RosetteAPI
261
245
 
262
246
  params = params.load_params
263
247
 
264
- RequestBuilder.new(@user_key, @alternate_url + NAME_TRANSLATION_ENDPOINT, params)
248
+ RequestBuilder.new(@user_key, @alternate_url + NAME_TRANSLATION_ENDPOINT, params, BINDING_VERSION)
265
249
  .send_post_request
266
250
  end
267
251
 
@@ -278,7 +262,7 @@ class RosetteAPI
278
262
 
279
263
  params = params.load_params
280
264
 
281
- RequestBuilder.new(@user_key, @alternate_url + NAME_SIMILARITY_ENDPOINT, params)
265
+ RequestBuilder.new(@user_key, @alternate_url + NAME_SIMILARITY_ENDPOINT, params, BINDING_VERSION)
282
266
  .send_post_request
283
267
  end
284
268
 
@@ -294,7 +278,7 @@ class RosetteAPI
294
278
 
295
279
  params = params.load_params
296
280
 
297
- RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT, params)
281
+ RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT, params, BINDING_VERSION)
298
282
  .send_post_request
299
283
  end
300
284
 
@@ -310,21 +294,21 @@ class RosetteAPI
310
294
 
311
295
  params = params.load_params
312
296
 
313
- RequestBuilder.new(@user_key, @alternate_url + SENTENCES_ENDPOINT, params)
297
+ RequestBuilder.new(@user_key, @alternate_url + SENTENCES_ENDPOINT, params, BINDING_VERSION)
314
298
  .send_post_request
315
299
  end
316
300
 
317
- # Gets information about the Rosette API, returns name, version, build number
301
+ # Gets information about the Rosette API, returns name, build number
318
302
  # and build time.
319
303
  def info
320
- RequestBuilder.new(@user_key, @alternate_url + INFO)
304
+ RequestBuilder.new(@user_key, @alternate_url + INFO, BINDING_VERSION)
321
305
  .send_get_request
322
306
  end
323
307
 
324
308
  # Pings the Rosette API for a response indicting that the service is
325
309
  # available.
326
310
  def ping
327
- RequestBuilder.new(@user_key, @alternate_url + PING)
311
+ RequestBuilder.new(@user_key, @alternate_url + PING, BINDING_VERSION)
328
312
  .send_get_request
329
313
  end
330
314
 
data/tests/tests_spec.rb CHANGED
@@ -10,21 +10,15 @@ describe RosetteAPI do
10
10
  describe '.get_language' do
11
11
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/language.json'))
12
12
  before do
13
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
14
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
15
- headers: {'Accept' => 'application/json',
16
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
17
- 'Content-Type' => 'application/json',
18
- 'User-Agent' => 'Ruby',
19
- 'X-Rosetteapi-Key' => '0123456789'}).
20
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
21
13
  stub_request(:post, 'https://api.rosette.com/rest/v1/language').
22
14
  with(body: request_file,
23
15
  headers: {'Accept' => 'application/json',
24
16
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
25
17
  'Content-Type' => 'application/json',
26
18
  'User-Agent' => 'Ruby',
27
- 'X-Rosetteapi-Key' => '0123456789'}).
19
+ 'X-Rosetteapi-Key' => '0123456789',
20
+ 'X-Rosetteapi-Binding' => 'ruby',
21
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
28
22
  to_return(status: 200, body: {'test': 'language'}.to_json, headers: {})
29
23
  end
30
24
  it 'test language' do
@@ -47,26 +41,21 @@ describe RosetteAPI do
47
41
  .get_language(params) }
48
42
  .to raise_error(BadRequestFormatError)
49
43
  end
44
+
50
45
  end
51
46
 
52
47
  describe '.get_morphology_complete' do
53
48
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/morphology_complete.json'))
54
49
  before do
55
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
56
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
57
- headers: {'Accept' => 'application/json',
58
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
59
- 'Content-Type' => 'application/json',
60
- 'User-Agent' => 'Ruby',
61
- 'X-Rosetteapi-Key' => '0123456789'}).
62
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
63
50
  stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/complete').
64
51
  with(body: request_file,
65
52
  headers: {'Accept' => 'application/json',
66
53
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
67
54
  'Content-Type' => 'application/json',
68
55
  'User-Agent' => 'Ruby',
69
- 'X-Rosetteapi-Key' => '0123456789'}).
56
+ 'X-Rosetteapi-Key' => '0123456789',
57
+ 'X-Rosetteapi-Binding' => 'ruby',
58
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
70
59
  to_return(status: 200, body: {'test': 'morphology/complete'}.to_json, headers: {})
71
60
  end
72
61
  it 'test morphology complete' do
@@ -80,21 +69,15 @@ describe RosetteAPI do
80
69
  describe '.get_compound_components' do
81
70
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/morphology_compound_components.json'))
82
71
  before do
83
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
84
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
85
- headers: {'Accept' => 'application/json',
86
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
87
- 'Content-Type' => 'application/json',
88
- 'User-Agent' => 'Ruby',
89
- 'X-Rosetteapi-Key' => '0123456789'}).
90
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
91
72
  stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/compound-components').
92
73
  with(body: request_file,
93
74
  headers: {'Accept' => 'application/json',
94
75
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
95
76
  'Content-Type' => 'application/json',
96
77
  'User-Agent' => 'Ruby',
97
- 'X-Rosetteapi-Key' => '0123456789'}).
78
+ 'X-Rosetteapi-Key' => '0123456789',
79
+ 'X-Rosetteapi-Binding' => 'ruby',
80
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
98
81
  to_return(status: 200, body: {'test': 'morphology/compound-components'}.to_json, headers: {})
99
82
  end
100
83
  it 'test morphology compound components' do
@@ -108,21 +91,15 @@ describe RosetteAPI do
108
91
  describe '.get_han_readings' do
109
92
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/morphology_han_readings.json')), encoding: 'utf-8'
110
93
  before do
111
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
112
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
113
- headers: {'Accept' => 'application/json',
114
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
115
- 'Content-Type' => 'application/json',
116
- 'User-Agent' => 'Ruby',
117
- 'X-Rosetteapi-Key' => '0123456789'}).
118
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
119
94
  stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/han-readings').
120
95
  with(body: request_file,
121
96
  headers: {'Accept' => 'application/json',
122
97
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
123
98
  'Content-Type' => 'application/json',
124
99
  'User-Agent' => 'Ruby',
125
- 'X-Rosetteapi-Key' => '0123456789'}).
100
+ 'X-Rosetteapi-Key' => '0123456789',
101
+ 'X-Rosetteapi-Binding' => 'ruby',
102
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
126
103
  to_return(status: 200, body: {'test': 'morphology/han-readings'}.to_json, headers: {})
127
104
  end
128
105
  it 'test morphology han readings' do
@@ -136,21 +113,15 @@ describe RosetteAPI do
136
113
  describe '.get_parts_of_speech' do
137
114
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/morphology_parts_of_speech.json'))
138
115
  before do
139
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
140
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
141
- headers: {'Accept' => 'application/json',
142
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
143
- 'Content-Type' => 'application/json',
144
- 'User-Agent' => 'Ruby',
145
- 'X-Rosetteapi-Key' => '0123456789'}).
146
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
147
116
  stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/parts-of-speech').
148
117
  with(body: request_file,
149
118
  headers: {'Accept' => 'application/json',
150
119
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
151
120
  'Content-Type' => 'application/json',
152
121
  'User-Agent' => 'Ruby',
153
- 'X-Rosetteapi-Key' => '0123456789'}).
122
+ 'X-Rosetteapi-Key' => '0123456789',
123
+ 'X-Rosetteapi-Binding' => 'ruby',
124
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
154
125
  to_return(status: 200, body: {'test': 'morphology/parts-of-speech'}.to_json, headers: {})
155
126
  end
156
127
  it 'test morphology parts of speech' do
@@ -164,21 +135,15 @@ describe RosetteAPI do
164
135
  describe '.get_lemmas' do
165
136
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/morphology_lemmas.json'))
166
137
  before do
167
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
168
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
169
- headers: {'Accept' => 'application/json',
170
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
171
- 'Content-Type' => 'application/json',
172
- 'User-Agent' => 'Ruby',
173
- 'X-Rosetteapi-Key' => '0123456789'}).
174
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
175
138
  stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/lemmas').
176
139
  with(body: request_file,
177
140
  headers: {'Accept' => 'application/json',
178
141
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
179
142
  'Content-Type' => 'application/json',
180
143
  'User-Agent' => 'Ruby',
181
- 'X-Rosetteapi-Key' => '0123456789'}).
144
+ 'X-Rosetteapi-Key' => '0123456789',
145
+ 'X-Rosetteapi-Binding' => 'ruby',
146
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
182
147
  to_return(status: 200, body: {'test': 'morphology/lemmas'}.to_json, headers: {})
183
148
  end
184
149
  it 'test morphology lemmas' do
@@ -192,21 +157,15 @@ describe RosetteAPI do
192
157
  describe '.get_entities' do
193
158
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/entities.json')), encoding: 'utf-8'
194
159
  before do
195
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
196
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
197
- headers: {'Accept' => 'application/json',
198
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
199
- 'Content-Type' => 'application/json',
200
- 'User-Agent' => 'Ruby',
201
- 'X-Rosetteapi-Key' => '0123456789'}).
202
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
203
160
  stub_request(:post, 'https://api.rosette.com/rest/v1/entities').
204
161
  with(body: request_file,
205
162
  headers: {'Accept' => 'application/json',
206
163
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
207
164
  'Content-Type' => 'application/json',
208
165
  'User-Agent' => 'Ruby',
209
- 'X-Rosetteapi-Key' => '0123456789'}).
166
+ 'X-Rosetteapi-Key' => '0123456789',
167
+ 'X-Rosetteapi-Binding' => 'ruby',
168
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
210
169
  to_return(status: 200, body: {'test': 'entities'}.to_json, headers: {})
211
170
  end
212
171
  it 'test entities' do
@@ -221,21 +180,15 @@ describe RosetteAPI do
221
180
  describe '.get_entities_linked' do
222
181
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/entities_linked.json'))
223
182
  before do
224
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
225
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
226
- headers: {'Accept' => 'application/json',
227
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
228
- 'Content-Type' => 'application/json',
229
- 'User-Agent' => 'Ruby',
230
- 'X-Rosetteapi-Key' => '0123456789'}).
231
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
232
183
  stub_request(:post, 'https://api.rosette.com/rest/v1/entities/linked').
233
184
  with(body: request_file,
234
185
  headers: {'Accept' => 'application/json',
235
186
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
236
187
  'Content-Type' => 'application/json',
237
188
  'User-Agent' => 'Ruby',
238
- 'X-Rosetteapi-Key' => '0123456789'}).
189
+ 'X-Rosetteapi-Key' => '0123456789',
190
+ 'X-Rosetteapi-Binding' => 'ruby',
191
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
239
192
  to_return(status: 200, body: {'test': 'entities/linked'}.to_json, headers: {})
240
193
  end
241
194
  it 'test entities linked' do
@@ -257,21 +210,15 @@ describe RosetteAPI do
257
210
  describe '.get_categories' do
258
211
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/categories.json'))
259
212
  before do
260
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
261
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
262
- headers: {'Accept' => 'application/json',
263
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
264
- 'Content-Type' => 'application/json',
265
- 'User-Agent' => 'Ruby',
266
- 'X-Rosetteapi-Key' => '0123456789'}).
267
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
268
213
  stub_request(:post, 'https://api.rosette.com/rest/v1/categories').
269
214
  with(body: request_file,
270
215
  headers: {'Accept' => 'application/json',
271
216
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
272
217
  'Content-Type' => 'application/json',
273
218
  'User-Agent' => 'Ruby',
274
- 'X-Rosetteapi-Key' => '0123456789'}).
219
+ 'X-Rosetteapi-Key' => '0123456789',
220
+ 'X-Rosetteapi-Binding' => 'ruby',
221
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
275
222
  to_return(status: 200, body: {'test': 'categories'}.to_json, headers: {})
276
223
  end
277
224
  it 'test categories' do
@@ -285,21 +232,15 @@ describe RosetteAPI do
285
232
  describe '.get_relationships' do
286
233
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/relationships.json'))
287
234
  before do
288
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
289
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
290
- headers: {'Accept' => 'application/json',
291
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
292
- 'Content-Type' => 'application/json',
293
- 'User-Agent' => 'Ruby',
294
- 'X-Rosetteapi-Key' => '0123456789'}).
295
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
296
235
  stub_request(:post, 'https://api.rosette.com/rest/v1/relationships').
297
236
  with(body: request_file,
298
237
  headers: {'Accept' => 'application/json',
299
238
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
300
239
  'Content-Type' => 'application/json',
301
240
  'User-Agent' => 'Ruby',
302
- 'X-Rosetteapi-Key' => '0123456789'}).
241
+ 'X-Rosetteapi-Key' => '0123456789',
242
+ 'X-Rosetteapi-Binding' => 'ruby',
243
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
303
244
  to_return(status: 200, body: {'test': 'relationships'}.to_json, headers: {})
304
245
  end
305
246
  it 'test relationships' do
@@ -313,21 +254,15 @@ describe RosetteAPI do
313
254
  describe '.name_translation' do
314
255
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/name_translation.json')), encoding: 'utf-8'
315
256
  before do
316
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
317
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
318
- headers: {'Accept' => 'application/json',
319
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
320
- 'Content-Type' => 'application/json',
321
- 'User-Agent' => 'Ruby',
322
- 'X-Rosetteapi-Key' => '0123456789'}).
323
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
324
257
  stub_request(:post, 'https://api.rosette.com/rest/v1/name-translation').
325
258
  with(body: request_file,
326
259
  headers: {'Accept' => 'application/json',
327
260
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
328
261
  'Content-Type' => 'application/json',
329
262
  'User-Agent' => 'Ruby',
330
- 'X-Rosetteapi-Key' => '0123456789'}).
263
+ 'X-Rosetteapi-Key' => '0123456789',
264
+ 'X-Rosetteapi-Binding' => 'ruby',
265
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
331
266
  to_return(status: 200, body: {'test': 'name-translation'}.to_json, headers: {})
332
267
  end
333
268
  it 'test name translation' do
@@ -346,21 +281,15 @@ describe RosetteAPI do
346
281
  describe '.name_similarity' do
347
282
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/name_similarity.json')), encoding: 'utf-8'
348
283
  before do
349
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
350
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
351
- headers: {'Accept' => 'application/json',
352
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
353
- 'Content-Type' => 'application/json',
354
- 'User-Agent' => 'Ruby',
355
- 'X-Rosetteapi-Key' => '0123456789'}).
356
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
357
284
  stub_request(:post, 'https://api.rosette.com/rest/v1/name-similarity').
358
285
  with(body: request_file,
359
286
  headers: {'Accept' => 'application/json',
360
287
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
361
288
  'Content-Type' => 'application/json',
362
289
  'User-Agent' => 'Ruby',
363
- 'X-Rosetteapi-Key' => '0123456789'}).
290
+ 'X-Rosetteapi-Key' => '0123456789',
291
+ 'X-Rosetteapi-Binding' => 'ruby',
292
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
364
293
  to_return(status: 200, body: {'test': 'name-similarity'}.to_json, headers: {})
365
294
  end
366
295
  it 'test name similarity' do
@@ -388,21 +317,15 @@ describe RosetteAPI do
388
317
  describe '.get_tokens' do
389
318
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/tokens.json')), encoding: 'utf-8'
390
319
  before do
391
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
392
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
393
- headers: {'Accept' => 'application/json',
394
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
395
- 'Content-Type' => 'application/json',
396
- 'User-Agent' => 'Ruby',
397
- 'X-Rosetteapi-Key' => '0123456789'}).
398
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
399
320
  stub_request(:post, 'https://api.rosette.com/rest/v1/tokens').
400
321
  with(body: request_file,
401
322
  headers: {'Accept' => 'application/json',
402
323
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
403
324
  'Content-Type' => 'application/json',
404
325
  'User-Agent' => 'Ruby',
405
- 'X-Rosetteapi-Key' => '0123456789'}).
326
+ 'X-Rosetteapi-Key' => '0123456789',
327
+ 'X-Rosetteapi-Binding' => 'ruby',
328
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
406
329
  to_return(status: 200, body: {'test': 'tokens'}.to_json, headers: {})
407
330
  end
408
331
  it 'test tokens' do
@@ -416,21 +339,15 @@ describe RosetteAPI do
416
339
  describe '.get_sentences' do
417
340
  request_file = File.read File.expand_path(File.join(File.dirname(__FILE__), '../mock-data/request/sentences.json'))
418
341
  before do
419
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
420
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
421
- headers: {'Accept' => 'application/json',
422
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
423
- 'Content-Type' => 'application/json',
424
- 'User-Agent' => 'Ruby',
425
- 'X-Rosetteapi-Key' => '0123456789'}).
426
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
427
342
  stub_request(:post, 'https://api.rosette.com/rest/v1/sentences').
428
343
  with(body: request_file,
429
344
  headers: {'Accept' => 'application/json',
430
345
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
431
346
  'Content-Type' => 'application/json',
432
347
  'User-Agent' => 'Ruby',
433
- 'X-Rosetteapi-Key' => '0123456789'}).
348
+ 'X-Rosetteapi-Key' => '0123456789',
349
+ 'X-Rosetteapi-Binding' => 'ruby',
350
+ 'X-Rosetteapi-Binding-Version' => '1.0.2'}).
434
351
  to_return(status: 200, body: {'test': 'sentences'}.to_json, headers: {})
435
352
  end
436
353
  it 'test sentences' do
@@ -446,14 +363,6 @@ describe RosetteAPI do
446
363
 
447
364
  describe '.info' do
448
365
  before do
449
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
450
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
451
- headers: {'Accept' => 'application/json',
452
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
453
- 'Content-Type' => 'application/json',
454
- 'User-Agent' => 'Ruby',
455
- 'X-Rosetteapi-Key' => '0123456789'}).
456
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
457
366
  stub_request(:get, 'https://api.rosette.com/rest/v1/info').
458
367
  with(headers: {'Accept' => '*/*',
459
368
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
@@ -469,14 +378,6 @@ describe RosetteAPI do
469
378
 
470
379
  describe '.ping' do
471
380
  before do
472
- stub_request(:post, 'https://api.rosette.com/rest/v1/info?clientVersion=1.0.2').
473
- with(body: "\"{\\\"body\\\": \\\"version check\\\"}\"",
474
- headers: {'Accept' => 'application/json',
475
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
476
- 'Content-Type' => 'application/json',
477
- 'User-Agent' => 'Ruby',
478
- 'X-Rosetteapi-Key' => '0123456789'}).
479
- to_return(status: 200, body: {'versionChecked': true}.to_json, headers: {})
480
381
  stub_request(:get, 'https://api.rosette.com/rest/v1/ping').
481
382
  with(headers: {'Accept' => '*/*',
482
383
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
@@ -489,4 +390,6 @@ describe RosetteAPI do
489
390
  expect(response).instance_of? Hash
490
391
  end
491
392
  end
393
+
394
+
492
395
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosette_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
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-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubysl-securerandom
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  description: A Ruby client binding for the Rosette API, a multilingual text analytics
@@ -51,17 +51,17 @@ require_paths:
51
51
  - lib
52
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: 2.0.0
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.6.4
64
+ rubygems_version: 2.6.3
65
65
  signing_key:
66
66
  specification_version: 2
67
67
  summary: Rosette API gem that supports multilingual text-analytics.