rosette_api 1.8.0 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +13 -0
  3. data/README.md +38 -0
  4. data/examples/README.md +36 -0
  5. data/examples/address_similarity.rb +29 -0
  6. data/examples/categories.rb +22 -0
  7. data/examples/entities.rb +23 -0
  8. data/examples/info.rb +20 -0
  9. data/examples/language.rb +23 -0
  10. data/examples/language_multilingual.rb +25 -0
  11. data/examples/morphology_complete.rb +22 -0
  12. data/examples/morphology_compound-components.rb +24 -0
  13. data/examples/morphology_han-readings.rb +22 -0
  14. data/examples/morphology_lemmas.rb +22 -0
  15. data/examples/morphology_parts-of-speech.rb +22 -0
  16. data/examples/name_deduplication.rb +25 -0
  17. data/examples/name_similarity.rb +28 -0
  18. data/examples/name_translation.rb +26 -0
  19. data/examples/ping.rb +20 -0
  20. data/examples/relationships.rb +23 -0
  21. data/examples/semantic_vectors.rb +22 -0
  22. data/examples/sentences.rb +24 -0
  23. data/examples/sentiment.rb +26 -0
  24. data/examples/similar_terms.rb +23 -0
  25. data/examples/syntax_dependencies.rb +23 -0
  26. data/examples/tokens.rb +22 -0
  27. data/examples/topics.rb +23 -0
  28. data/examples/transliteration.rb +24 -0
  29. data/lib/address_parameter.rb +117 -0
  30. data/lib/address_similarity_parameters.rb +49 -0
  31. data/lib/bad_request_error.rb +2 -0
  32. data/lib/bad_request_format_error.rb +2 -0
  33. data/lib/document_parameters.rb +20 -11
  34. data/lib/name_deduplication_parameters.rb +15 -7
  35. data/lib/name_parameter.rb +6 -3
  36. data/lib/name_similarity_parameters.rb +14 -6
  37. data/lib/name_translation_parameters.rb +12 -6
  38. data/lib/request_builder.rb +49 -18
  39. data/lib/rosette_api.rb +193 -66
  40. data/lib/rosette_api_error.rb +3 -1
  41. metadata +43 -14
  42. data/.rubocop.yml +0 -312
  43. data/tests/tests_spec.rb +0 -583
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This class encapsulates all Rosette API server errors encountered during
2
4
  # requests.
3
5
  class RosetteAPIError < StandardError
@@ -10,4 +12,4 @@ class RosetteAPIError < StandardError
10
12
  @status_code = status_code
11
13
  @message = message
12
14
  end
13
- end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosette_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.14.4
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: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubysl-securerandom
@@ -24,14 +24,46 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- description: A Ruby client binding for the Rosette API, a multilingual text analytics
28
- RESTful API.
27
+ description: The Rosette Text Analytics Platform uses natural language processing,
28
+ statistical modeling, and machine learning to analyze unstructured and semi-structured
29
+ text across 364 language-encoding-script combinations, revealing valuable information
30
+ and actionable data. Rosette provides endpoints for extracting entities and relationships,
31
+ translating and comparing the similarity of names, categorizing and adding linguistic
32
+ tags to text and more.
29
33
  email: support@rosette.com
30
34
  executables: []
31
35
  extensions: []
32
36
  extra_rdoc_files: []
33
37
  files:
34
- - ".rubocop.yml"
38
+ - LICENSE
39
+ - README.md
40
+ - examples/README.md
41
+ - examples/address_similarity.rb
42
+ - examples/categories.rb
43
+ - examples/entities.rb
44
+ - examples/info.rb
45
+ - examples/language.rb
46
+ - examples/language_multilingual.rb
47
+ - examples/morphology_complete.rb
48
+ - examples/morphology_compound-components.rb
49
+ - examples/morphology_han-readings.rb
50
+ - examples/morphology_lemmas.rb
51
+ - examples/morphology_parts-of-speech.rb
52
+ - examples/name_deduplication.rb
53
+ - examples/name_similarity.rb
54
+ - examples/name_translation.rb
55
+ - examples/ping.rb
56
+ - examples/relationships.rb
57
+ - examples/semantic_vectors.rb
58
+ - examples/sentences.rb
59
+ - examples/sentiment.rb
60
+ - examples/similar_terms.rb
61
+ - examples/syntax_dependencies.rb
62
+ - examples/tokens.rb
63
+ - examples/topics.rb
64
+ - examples/transliteration.rb
65
+ - lib/address_parameter.rb
66
+ - lib/address_similarity_parameters.rb
35
67
  - lib/bad_request_error.rb
