rosette_api 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +312 -0
- data/lib/document_parameters.rb +4 -4
- data/lib/request_builder.rb +10 -7
- data/lib/rosette_api.rb +44 -60
- data/tests/tests_spec.rb +17 -17
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518dc7208214566ddaeb979cba5bb276c7f05558
|
4
|
+
data.tar.gz: 840bcfdfe10f7de5fab352ab164d8c94fa36f325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a861e66e8893f501759c33099098e03e4ab8438f37c3780c36d2304af0afb6823c58fcde40b8e59416ceaed4ce190362efb1fbfaa3bc390a8748b4365c3cd8
|
7
|
+
data.tar.gz: 083ec97fa03d5c621c197e132247d6caed164b22a7628aa20d53add57daa9eebe2fa0b11d6f3b017823c6583f396ff0b9afbba5187fad939be35411323712960
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-12-07 10:52:04 -0500 using RuboCop version 0.46.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/Gemfile, **/gems.rb
|
12
|
+
Bundler/OrderedGems:
|
13
|
+
Exclude:
|
14
|
+
- 'Gemfile'
|
15
|
+
|
16
|
+
# Offense count: 2
|
17
|
+
Lint/Void:
|
18
|
+
Exclude:
|
19
|
+
- 'examples/sentences.rb'
|
20
|
+
- 'examples/sentiment.rb'
|
21
|
+
|
22
|
+
# Offense count: 3
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Max: 41
|
25
|
+
|
26
|
+
# Offense count: 4
|
27
|
+
# Configuration parameters: CountComments.
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Max: 425
|
30
|
+
|
31
|
+
# Offense count: 2
|
32
|
+
# Configuration parameters: CountComments.
|
33
|
+
Metrics/ClassLength:
|
34
|
+
Max: 140
|
35
|
+
|
36
|
+
# Offense count: 142
|
37
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
38
|
+
# URISchemes: http, https
|
39
|
+
Metrics/LineLength:
|
40
|
+
Max: 408
|
41
|
+
|
42
|
+
# Offense count: 6
|
43
|
+
# Configuration parameters: CountComments.
|
44
|
+
Metrics/MethodLength:
|
45
|
+
Max: 42
|
46
|
+
|
47
|
+
# Offense count: 1
|
48
|
+
# Configuration parameters: CountKeywordArgs.
|
49
|
+
Metrics/ParameterLists:
|
50
|
+
Max: 6
|
51
|
+
|
52
|
+
# Offense count: 94
|
53
|
+
# Cop supports --auto-correct.
|
54
|
+
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
|
55
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
56
|
+
Style/AlignHash:
|
57
|
+
Exclude:
|
58
|
+
- 'tests/tests_spec.rb'
|
59
|
+
|
60
|
+
# Offense count: 1
|
61
|
+
# Cop supports --auto-correct.
|
62
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
63
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
64
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
65
|
+
# FunctionalMethods: let, let!, subject, watch
|
66
|
+
# IgnoredMethods: lambda, proc, it
|
67
|
+
Style/BlockDelimiters:
|
68
|
+
Exclude:
|
69
|
+
- 'tests/tests_spec.rb'
|
70
|
+
|
71
|
+
# Offense count: 1
|
72
|
+
# Cop supports --auto-correct.
|
73
|
+
Style/BlockEndNewline:
|
74
|
+
Exclude:
|
75
|
+
- 'tests/tests_spec.rb'
|
76
|
+
|
77
|
+
# Offense count: 18
|
78
|
+
# Cop supports --auto-correct.
|
79
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
|
80
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
81
|
+
Style/ConditionalAssignment:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
# Offense count: 40
|
85
|
+
# Cop supports --auto-correct.
|
86
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
87
|
+
# SupportedStyles: leading, trailing
|
88
|
+
Style/DotPosition:
|
89
|
+
Exclude:
|
90
|
+
- 'tests/tests_spec.rb'
|
91
|
+
|
92
|
+
# Offense count: 1
|
93
|
+
# Cop supports --auto-correct.
|
94
|
+
# Configuration parameters: AllowAdjacentOneLineDefs.
|
95
|
+
Style/EmptyLineBetweenDefs:
|
96
|
+
Exclude:
|
97
|
+
- 'lib/rosette_api.rb'
|
98
|
+
|
99
|
+
# Offense count: 4
|
100
|
+
# Cop supports --auto-correct.
|
101
|
+
Style/EmptyLines:
|
102
|
+
Exclude:
|
103
|
+
- 'examples/sentiment.rb'
|
104
|
+
- 'lib/request_builder.rb'
|
105
|
+
- 'rosette_api.gemspec'
|
106
|
+
|
107
|
+
# Offense count: 2
|
108
|
+
# Cop supports --auto-correct.
|
109
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
110
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
111
|
+
Style/EmptyLinesAroundBlockBody:
|
112
|
+
Exclude:
|
113
|
+
- 'tests/tests_spec.rb'
|
114
|
+
|
115
|
+
# Offense count: 1
|
116
|
+
# Cop supports --auto-correct.
|
117
|
+
Style/EmptyLinesAroundMethodBody:
|
118
|
+
Exclude:
|
119
|
+
- 'lib/request_builder.rb'
|
120
|
+
|
121
|
+
# Offense count: 3
|
122
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
123
|
+
Style/FileName:
|
124
|
+
Exclude:
|
125
|
+
- 'examples/morphology_compound-components.rb'
|
126
|
+
- 'examples/morphology_han-readings.rb'
|
127
|
+
- 'examples/morphology_parts-of-speech.rb'
|
128
|
+
|
129
|
+
# Offense count: 2
|
130
|
+
# Configuration parameters: SupportedStyles.
|
131
|
+
# SupportedStyles: for, each
|
132
|
+
Style/For:
|
133
|
+
EnforcedStyle: for
|
134
|
+
|
135
|
+
# Offense count: 30
|
136
|
+
# Cop supports --auto-correct.
|
137
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
138
|
+
# SupportedStyles: when_needed, always
|
139
|
+
Style/FrozenStringLiteralComment:
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
# Offense count: 4
|
143
|
+
# Configuration parameters: MinBodyLength.
|
144
|
+
Style/GuardClause:
|
145
|
+
Exclude:
|
146
|
+
- 'lib/name_similarity_parameters.rb'
|
147
|
+
- 'lib/name_translation_parameters.rb'
|
148
|
+
- 'lib/request_builder.rb'
|
149
|
+
|
150
|
+
# Offense count: 90
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
153
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
154
|
+
Style/HashSyntax:
|
155
|
+
Exclude:
|
156
|
+
- 'tests/tests_spec.rb'
|
157
|
+
|
158
|
+
# Offense count: 3
|
159
|
+
# Cop supports --auto-correct.
|
160
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
161
|
+
# SupportedStyles: normal, rails
|
162
|
+
Style/IndentationConsistency:
|
163
|
+
Exclude:
|
164
|
+
- 'examples/sentences.rb'
|
165
|
+
- 'examples/sentiment.rb'
|
166
|
+
- 'lib/rosette_api.rb'
|
167
|
+
|
168
|
+
# Offense count: 5
|
169
|
+
# Cop supports --auto-correct.
|
170
|
+
# Configuration parameters: Width.
|
171
|
+
Style/IndentationWidth:
|
172
|
+
Exclude:
|
173
|
+
- 'examples/morphology_han-readings.rb'
|
174
|
+
- 'lib/request_builder.rb'
|
175
|
+
- 'tests/tests_spec.rb'
|
176
|
+
|
177
|
+
# Offense count: 1
|
178
|
+
# Cop supports --auto-correct.
|
179
|
+
Style/MultilineBlockLayout:
|
180
|
+
Exclude:
|
181
|
+
- 'tests/tests_spec.rb'
|
182
|
+
|
183
|
+
# Offense count: 41
|
184
|
+
# Cop supports --auto-correct.
|
185
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
186
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
187
|
+
Style/MultilineMethodCallIndentation:
|
188
|
+
Exclude:
|
189
|
+
- 'tests/tests_spec.rb'
|
190
|
+
|
191
|
+
# Offense count: 15
|
192
|
+
# Cop supports --auto-correct.
|
193
|
+
Style/MutableConstant:
|
194
|
+
Exclude:
|
195
|
+
- 'lib/rosette_api.rb'
|
196
|
+
|
197
|
+
# Offense count: 1
|
198
|
+
# Cop supports --auto-correct.
|
199
|
+
Style/NegatedIf:
|
200
|
+
Exclude:
|
201
|
+
- 'lib/name_translation_parameters.rb'
|
202
|
+
|
203
|
+
# Offense count: 1
|
204
|
+
# Cop supports --auto-correct.
|
205
|
+
# Configuration parameters: IncludeSemanticChanges.
|
206
|
+
Style/NonNilCheck:
|
207
|
+
Exclude:
|
208
|
+
- 'lib/request_builder.rb'
|
209
|
+
|
210
|
+
# Offense count: 2
|
211
|
+
Style/OptionalArguments:
|
212
|
+
Exclude:
|
213
|
+
- 'lib/request_builder.rb'
|
214
|
+
|
215
|
+
# Offense count: 4
|
216
|
+
# Cop supports --auto-correct.
|
217
|
+
# Configuration parameters: PreferredDelimiters.
|
218
|
+
Style/PercentLiteralDelimiters:
|
219
|
+
Exclude:
|
220
|
+
- 'rosette_api.gemspec'
|
221
|
+
|
222
|
+
# Offense count: 8
|
223
|
+
# Cop supports --auto-correct.
|
224
|
+
# Configuration parameters: SupportedStyles.
|
225
|
+
# SupportedStyles: compact, exploded
|
226
|
+
Style/RaiseArgs:
|
227
|
+
EnforcedStyle: compact
|
228
|
+
|
229
|
+
# Offense count: 7
|
230
|
+
# Cop supports --auto-correct.
|
231
|
+
Style/RedundantSelf:
|
232
|
+
Exclude:
|
233
|
+
- 'lib/document_parameters.rb'
|
234
|
+
- 'lib/name_parameter.rb'
|
235
|
+
- 'lib/name_similarity_parameters.rb'
|
236
|
+
- 'lib/name_translation_parameters.rb'
|
237
|
+
|
238
|
+
# Offense count: 1
|
239
|
+
# Cop supports --auto-correct.
|
240
|
+
Style/SpaceAfterColon:
|
241
|
+
Exclude:
|
242
|
+
- 'examples/name_similarity.rb'
|
243
|
+
|
244
|
+
# Offense count: 2
|
245
|
+
# Cop supports --auto-correct.
|
246
|
+
# Configuration parameters: AllowForAlignment.
|
247
|
+
Style/SpaceAroundOperators:
|
248
|
+
Exclude:
|
249
|
+
- 'examples/language.rb'
|
250
|
+
- 'rosette_api.gemspec'
|
251
|
+
|
252
|
+
# Offense count: 56
|
253
|
+
# Cop supports --auto-correct.
|
254
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
255
|
+
# SupportedStyles: space, no_space, compact
|
256
|
+
Style/SpaceInsideHashLiteralBraces:
|
257
|
+
Exclude:
|
258
|
+
- 'examples/language.rb'
|
259
|
+
- 'tests/tests_spec.rb'
|
260
|
+
|
261
|
+
# Offense count: 44
|
262
|
+
# Cop supports --auto-correct.
|
263
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
264
|
+
# SupportedStyles: single_quotes, double_quotes
|
265
|
+
Style/StringLiterals:
|
266
|
+
Exclude:
|
267
|
+
- 'Gemfile'
|
268
|
+
- 'examples/categories.rb'
|
269
|
+
- 'examples/entities.rb'
|
270
|
+
- 'examples/language.rb'
|
271
|
+
- 'examples/morphology_complete.rb'
|
272
|
+
- 'examples/morphology_compound-components.rb'
|
273
|
+
- 'examples/morphology_han-readings.rb'
|
274
|
+
- 'examples/name_similarity.rb'
|
275
|
+
- 'examples/name_translation.rb'
|
276
|
+
- 'examples/sentiment.rb'
|
277
|
+
- 'examples/syntax_dependencies.rb'
|
278
|
+
- 'examples/tokens.rb'
|
279
|
+
- 'tests/tests_spec.rb'
|
280
|
+
|
281
|
+
# Offense count: 14
|
282
|
+
# Cop supports --auto-correct.
|
283
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
284
|
+
# SupportedStyles: final_newline, final_blank_line
|
285
|
+
Style/TrailingBlankLines:
|
286
|
+
Exclude:
|
287
|
+
- 'examples/info.rb'
|
288
|
+
- 'examples/language.rb'
|
289
|
+
- 'examples/morphology_compound-components.rb'
|
290
|
+
- 'examples/morphology_han-readings.rb'
|
291
|
+
- 'examples/morphology_lemmas.rb'
|
292
|
+
- 'examples/morphology_parts-of-speech.rb'
|
293
|
+
- 'examples/name_similarity.rb'
|
294
|
+
- 'examples/name_translation.rb'
|
295
|
+
- 'examples/ping.rb'
|
296
|
+
- 'examples/sentences.rb'
|
297
|
+
- 'examples/sentiment.rb'
|
298
|
+
- 'examples/tokens.rb'
|
299
|
+
- 'lib/rosette_api.rb'
|
300
|
+
- 'lib/rosette_api_error.rb'
|
301
|
+
|
302
|
+
# Offense count: 1
|
303
|
+
# Cop supports --auto-correct.
|
304
|
+
Style/TrailingWhitespace:
|
305
|
+
Exclude:
|
306
|
+
- 'lib/request_builder.rb'
|
307
|
+
|
308
|
+
# Offense count: 4
|
309
|
+
# Cop supports --auto-correct.
|
310
|
+
Style/UnneededPercentQ:
|
311
|
+
Exclude:
|
312
|
+
- 'rosette_api.gemspec'
|
data/lib/document_parameters.rb
CHANGED
@@ -56,10 +56,10 @@ class DocumentParameters
|
|
56
56
|
#
|
57
57
|
# Returns the new Hash.
|
58
58
|
def load_params
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
validate_params
|
60
|
+
to_hash.select { |_key, value| !value.nil? }
|
61
|
+
.map { |key, value| [key.to_s.split('_').map(&:capitalize).join.sub!(/\D/, &:downcase), value] }
|
62
|
+
.to_h
|
63
63
|
end
|
64
64
|
|
65
65
|
# Converts this class to Hash.
|
data/lib/request_builder.rb
CHANGED
@@ -19,13 +19,16 @@ class RequestBuilder
|
|
19
19
|
attr_accessor :binding_version
|
20
20
|
|
21
21
|
|
22
|
-
def initialize(user_key, alternate_url, http_client, params = {}, binding_version)
|
22
|
+
def initialize(user_key, alternate_url, http_client, params = {}, url_parameters = nil, binding_version)
|
23
23
|
@user_key = user_key
|
24
24
|
@alternate_url = alternate_url
|
25
25
|
@http_client = http_client
|
26
26
|
@params = params
|
27
27
|
@binding_version = binding_version
|
28
28
|
|
29
|
+
return unless url_parameters
|
30
|
+
@alternate_url = @alternate_url + '?' + URI.encode_www_form(url_parameters)
|
31
|
+
|
29
32
|
end
|
30
33
|
|
31
34
|
# Prepares a plain POST request for Rosette API.
|
@@ -43,7 +46,7 @@ class RequestBuilder
|
|
43
46
|
raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
|
44
47
|
end
|
45
48
|
|
46
|
-
if params['customHeaders']
|
49
|
+
if params['customHeaders']
|
47
50
|
keys_array = params['customHeaders'].keys
|
48
51
|
for k in keys_array
|
49
52
|
if k.to_s =~ /^X-RosetteAPI-/
|
@@ -141,20 +144,20 @@ class RequestBuilder
|
|
141
144
|
end
|
142
145
|
request['X-RosetteAPI-Key'] = @user_key
|
143
146
|
|
144
|
-
|
147
|
+
get_response @http_client, request
|
145
148
|
end
|
146
149
|
|
147
150
|
# Sends a POST request to Rosette API.
|
148
151
|
#
|
149
152
|
# Returns JSON response or raises RosetteAPIError if encountered.
|
150
153
|
def send_post_request
|
151
|
-
if
|
152
|
-
http, request =
|
154
|
+
if params['filePath']
|
155
|
+
http, request = prepare_multipart_request params
|
153
156
|
else
|
154
|
-
http, request =
|
157
|
+
http, request = prepare_plain_request params
|
155
158
|
end
|
156
159
|
|
157
|
-
|
160
|
+
get_response http, request
|
158
161
|
end
|
159
162
|
|
160
163
|
# Gets response from HTTP connection.
|
data/lib/rosette_api.rb
CHANGED
@@ -9,35 +9,35 @@ 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.
|
12
|
+
BINDING_VERSION = '1.5.0'
|
13
13
|
# Rosette API language endpoint
|
14
|
-
LANGUAGE_ENDPOINT = '/language'
|
14
|
+
LANGUAGE_ENDPOINT = '/language'.freeze
|
15
15
|
# Rosette API morphology endpoint
|
16
|
-
MORPHOLOGY_ENDPOINT = '/morphology'
|
16
|
+
MORPHOLOGY_ENDPOINT = '/morphology'.freeze
|
17
17
|
# Rosette API entities endpoint
|
18
|
-
ENTITIES_ENDPOINT = '/entities'
|
18
|
+
ENTITIES_ENDPOINT = '/entities'.freeze
|
19
19
|
# Rosette API categories endpoint
|
20
|
-
CATEGORIES_ENDPOINT = '/categories'
|
20
|
+
CATEGORIES_ENDPOINT = '/categories'.freeze
|
21
21
|
# Rosette API relationships endpoint
|
22
|
-
RELATIONSHIPS_ENDPOINT = '/relationships'
|
22
|
+
RELATIONSHIPS_ENDPOINT = '/relationships'.freeze
|
23
23
|
# Rosette API sentiment endpoint
|
24
|
-
SENTIMENT_ENDPOINT = '/sentiment'
|
24
|
+
SENTIMENT_ENDPOINT = '/sentiment'.freeze
|
25
25
|
# Rosette API name-translation endpoint
|
26
|
-
NAME_TRANSLATION_ENDPOINT = '/name-translation'
|
26
|
+
NAME_TRANSLATION_ENDPOINT = '/name-translation'.freeze
|
27
27
|
# Rosette API name-similarity endpoint
|
28
|
-
NAME_SIMILARITY_ENDPOINT = '/name-similarity'
|
28
|
+
NAME_SIMILARITY_ENDPOINT = '/name-similarity'.freeze
|
29
29
|
# Rosette API tokens endpoint
|
30
|
-
TOKENS_ENDPOINT = '/tokens'
|
30
|
+
TOKENS_ENDPOINT = '/tokens'.freeze
|
31
31
|
# Rosette API sentences endpoint
|
32
|
-
SENTENCES_ENDPOINT = '/sentences'
|
32
|
+
SENTENCES_ENDPOINT = '/sentences'.freeze
|
33
33
|
# Rosette API info endpoint
|
34
|
-
INFO = '/info'
|
34
|
+
INFO = '/info'.freeze
|
35
35
|
# Rosette API ping endpoint
|
36
|
-
PING = '/ping'
|
36
|
+
PING = '/ping'.freeze
|
37
37
|
# Text Embedding endpoint
|
38
|
-
TEXT_EMBEDDING = '/text-embedding'
|
38
|
+
TEXT_EMBEDDING = '/text-embedding'.freeze
|
39
39
|
# Syntactic Dependencies endpoint
|
40
|
-
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'
|
40
|
+
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'.freeze
|
41
41
|
|
42
42
|
# Rosette API key
|
43
43
|
attr_accessor :user_key
|
@@ -45,10 +45,13 @@ class RosetteAPI
|
|
45
45
|
attr_accessor :alternate_url
|
46
46
|
# custom Rosette API headers
|
47
47
|
attr_accessor :custom_headers
|
48
|
+
# URL query parameter(s)
|
49
|
+
attr_accessor :url_parameters
|
48
50
|
|
49
|
-
def initialize(user_key, alternate_url = 'https://api.rosette.com/rest/v1')
|
51
|
+
def initialize(user_key, alternate_url = 'https://api.rosette.com/rest/v1')
|
50
52
|
@user_key = user_key
|
51
53
|
@alternate_url = alternate_url
|
54
|
+
@url_parameters = nil
|
52
55
|
|
53
56
|
if @alternate_url.to_s.end_with?('/')
|
54
57
|
@alternate_url = alternate_url.to_s.slice(0..-2)
|
@@ -71,7 +74,7 @@ class RosetteAPI
|
|
71
74
|
|
72
75
|
params = params.load_params
|
73
76
|
|
74
|
-
RequestBuilder.new(@user_key, @alternate_url + LANGUAGE_ENDPOINT, @http_client, params, BINDING_VERSION)
|
77
|
+
RequestBuilder.new(@user_key, @alternate_url + LANGUAGE_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
75
78
|
.send_post_request
|
76
79
|
end
|
77
80
|
|
@@ -89,7 +92,7 @@ class RosetteAPI
|
|
89
92
|
|
90
93
|
params = params.load_params
|
91
94
|
|
92
|
-
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/complete', @http_client, params, BINDING_VERSION)
|
95
|
+
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/complete', @http_client, params, @url_parameters, BINDING_VERSION)
|
93
96
|
.send_post_request
|
94
97
|
end
|
95
98
|
|
@@ -106,7 +109,7 @@ class RosetteAPI
|
|
106
109
|
|
107
110
|
params = params.load_params
|
108
111
|
|
109
|
-
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/compound-components', @http_client, params, BINDING_VERSION)
|
112
|
+
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/compound-components', @http_client, params, @url_parameters, BINDING_VERSION)
|
110
113
|
.send_post_request
|
111
114
|
end
|
112
115
|
|
@@ -123,7 +126,7 @@ class RosetteAPI
|
|
123
126
|
|
124
127
|
params = params.load_params
|
125
128
|
|
126
|
-
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/han-readings', @http_client, params, BINDING_VERSION)
|
129
|
+
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/han-readings', @http_client, params, @url_parameters, BINDING_VERSION)
|
127
130
|
.send_post_request
|
128
131
|
end
|
129
132
|
|
@@ -139,7 +142,7 @@ class RosetteAPI
|
|
139
142
|
|
140
143
|
params = params.load_params
|
141
144
|
|
142
|
-
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/lemmas', @http_client, params, BINDING_VERSION)
|
145
|
+
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/lemmas', @http_client, params, @url_parameters, BINDING_VERSION)
|
143
146
|
.send_post_request
|
144
147
|
end
|
145
148
|
|
@@ -156,7 +159,7 @@ class RosetteAPI
|
|
156
159
|
|
157
160
|
params = params.load_params
|
158
161
|
|
159
|
-
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/parts-of-speech', @http_client, params, BINDING_VERSION)
|
162
|
+
RequestBuilder.new(@user_key, @alternate_url + MORPHOLOGY_ENDPOINT + '/parts-of-speech', @http_client, params, @url_parameters, BINDING_VERSION)
|
160
163
|
.send_post_request
|
161
164
|
end
|
162
165
|
|
@@ -165,37 +168,18 @@ class RosetteAPI
|
|
165
168
|
# ==== Attributes
|
166
169
|
#
|
167
170
|
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
168
|
-
# * +resolve_entities+ - Enables entities to be linked in application endpoints.
|
169
171
|
#
|
170
172
|
# Returns each entity extracted from the input.
|
171
|
-
def get_entities(params
|
173
|
+
def get_entities(params)
|
172
174
|
check_params params
|
173
175
|
|
174
|
-
raise BadRequestError.new('Expects boolean for resolve_entities') unless !!resolve_entities == resolve_entities
|
175
|
-
|
176
176
|
params = params.load_params
|
177
177
|
|
178
|
-
endpoint =
|
179
|
-
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, params, BINDING_VERSION)
|
178
|
+
endpoint = ENTITIES_ENDPOINT
|
179
|
+
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, params, @url_parameters, BINDING_VERSION)
|
180
180
|
.send_post_request
|
181
181
|
end
|
182
182
|
|
183
|
-
# Extracts entities from the input.
|
184
|
-
#
|
185
|
-
# ==== Attributes
|
186
|
-
#
|
187
|
-
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
|
188
|
-
#
|
189
|
-
# Returns list of entities that have been linked to entities in the knowledge
|
190
|
-
# base.
|
191
|
-
def get_entities_linked(params)
|
192
|
-
warn '[DEPRECATION] `get_entities_linked` is deprecated. Please use ' \
|
193
|
-
'`get_entities` instead.'
|
194
|
-
get_entities(params, true)
|
195
|
-
end
|
196
|
-
|
197
|
-
|
198
|
-
|
199
183
|
# Extracts Tier 1 contextual categories from the input.
|
200
184
|
#
|
201
185
|
# ==== Attributes
|
@@ -208,7 +192,7 @@ class RosetteAPI
|
|
208
192
|
|
209
193
|
params = params.load_params
|
210
194
|
|
211
|
-
RequestBuilder.new(@user_key, @alternate_url + CATEGORIES_ENDPOINT, @http_client, params, BINDING_VERSION)
|
195
|
+
RequestBuilder.new(@user_key, @alternate_url + CATEGORIES_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
212
196
|
.send_post_request
|
213
197
|
end
|
214
198
|
|
@@ -224,7 +208,7 @@ class RosetteAPI
|
|
224
208
|
|
225
209
|
params = params.load_params
|
226
210
|
|
227
|
-
RequestBuilder.new(@user_key, @alternate_url + RELATIONSHIPS_ENDPOINT, @http_client, params, BINDING_VERSION)
|
211
|
+
RequestBuilder.new(@user_key, @alternate_url + RELATIONSHIPS_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
228
212
|
.send_post_request
|
229
213
|
end
|
230
214
|
|
@@ -240,7 +224,7 @@ class RosetteAPI
|
|
240
224
|
|
241
225
|
params = params.load_params
|
242
226
|
|
243
|
-
RequestBuilder.new(@user_key, @alternate_url + SENTIMENT_ENDPOINT, @http_client, params, BINDING_VERSION)
|
227
|
+
RequestBuilder.new(@user_key, @alternate_url + SENTIMENT_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
244
228
|
.send_post_request
|
245
229
|
end
|
246
230
|
|
@@ -256,7 +240,7 @@ class RosetteAPI
|
|
256
240
|
|
257
241
|
params = params.load_params
|
258
242
|
|
259
|
-
RequestBuilder.new(@user_key, @alternate_url + NAME_TRANSLATION_ENDPOINT, @http_client, params, BINDING_VERSION)
|
243
|
+
RequestBuilder.new(@user_key, @alternate_url + NAME_TRANSLATION_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
260
244
|
.send_post_request
|
261
245
|
end
|
262
246
|
|
@@ -273,7 +257,7 @@ class RosetteAPI
|
|
273
257
|
|
274
258
|
params = params.load_params
|
275
259
|
|
276
|
-
RequestBuilder.new(@user_key, @alternate_url + NAME_SIMILARITY_ENDPOINT, @http_client, params, BINDING_VERSION)
|
260
|
+
RequestBuilder.new(@user_key, @alternate_url + NAME_SIMILARITY_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
277
261
|
.send_post_request
|
278
262
|
end
|
279
263
|
|
@@ -289,7 +273,7 @@ class RosetteAPI
|
|
289
273
|
|
290
274
|
params = params.load_params
|
291
275
|
|
292
|
-
RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT, @http_client, params, BINDING_VERSION)
|
276
|
+
RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
293
277
|
.send_post_request
|
294
278
|
end
|
295
279
|
|
@@ -305,9 +289,10 @@ class RosetteAPI
|
|
305
289
|
|
306
290
|
params = params.load_params
|
307
291
|
|
308
|
-
RequestBuilder.new(@user_key, @alternate_url + SENTENCES_ENDPOINT, @http_client, params, BINDING_VERSION)
|
292
|
+
RequestBuilder.new(@user_key, @alternate_url + SENTENCES_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
309
293
|
.send_post_request
|
310
294
|
end
|
295
|
+
|
311
296
|
#
|
312
297
|
# Returns the vectors associated with the text
|
313
298
|
#
|
@@ -321,7 +306,7 @@ class RosetteAPI
|
|
321
306
|
|
322
307
|
params = params.load_params
|
323
308
|
|
324
|
-
RequestBuilder.new(@user_key, @alternate_url + TEXT_EMBEDDING, @http_client, params, BINDING_VERSION)
|
309
|
+
RequestBuilder.new(@user_key, @alternate_url + TEXT_EMBEDDING, @http_client, params, @url_parameters, BINDING_VERSION)
|
325
310
|
.send_post_request
|
326
311
|
end
|
327
312
|
|
@@ -338,29 +323,28 @@ class RosetteAPI
|
|
338
323
|
|
339
324
|
params = params.load_params
|
340
325
|
|
341
|
-
RequestBuilder.new(@user_key, @alternate_url + SYNTACTIC_DEPENDENCIES_ENDPOINT, @http_client, params, BINDING_VERSION)
|
326
|
+
RequestBuilder.new(@user_key, @alternate_url + SYNTACTIC_DEPENDENCIES_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
|
342
327
|
.send_post_request
|
343
328
|
end
|
344
329
|
|
345
330
|
# Gets information about the Rosette API, returns name, build number
|
346
331
|
# and build time.
|
347
332
|
def info
|
348
|
-
RequestBuilder.new(@user_key, @alternate_url + INFO, @http_client, BINDING_VERSION)
|
333
|
+
RequestBuilder.new(@user_key, @alternate_url + INFO, @http_client, @url_parameters, BINDING_VERSION)
|
349
334
|
.send_get_request
|
350
335
|
end
|
351
336
|
|
352
337
|
# Pings the Rosette API for a response indicting that the service is
|
353
338
|
# available.
|
354
339
|
def ping
|
355
|
-
RequestBuilder.new(@user_key, @alternate_url + PING, @http_client, BINDING_VERSION)
|
340
|
+
RequestBuilder.new(@user_key, @alternate_url + PING, @http_client, @url_parameters, BINDING_VERSION)
|
356
341
|
.send_get_request
|
357
342
|
end
|
358
343
|
|
359
344
|
private
|
360
345
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
346
|
+
# Checks that the right parameter type is being passed in.
|
347
|
+
def check_params(params, message = 'Expects a DocumentParameters type as an argument', type = DocumentParameters)
|
348
|
+
raise BadRequestError.new message unless params.is_a? type
|
349
|
+
end
|
365
350
|
end
|
366
|
-
|
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.
|
24
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
60
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
81
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
102
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
123
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
144
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
165
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
187
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
218
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
239
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
261
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
288
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
323
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
344
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
395
|
+
'X-Rosetteapi-Binding-Version' => '1.5.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.
|
432
|
+
'X-Rosetteapi-Binding-Version' => '1.5.0'}).
|
433
433
|
to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
|
434
434
|
end
|
435
435
|
it 'test text_embedding' do
|
@@ -450,7 +450,7 @@ describe RosetteAPI do
|
|
450
450
|
'User-Agent' => 'Ruby',
|
451
451
|
'X-Rosetteapi-Key' => '0123456789',
|
452
452
|
'X-Rosetteapi-Binding' => 'ruby',
|
453
|
-
'X-Rosetteapi-Binding-Version' => '1.
|
453
|
+
'X-Rosetteapi-Binding-Version' => '1.5.0'}).
|
454
454
|
to_return(:status => 200, :body => "{\"test\": \"language\"}", :headers => {})
|
455
455
|
end
|
456
456
|
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.5.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-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubysl-securerandom
|
@@ -31,6 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".rubocop.yml"
|
34
35
|
- lib/bad_request_error.rb
|
35
36
|
- lib/bad_request_format_error.rb
|
36
37
|
- lib/document_parameters.rb
|