36
68
  - lib/bad_request_format_error.rb
37
69
  - lib/document_parameters.rb
@@ -42,10 +74,9 @@ files:
42
74
  - lib/request_builder.rb
43
75
  - lib/rosette_api.rb
44
76
  - lib/rosette_api_error.rb
45
- - tests/tests_spec.rb
46
77
  homepage: https://developer.rosette.com/
47
78
  licenses:
48
- - MIT
79
+ - Apache-2.0
49
80
  metadata: {}
50
81
  post_install_message:
51
82
  rdoc_options: []
@@ -55,17 +86,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
86
  requirements:
56
87
  - - ">="
57
88
  - !ruby/object:Gem::Version
58
- version: 2.0.0
89
+ version: 2.3.0
59
90
  required_rubygems_version: !ruby/object:Gem::Requirement
60
91
  requirements:
61
92
  - - ">="
62
93
  - !ruby/object:Gem::Version
63
94
  version: '0'
64
95
  requirements: []
65
- rubyforge_project:
66
- rubygems_version: 2.6.14
96
+ rubygems_version: 3.1.2
67
97
  signing_key:
68
- specification_version: 2
69
- summary: Rosette API gem that supports multilingual text-analytics.
70
- test_files:
71
- - tests/tests_spec.rb
98
+ specification_version: 4
99
+ summary: A Ruby interface for Rosette Text Analytics Platform.
100
+ test_files: []
@@ -1,312 +0,0 @@
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'
@@ -1,583 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rosette_api'
3
- require 'rspec'
4
- require 'webmock/rspec'
5
- require 'json'
6
- WebMock.disable_net_connect!(allow_localhost: true)
7
-
8
- describe RosetteAPI do
9
- RSpec.configure do |config|
10
- config.before(:example) { @content = 'Sample Content' }
11
- config.before(:example) { @json = {content: 'Sample Content'}.to_json }
12
- end
13
-
14
- describe '.get_language' do
15
- before do
16
- stub_request(:post, 'https://api.rosette.com/rest/v1/language')
17
- .with(body: @json,
18
- headers: { 'Accept' => 'application/json',
19
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
20
- 'Content-Type' => 'application/json',
21
- 'User-Agent' => 'Ruby',
22
- 'X-Rosetteapi-Key' => '0123456789',
23
- 'X-Rosetteapi-Binding' => 'ruby',
24
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
25
- .to_return(status: 200, body: '{"test": "language"}', headers: {})
26
- end
27
- it 'test language' do
28
- params = DocumentParameters.new
29
- params.content = @content
30
- response = RosetteAPI.new('0123456789').get_language(params)
31
- expect(response).instance_of? Hash
32
- end
33
-
34
- it 'badRequestFormat: the format of the request is invalid: multiple content sources' do
35
- params = DocumentParameters.new
36
- params.content = 'Por favor Senorita, says the man.?'
37
- params.content_uri = 'Por favor Senorita, says the man.?'
38
- expect { RosetteAPI.new('0123456789').get_language(params) }.to raise_error(BadRequestFormatError)
39
- end
40
-
41
- it 'badRequestFormat: the format of the request is invalid: no content provided;' do
42
- params = DocumentParameters.new
43
- expect { RosetteAPI.new('0123456789').get_language(params) }.to raise_error(BadRequestFormatError)
44
- end
45
-
46
- end
47
-
48
- describe '.get_morphology_complete' do
49
- before do
50
- stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/complete')
51
- .with(body: @json,
52
- headers: { 'Accept' => 'application/json',
53
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
54
- 'Content-Type' => 'application/json',
55
- 'User-Agent' => 'Ruby',
56
- 'X-Rosetteapi-Key' => '0123456789',
57
- 'X-Rosetteapi-Binding' => 'ruby',
58
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
59
- .to_return(status: 200, body: '{"test": "morphology/complete"}', headers: {})
60
- end
61
- it 'test morphology complete' do
62
- params = DocumentParameters.new
63
- params.content = @content
64
- response = RosetteAPI.new('0123456789').get_morphology_complete(params)
65
- expect(response).instance_of? Hash
66
- end
67
- end
68
-
69
- describe '.get_compound_components' do
70
- before do
71
- stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/compound-components')
72
- .with(body: @json,
73
- headers: { 'Accept' => 'application/json',
74
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
75
- 'Content-Type' => 'application/json',
76
- 'User-Agent' => 'Ruby',
77
- 'X-Rosetteapi-Key' => '0123456789',
78
- 'X-Rosetteapi-Binding' => 'ruby',
79
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
80
- .to_return(status: 200, body: '{"test": "morphology/compound-components"}', headers: {})
81
- end
82
- it 'test morphology compound components' do
83
- params = DocumentParameters.new
84
- params.content = @content
85
- response = RosetteAPI.new('0123456789').get_compound_components(params)
86
- expect(response).instance_of? Hash
87
- end
88
- end
89
-
90
- describe '.get_han_readings' do
91
- before do
92
- stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/han-readings')
93
- .with(body: @json,
94
- headers: { 'Accept' => 'application/json',
95
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
96
- 'Content-Type' => 'application/json',
97
- 'User-Agent' => 'Ruby',
98
- 'X-Rosetteapi-Key' => '0123456789',
99
- 'X-Rosetteapi-Binding' => 'ruby',
100
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
101
- .to_return(status: 200, body: '{"test": "morphology/han-readings"}', headers: {})
102
- end
103
- it 'test morphology han readings' do
104
- params = DocumentParameters.new
105
- params.content = @content
106
- response = RosetteAPI.new('0123456789').get_han_readings(params)
107
- expect(response).instance_of? Hash
108
- end
109
- end
110
-
111
- describe '.get_parts_of_speech' do
112
- before do
113
- stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/parts-of-speech')
114
- .with(body: @json,
115
- headers: { 'Accept' => 'application/json',
116
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
117
- 'Content-Type' => 'application/json',
118
- 'User-Agent' => 'Ruby',
119
- 'X-Rosetteapi-Key' => '0123456789',
120
- 'X-Rosetteapi-Binding' => 'ruby',
121
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
122
- .to_return(status: 200, body: '{"test": "morphology/parts-of-speech"}', headers: {})
123
- end
124
- it 'test morphology parts of speech' do
125
- params = DocumentParameters.new
126
- params.content = @content
127
- response = RosetteAPI.new('0123456789').get_parts_of_speech(params)
128
- expect(response).instance_of? Hash
129
- end
130
- end
131
-
132
- describe '.get_lemmas' do
133
- before do
134
- stub_request(:post, 'https://api.rosette.com/rest/v1/morphology/lemmas')
135
- .with(body: @json,
136
- headers: { 'Accept' => 'application/json',
137
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
138
- 'Content-Type' => 'application/json',
139
- 'User-Agent' => 'Ruby',
140
- 'X-Rosetteapi-Key' => '0123456789',
141
- 'X-Rosetteapi-Binding' => 'ruby',
142
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
143
- .to_return(status: 200, body: '{"test": "morphology/lemmas"}', headers: {})
144
- end
145
- it 'test morphology lemmas' do
146
- params = DocumentParameters.new
147
- params.content = @content
148
- response = RosetteAPI.new('0123456789').get_lemmas(params)
149
- expect(response).instance_of? Hash
150
- end
151
- end
152
-
153
- describe '.get_entities' do
154
- before do
155
- stub_request(:post, 'https://api.rosette.com/rest/v1/entities')
156
- .with(body: @json,
157
- headers: { 'Accept' => 'application/json',
158
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
159
- 'Content-Type' => 'application/json',
160
- 'User-Agent' => 'Ruby',
161
- 'X-Rosetteapi-Key' => '0123456789',
162
- 'X-Rosetteapi-Binding' => 'ruby',
163
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
164
- .to_return(status: 200, body: '{"test": "entities"}', headers: {})
165
- end
166
- it 'test entities' do
167
- params = DocumentParameters.new
168
- params.content = @content
169
- response = RosetteAPI.new('0123456789').get_entities(params)
170
- expect(response).instance_of? Hash
171
- end
172
- end
173
-
174
- describe '.get_entities_no_qids' do
175
- before do
176
- no_qids_json = { content: 'Sample Content', options: { linkEntities: false } }.to_json
177
- stub_request(:post, 'https://api.rosette.com/rest/v1/entities')
178
- .with(body: no_qids_json,
179
- headers: { 'Accept' => 'application/json',
180
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
181
- 'Content-Type' => 'application/json',
182
- 'User-Agent' => 'Ruby',
183
- 'X-Rosetteapi-Key' => '0123456789',
184
- 'X-Rosetteapi-Binding' => 'ruby',
185
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
186
- .to_return(status: 200, body: '{"test": "entities"}', headers: {})
187
- end
188
- it 'test entities without qids' do
189
- params = DocumentParameters.new
190
- params.content = @content
191
- params.rosette_options = { linkEntities: false}
192
- response = RosetteAPI.new('0123456789').get_entities(params)
193
- expect(response).instance_of? Hash
194
- end
195
-
196
- it 'test rosette_options is not a Hash' do
197
- params = DocumentParameters.new
198
- params.content = 'Last month director Paul Feig announced the movie will have an all-star female cast including' \
199
- ' Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.'
200
- params.rosette_options = 1
201
- expect { RosetteAPI.new('0123456789').get_entities(params) }.to raise_error(BadRequestError)
202
- end
203
- end
204
-
205
- describe '.get_categories' do
206
- before do
207
- categories_json = { contentUri: 'http://google.com' }.to_json
208
- stub_request(:post, 'https://api.rosette.com/rest/v1/categories')
209
- .with(body: categories_json,
210
- headers: { 'Accept' => 'application/json',
211
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
212
- 'Content-Type' => 'application/json',
213
- 'User-Agent' => 'Ruby',
214
- 'X-Rosetteapi-Key' => '0123456789',
215
- 'X-Rosetteapi-Binding' => 'ruby',
216
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
217
- .to_return(status: 200, body: '{"test": "categories"}', headers: {})
218
- end
219
- it 'test categories' do
220
- params = DocumentParameters.new
221
- params.content_uri = 'http://google.com'
222
- response = RosetteAPI.new('0123456789').get_categories(params)
223
- expect(response).instance_of? Hash
224
- end
225
- end
226
-
227
- describe '.get_relationships' do
228
- before do
229
- stub_request(:post, 'https://api.rosette.com/rest/v1/relationships')
230
- .with(body: @json,
231
- headers: { 'Accept' => 'application/json',
232
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
233
- 'Content-Type' => 'application/json',
234
- 'User-Agent' => 'Ruby',
235
- 'X-Rosetteapi-Key' => '0123456789',
236
- 'X-Rosetteapi-Binding' => 'ruby',
237
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
238
- .to_return(status: 200, body: '{"test": "relationships"}', headers: {})
239
- end
240
- it 'test relationships' do
241
- params = DocumentParameters.new
242
- params.content = @content
243
- response = RosetteAPI.new('0123456789').get_relationships(params)
244
- expect(response).instance_of? Hash
245
- end
246
- end
247
-
248
- describe '.name_translation' do
249
- before do
250
- name_translation_json = { name: 'معمر محمد أبو منيار القذاف', targetLanguage: 'eng', targetScript: 'Latn' }.to_json
251
- stub_request(:post, 'https://api.rosette.com/rest/v1/name-translation')
252
- .with(body: name_translation_json,
253
- headers: { 'Accept' => 'application/json',
254
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
255
- 'Content-Type' => 'application/json',
256
- 'User-Agent' => 'Ruby',
257
- 'X-Rosetteapi-Key' => '0123456789',
258
- 'X-Rosetteapi-Binding' => 'ruby',
259
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
260
- .to_return(status: 200, body: '{"test": "name-translation"}', headers: {})
261
- end
262
- it 'test name translation' do
263
- params = NameTranslationParameters.new('معمر محمد أبو منيار القذاف'.encode('UTF-8'), 'eng')
264
- params.target_script = 'Latn'
265
- response = RosetteAPI.new('0123456789').get_name_translation(params)
266
- expect(response).instance_of? Hash
267
- end
268
-
269
- it 'badRequest: Expects NameTranslationParameters type as an argument' do
270
- params = NameSimilarityParameters.new('Michael Jackson', '迈克尔·杰克逊')
271
- expect { RosetteAPI.new('0123456789').get_name_translation(params) }.to raise_error(BadRequestError)
272
- end
273
- end
274
-
275
- describe '.name_similarity' do
276
- before do
277
- name_similarity_json = { name1: 'Michael Jackson', name2: '迈克尔·杰克逊' }.to_json
278
- stub_request(:post, 'https://api.rosette.com/rest/v1/name-similarity')
279
- .with(body: name_similarity_json,
280
- headers: { 'Accept' => 'application/json',
281
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
282
- 'Content-Type' => 'application/json',
283
- 'User-Agent' => 'Ruby',
284
- 'X-Rosetteapi-Key' => '0123456789',
285
- 'X-Rosetteapi-Binding' => 'ruby',
286
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
287
- .to_return(status: 200, body: '{"test": "name-similarity"}', headers: {})
288
- end
289
- it 'test name similarity' do
290
- params = NameSimilarityParameters.new('Michael Jackson', '迈克尔·杰克逊')
291
- response = RosetteAPI.new('0123456789').get_name_similarity(params)
292
- expect(response).instance_of? Hash
293
- end
294
-
295
- it 'badRequestFormat: name1 option can only be an instance of a String or NameParameter' do
296
- params = NameSimilarityParameters.new(123, 'Michael Jackson')
297
- expect { RosetteAPI.new('0123456789').get_name_similarity(params) }.to raise_error(BadRequestError)
298
- end
299
-
300
- it 'badRequestFormat: name2 option can only be an instance of a String or NameParameter' do
301
- params = NameSimilarityParameters.new('Michael Jackson', 123)
302
- expect { RosetteAPI.new('0123456789').get_name_similarity(params) }.to raise_error(BadRequestError)
303
- end
304
-
305
- it 'badRequest: Expects NameSimilarityParameters type as an argument' do
306
- params = NameTranslationParameters.new('معمر محمد أبو منيار القذاف'.encode('UTF-8'), 'eng')
307
- expect { RosetteAPI.new('0123456789').get_name_similarity(params) }.to raise_error(BadRequestError)
308
- end
309
- end
310
-
311
- describe '.name_deduplication' do
312
- names = ['John Smith', 'Johnathon Smith', 'Fred Jones'].map { |n| NameParameter.new(n) }
313
- before do
314
- names_json = { names: names.map(&:load_param), threshold: 0.75 }.to_json
315
-
316
- stub_request(:post, 'https://api.rosette.com/rest/v1/name-deduplication')
317
- .with(body: names_json,
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
- 'X-Rosetteapi-Binding' => 'ruby',
324
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
325
- .to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {})
326
-
327
- nothresh_json = { names: names.map(&:load_param) }.to_json
328
-
329
- stub_request(:post, 'https://api.rosette.com/rest/v1/name-deduplication')
330
- .with(body: nothresh_json,
331
- headers: {'Accept' => 'application/json',
332
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
333
- 'Content-Type' => 'application/json',
334
- 'User-Agent' => 'Ruby',
335
- 'X-Rosetteapi-Key' => '0123456789',
336
- 'X-Rosetteapi-Binding' => 'ruby',
337
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
338
- .to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {})
339
- end
340
- it 'test name deduplication' do
341
- params = NameDeduplicationParameters.new(names, 0.75)
342
- response = RosetteAPI.new('0123456789').get_name_deduplication(params)
343
- expect(response).instance_of? Hash
344
- end
345
-
346
- it 'test null threshold' do
347
- params = NameDeduplicationParameters.new(names, nil)
348
- response = RosetteAPI.new('0123456789').get_name_deduplication(params)
349
- expect(response).instance_of? Hash
350
- end
351
-
352
- it 'badRequestFormat: names must be an array of name_parameter' do
353
- params = NameDeduplicationParameters.new('Michael Jackson', 0.75)
354
- expect { RosetteAPI.new('0123456789').get_name_deduplication(params) }.to raise_error(BadRequestError)
355
- end
356
-
357
- it 'badRequestFormat: threshold must be a float' do
358
- params = NameDeduplicationParameters.new(names, 123)
359
- expect { RosetteAPI.new('0123456789').get_name_deduplication(params) }.to raise_error(BadRequestError)
360
- end
361
-
362
- it 'badRequest: threshold must be in the range of 0 to 1' do
363
- params = NameDeduplicationParameters.new(names, 1.5)
364
- expect { RosetteAPI.new('0123456789').get_name_deduplication(params) }.to raise_error(BadRequestError)
365
- end
366
-
367
- it 'badRequest: rosette_options can only be an instance of a Hash' do
368
- params = NameDeduplicationParameters.new(names, 0.5)
369
- params.rosette_options = 1
370
- expect { RosetteAPI.new('0123456789').get_name_deduplication(params) }.to raise_error(BadRequestError)
371
- end
372
- end
373
-
374
- describe '.transliteration' do
375
- content = 'Kareem Abdul Jabbar holds the record for most points in the NBA'
376
-
377
- before do
378
- transliteration_json = { content: content }.to_json
379
-
380
- stub_request(:post, 'https://api.rosette.com/rest/v1/transliteration')
381
- .with(body: transliteration_json,
382
- headers: {'Accept' => 'application/json',
383
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
384
- 'Content-Type' => 'application/json',
385
- 'User-Agent' => 'Ruby',
386
- 'X-Rosetteapi-Key' => '0123456789',
387
- 'X-Rosetteapi-Binding' => 'ruby',
388
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
389
- .to_return(status: 200, body: '{"test": "transliteration"}', headers: {})
390
- end
391
- it 'test transliteration' do
392
- params = DocumentParameters.new
393
- params.content = content
394
- response = RosetteAPI.new('0123456789').get_transliteration(params)
395
- expect(response).instance_of? Hash
396
- end
397
-
398
- it 'badRequest: content must be provided' do
399
- params = DocumentParameters.new
400
- expect { RosetteAPI.new('0123456789').get_transliteration(params) }.to raise_error(BadRequestFormatError)
401
- end
402
-
403
- it 'badRequest: rosette_options can only be an instance of a Hash' do
404
- params = DocumentParameters.new
405
- params.content = content
406
- params.rosette_options = 1
407
- expect { RosetteAPI.new('0123456789').get_transliteration(params) }.to raise_error(BadRequestError)
408
- end
409
- end
410
-
411
- describe '.get_tokens' do
412
- before do
413
- stub_request(:post, 'https://api.rosette.com/rest/v1/tokens')
414
- .with(body: @json,
415
- headers: { 'Accept' => 'application/json',
416
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
417
- 'Content-Type' => 'application/json',
418
- 'User-Agent' => 'Ruby',
419
- 'X-Rosetteapi-Key' => '0123456789',
420
- 'X-Rosetteapi-Binding' => 'ruby',
421
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
422
- .to_return(status: 200, body: '{"test": "tokens"}', headers: {})
423
- end
424
- it 'test tokens' do
425
- params = DocumentParameters.new
426
- params.content = @content
427
- response = RosetteAPI.new('0123456789').get_tokens(params)
428
- expect(response).instance_of? Hash
429
- end
430
- end
431
-
432
- describe '.get_topics' do
433
- before do
434
- stub_request(:post, 'https://api.rosette.com/rest/v1/topics')
435
- .with(body: @json,
436
- headers: { 'Accept' => 'application/json',
437
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
438
- 'Content-Type' => 'application/json',
439
- 'User-Agent' => 'Ruby',
440
- 'X-Rosetteapi-Key' => '0123456789',
441
- 'X-Rosetteapi-Binding' => 'ruby',
442
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
443
- .to_return(status: 200, body: '{"test": "topics"}', headers: {})
444
- end
445
- it 'test topics' do
446
- params = DocumentParameters.new
447
- params.content = @content
448
- response = RosetteAPI.new('0123456789').get_topics(params)
449
- expect(response).instance_of? Hash
450
- end
451
- end
452
-
453
- describe '.get_sentences' do
454
- before do
455
- stub_request(:post, 'https://api.rosette.com/rest/v1/sentences')
456
- .with(body: @json,
457
- headers: { 'Accept' => 'application/json',
458
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
459
- 'Content-Type' => 'application/json',
460
- 'User-Agent' => 'Ruby',
461
- 'X-Rosetteapi-Key' => '0123456789',
462
- 'X-Rosetteapi-Binding' => 'ruby',
463
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
464
- .to_return(status: 200, body: '{"test": "sentences"}', headers: {})
465
- end
466
- it 'test sentences' do
467
- params = DocumentParameters.new
468
- params.content = @content
469
- response = RosetteAPI.new('0123456789').get_sentences(params)
470
- expect(response).instance_of? Hash
471
- end
472
- end
473
-
474
- describe '.info' do
475
- before do
476
- stub_request(:get, 'https://api.rosette.com/rest/v1/info')
477
- .with(headers: { 'Accept' => '*/*',
478
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
479
- 'User-Agent' => 'Ruby',
480
- 'X-Rosetteapi-Key' => '0123456789' })
481
- .to_return(status: 200, body: '{"test": "info"}', headers: {})
482
- end
483
- it 'test info' do
484
- response = RosetteAPI.new('0123456789').info
485
- expect(response).instance_of? Hash
486
- end
487
- end
488
-
489
- describe '.ping' do
490
- before do
491
- stub_request(:get, 'https://api.rosette.com/rest/v1/ping')
492
- .with(headers: { 'Accept' => '*/*',
493
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
494
- 'User-Agent' => 'Ruby',
495
- 'X-Rosetteapi-Key' => '0123456789' })
496
- .to_return(status: 200, body: '{"test": "ping"}', headers: {})
497
- end
498
- it 'test ping' do
499
- response = RosetteAPI.new('0123456789').ping
500
- expect(response).instance_of? Hash
501
- end
502
- end
503
-
504
- describe '.get_language_custom_header' do
505
- before do
506
- stub_request(:post, 'https://api.rosette.com/rest/v1/language')
507
- .with(body: @json,
508
- headers: { 'Accept' => 'application/json',
509
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
510
- 'Content-Type' => 'application/json',
511
- 'User-Agent' => 'Ruby',
512
- 'X-Rosetteapi-Key' => '0123456789',
513
- 'X-Rosetteapi-Binding' => 'ruby',
514
- 'X-Rosetteapi-Binding-Version' => '1.8.0',
515
- 'X-RosetteApi-App' => 'ruby-app' })
516
- .to_return(status: 200, body: '{"test": "language"}', headers: {})
517
- end
518
-
519
- it 'test custom_headers is invalid' do
520
- params = DocumentParameters.new
521
- params.content = 'Por favor Senorita, says the man.?'
522
- params.custom_headers = {'test' => 'ruby-app'}
523
- expect { RosetteAPI.new('0123456789').get_language(params) }.to raise_error(RosetteAPIError)
524
- end
525
- end
526
-
527
- describe '.error_409_incompatible_client_version' do
528
- before do
529
- stub_request(:get, 'https://api.rosette.com/rest/v1/info')
530
- .with(headers: { 'Accept' => '*/*',
531
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
532
- 'User-Agent' => 'Ruby',
533
- 'X-Rosetteapi-Key' => '0123456789' })
534
- .to_return(status: 409, body: '{"code": "incompatibleClientVersion"}', headers: {})
535
- end
536
- it 'test error 409 properly handled' do
537
- expect { RosetteAPI.new('0123456789').info }.to raise_error(RosetteAPIError)
538
- end
539
- end
540
-
541
- describe '.get_text_embedding' do
542
- before do
543
- stub_request(:post, 'https://api.rosette.com/rest/v1/text-embedding')
544
- .with(body: @json,
545
- headers: { 'Accept' => 'application/json',
546
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
547
- 'Content-Type' => 'application/json',
548
- 'User-Agent' => 'Ruby',
549
- 'X-Rosetteapi-Key' => '0123456789',
550
- 'X-Rosetteapi-Binding' => 'ruby',
551
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
552
- .to_return(status: 200, body: '{"test": "language"}', headers: {})
553
- end
554
- it 'test text_embedding' do
555
- params = DocumentParameters.new
556
- params.content = @content
557
- response = RosetteAPI.new('0123456789').get_text_embedding(params)
558
- expect(response).instance_of? Hash
559
- end
560
- end
561
-
562
- describe '.get_syntax_dependencies' do
563
- before do
564
- stub_request(:post, 'https://api.rosette.com/rest/v1/syntax/dependencies')
565
- .with(body: @json,
566
- headers: { 'Accept' => 'application/json',
567
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
568
- 'Content-Type' => 'application/json',
569
- 'User-Agent' => 'Ruby',
570
- 'X-Rosetteapi-Key' => '0123456789',
571
- 'X-Rosetteapi-Binding' => 'ruby',
572
- 'X-Rosetteapi-Binding-Version' => '1.8.0' })
573
- .to_return(status: 200, body: '{"test": "language"}', headers: {})
574
- end
575
- it 'test syntax_dependencies' do
576
- params = DocumentParameters.new
577
- params.content = @content
578
- response = RosetteAPI.new('0123456789').get_syntax_dependencies(params)
579
- expect(response).instance_of? Hash
580
- end
581
- end
582
-
583
- end