rosette_api 1.14.4 → 1.37.0
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +23 -16
- data/examples/README.md +2 -2
- data/examples/address_similarity.rb +7 -6
- data/examples/categories.rb +9 -8
- data/examples/entities.rb +8 -8
- data/examples/events.rb +23 -0
- data/examples/info.rb +7 -6
- data/examples/language.rb +7 -6
- data/examples/language_multilingual.rb +7 -6
- data/examples/morphology_complete.rb +7 -6
- data/examples/morphology_compound-components.rb +7 -6
- data/examples/morphology_han-readings.rb +7 -6
- data/examples/morphology_lemmas.rb +7 -6
- data/examples/morphology_parts-of-speech.rb +7 -6
- data/examples/multipart_language_file.rb +29 -0
- data/examples/name_deduplication.rb +7 -6
- data/examples/name_similarity.rb +9 -7
- data/examples/name_translation.rb +7 -6
- data/examples/ping.rb +7 -6
- data/examples/record_similarity.rb +114 -0
- data/examples/relationships.rb +7 -6
- data/examples/semantic_vectors.rb +7 -6
- data/examples/sentences.rb +7 -6
- data/examples/sentiment.rb +8 -7
- data/examples/similar_terms.rb +7 -6
- data/examples/syntax_dependencies.rb +7 -6
- data/examples/tokens.rb +7 -6
- data/examples/topics.rb +7 -6
- data/examples/transliteration.rb +7 -6
- data/lib/address_parameter.rb +3 -4
- data/lib/address_similarity_parameters.rb +13 -6
- data/lib/bad_request_error.rb +3 -3
- data/lib/bad_request_format_error.rb +3 -3
- data/lib/document_parameters.rb +10 -12
- data/lib/name_deduplication_parameters.rb +5 -8
- data/lib/name_parameter.rb +22 -5
- data/lib/name_similarity_parameters.rb +51 -21
- data/lib/name_translation_parameters.rb +17 -10
- data/lib/record_similarity_parameters.rb +68 -0
- data/lib/request_builder.rb +94 -54
- data/lib/rosette_api.rb +90 -50
- data/lib/rosette_api_error.rb +5 -4
- metadata +28 -33
data/lib/rosette_api.rb
CHANGED
|
@@ -5,73 +5,76 @@ require_relative 'document_parameters'
|
|
|
5
5
|
require_relative 'name_deduplication_parameters'
|
|
6
6
|
require_relative 'name_translation_parameters'
|
|
7
7
|
require_relative 'name_similarity_parameters'
|
|
8
|
+
require_relative 'record_similarity_parameters'
|
|
8
9
|
require_relative 'address_similarity_parameters'
|
|
9
10
|
require_relative 'rosette_api_error'
|
|
10
11
|
require_relative 'bad_request_error'
|
|
11
12
|
require_relative 'bad_request_format_error'
|
|
13
|
+
require 'logger'
|
|
12
14
|
|
|
13
|
-
# This class allows you to access all
|
|
15
|
+
# This class allows you to access all Analytics API endpoints.
|
|
14
16
|
class RosetteAPI
|
|
15
17
|
# Version of Ruby binding
|
|
16
|
-
BINDING_VERSION = '1.
|
|
17
|
-
#
|
|
18
|
+
BINDING_VERSION = '1.37.0'
|
|
19
|
+
# API address-similarity endpoint
|
|
20
|
+
ADDRESS_SIMILARITY_ENDPOINT = '/address-similarity'
|
|
21
|
+
# API categories endpoint
|
|
22
|
+
CATEGORIES_ENDPOINT = '/categories'
|
|
23
|
+
# API entities endpoint
|
|
24
|
+
ENTITIES_ENDPOINT = '/entities'
|
|
25
|
+
# API events endpoint
|
|
26
|
+
EVENTS_ENDPOINT = '/events'
|
|
27
|
+
# API info endpoint
|
|
28
|
+
INFO = '/info'
|
|
29
|
+
# API language endpoint
|
|
18
30
|
LANGUAGE_ENDPOINT = '/language'
|
|
19
|
-
#
|
|
31
|
+
# API morphology endpoint
|
|
20
32
|
MORPHOLOGY_ENDPOINT = '/morphology'
|
|
21
|
-
# Rosette API entities endpoint
|
|
22
|
-
ENTITIES_ENDPOINT = '/entities'
|
|
23
|
-
# Rosette API categories endpoint
|
|
24
|
-
CATEGORIES_ENDPOINT = '/categories'
|
|
25
|
-
# Rosette API relationships endpoint
|
|
26
|
-
RELATIONSHIPS_ENDPOINT = '/relationships'
|
|
27
|
-
# Rosette API sentiment endpoint
|
|
28
|
-
SENTIMENT_ENDPOINT = '/sentiment'
|
|
29
33
|
# Name Deduplication endpoint
|
|
30
34
|
NAME_DEDUPLICATION_ENDPOINT = '/name-deduplication'
|
|
31
|
-
#
|
|
32
|
-
NAME_TRANSLATION_ENDPOINT = '/name-translation'
|
|
33
|
-
# Rosette API name-similarity endpoint
|
|
35
|
+
# API name-similarity endpoint
|
|
34
36
|
NAME_SIMILARITY_ENDPOINT = '/name-similarity'
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
TOKENS_ENDPOINT = '/tokens'
|
|
39
|
-
# Rosette API sentences endpoint
|
|
40
|
-
SENTENCES_ENDPOINT = '/sentences'
|
|
41
|
-
# Rosette API info endpoint
|
|
42
|
-
INFO = '/info'
|
|
43
|
-
# Rosette API ping endpoint
|
|
37
|
+
# API name-translation endpoint
|
|
38
|
+
NAME_TRANSLATION_ENDPOINT = '/name-translation'
|
|
39
|
+
# API ping endpoint
|
|
44
40
|
PING = '/ping'
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
#
|
|
41
|
+
# Record Similarity endpoint
|
|
42
|
+
RECORD_SIMILARITY_ENDPOINT = '/record-similarity'
|
|
43
|
+
# API relationships endpoint
|
|
44
|
+
RELATIONSHIPS_ENDPOINT = '/relationships'
|
|
45
|
+
# Semantic Vectors endpoint (replaces deprecated /text-embedding)
|
|
48
46
|
SEMANTIC_VECTORS = '/semantics/vector'
|
|
47
|
+
# API sentences endpoint
|
|
48
|
+
SENTENCES_ENDPOINT = '/sentences'
|
|
49
|
+
# API sentiment endpoint
|
|
50
|
+
SENTIMENT_ENDPOINT = '/sentiment'
|
|
49
51
|
# Similar Terms endpoint
|
|
50
52
|
SIMILAR_TERMS_ENDPOINT = '/semantics/similar'
|
|
51
53
|
# Syntactic Dependencies endpoint
|
|
52
54
|
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
+
# API tokens endpoint
|
|
56
|
+
TOKENS_ENDPOINT = '/tokens'
|
|
55
57
|
# Topics endpoint
|
|
56
58
|
TOPICS_ENDPOINT = '/topics'
|
|
59
|
+
# Transliteration endpoint
|
|
60
|
+
TRANSLITERATION_ENDPOINT = '/transliteration'
|
|
57
61
|
|
|
58
|
-
#
|
|
62
|
+
# API key
|
|
59
63
|
attr_accessor :user_key
|
|
60
|
-
# Alternate
|
|
64
|
+
# Alternate API URL
|
|
61
65
|
attr_accessor :alternate_url
|
|
62
|
-
# custom
|
|
66
|
+
# custom API headers
|
|
63
67
|
attr_accessor :custom_headers
|
|
64
68
|
# URL query parameter(s)
|
|
65
69
|
attr_accessor :url_parameters
|
|
66
70
|
|
|
67
|
-
def initialize(user_key, alternate_url = 'https://
|
|
71
|
+
def initialize(user_key, alternate_url = 'https://analytics.babelstreet.com/rest/v1')
|
|
72
|
+
@log = Logger.new($stdout)
|
|
68
73
|
@user_key = user_key
|
|
69
74
|
@alternate_url = alternate_url
|
|
70
75
|
@url_parameters = nil
|
|
71
76
|
|
|
72
|
-
if @alternate_url.to_s.end_with?('/')
|
|
73
|
-
@alternate_url = alternate_url.to_s.slice(0..-2)
|
|
74
|
-
end
|
|
77
|
+
@alternate_url = alternate_url.to_s.slice(0..-2) if @alternate_url.to_s.end_with?('/')
|
|
75
78
|
|
|
76
79
|
uri = URI.parse alternate_url
|
|
77
80
|
@http_client = Net::HTTP.new uri.host, uri.port
|
|
@@ -111,7 +114,7 @@ class RosetteAPI
|
|
|
111
114
|
|
|
112
115
|
params = params.load_params
|
|
113
116
|
|
|
114
|
-
endpoint = MORPHOLOGY_ENDPOINT
|
|
117
|
+
endpoint = "#{MORPHOLOGY_ENDPOINT}/complete"
|
|
115
118
|
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client,
|
|
116
119
|
BINDING_VERSION, params, @url_parameters)
|
|
117
120
|
.send_post_request
|
|
@@ -131,7 +134,7 @@ class RosetteAPI
|
|
|
131
134
|
|
|
132
135
|
params = params.load_params
|
|
133
136
|
|
|
134
|
-
endpoint = MORPHOLOGY_ENDPOINT
|
|
137
|
+
endpoint = "#{MORPHOLOGY_ENDPOINT}/compound-components"
|
|
135
138
|
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client,
|
|
136
139
|
BINDING_VERSION, params, @url_parameters)
|
|
137
140
|
.send_post_request
|
|
@@ -151,7 +154,7 @@ class RosetteAPI
|
|
|
151
154
|
|
|
152
155
|
params = params.load_params
|
|
153
156
|
|
|
154
|
-
endpoint = MORPHOLOGY_ENDPOINT
|
|
157
|
+
endpoint = "#{MORPHOLOGY_ENDPOINT}/han-readings"
|
|
155
158
|
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client,
|
|
156
159
|
BINDING_VERSION, params, @url_parameters)
|
|
157
160
|
.send_post_request
|
|
@@ -170,7 +173,7 @@ class RosetteAPI
|
|
|
170
173
|
|
|
171
174
|
params = params.load_params
|
|
172
175
|
|
|
173
|
-
endpoint = MORPHOLOGY_ENDPOINT
|
|
176
|
+
endpoint = "#{MORPHOLOGY_ENDPOINT}/lemmas"
|
|
174
177
|
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client,
|
|
175
178
|
BINDING_VERSION, params, @url_parameters)
|
|
176
179
|
.send_post_request
|
|
@@ -190,7 +193,7 @@ class RosetteAPI
|
|
|
190
193
|
|
|
191
194
|
params = params.load_params
|
|
192
195
|
|
|
193
|
-
endpoint = MORPHOLOGY_ENDPOINT
|
|
196
|
+
endpoint = "#{MORPHOLOGY_ENDPOINT}/parts-of-speech"
|
|
194
197
|
RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client,
|
|
195
198
|
BINDING_VERSION, params, @url_parameters)
|
|
196
199
|
.send_post_request
|
|
@@ -350,6 +353,26 @@ class RosetteAPI
|
|
|
350
353
|
.send_post_request
|
|
351
354
|
end
|
|
352
355
|
|
|
356
|
+
# Compares records and returns similarity information.
|
|
357
|
+
#
|
|
358
|
+
# ==== Attributes
|
|
359
|
+
#
|
|
360
|
+
# * +params+ - RecordSimilarityParameters helps to build the request body in
|
|
361
|
+
# RequestBuilder.
|
|
362
|
+
#
|
|
363
|
+
# Returns record similarity results.
|
|
364
|
+
def get_record_similarity(params)
|
|
365
|
+
check_params params,
|
|
366
|
+
'Expects a RecordSimilarityParameters type as an argument',
|
|
367
|
+
RecordSimilarityParameters
|
|
368
|
+
|
|
369
|
+
params = params.load_params
|
|
370
|
+
|
|
371
|
+
RequestBuilder.new(@user_key, @alternate_url + RECORD_SIMILARITY_ENDPOINT,
|
|
372
|
+
@http_client, BINDING_VERSION, params, @url_parameters)
|
|
373
|
+
.send_post_request
|
|
374
|
+
end
|
|
375
|
+
|
|
353
376
|
# Divides the input into tokens.
|
|
354
377
|
#
|
|
355
378
|
# ==== Attributes
|
|
@@ -398,13 +421,8 @@ class RosetteAPI
|
|
|
398
421
|
#
|
|
399
422
|
# Returns the text embedding representation of the input.
|
|
400
423
|
def get_text_embedding(params)
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
params = params.load_params
|
|
404
|
-
|
|
405
|
-
RequestBuilder.new(@user_key, @alternate_url + TEXT_EMBEDDING, @http_client,
|
|
406
|
-
BINDING_VERSION, params, @url_parameters)
|
|
407
|
-
.send_post_request
|
|
424
|
+
@log.warn('get_text_embedding is deprecated. Please use get_semantic_vectors instead.')
|
|
425
|
+
get_semantic_vectors(params)
|
|
408
426
|
end
|
|
409
427
|
|
|
410
428
|
#
|
|
@@ -501,7 +519,25 @@ class RosetteAPI
|
|
|
501
519
|
.send_post_request
|
|
502
520
|
end
|
|
503
521
|
|
|
504
|
-
#
|
|
522
|
+
# Returns the events of the input
|
|
523
|
+
#
|
|
524
|
+
# ==== Attributes
|
|
525
|
+
#
|
|
526
|
+
# * +params+ - DocumentParameters helps to build the request body in
|
|
527
|
+
# RequestBuilder.
|
|
528
|
+
#
|
|
529
|
+
# Returns the events of the input
|
|
530
|
+
def get_events(params)
|
|
531
|
+
check_params params
|
|
532
|
+
|
|
533
|
+
params = params.load_params
|
|
534
|
+
|
|
535
|
+
RequestBuilder.new(@user_key, @alternate_url + EVENTS_ENDPOINT,
|
|
536
|
+
@http_client, BINDING_VERSION, params, @url_parameters)
|
|
537
|
+
.send_post_request
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
# Gets information about the API, returns name, build number
|
|
505
541
|
# and build time.
|
|
506
542
|
def info
|
|
507
543
|
RequestBuilder.new(@user_key, @alternate_url + INFO, @http_client,
|
|
@@ -509,7 +545,7 @@ class RosetteAPI
|
|
|
509
545
|
.send_get_request
|
|
510
546
|
end
|
|
511
547
|
|
|
512
|
-
# Pings the
|
|
548
|
+
# Pings the API for a response indicting that the service is
|
|
513
549
|
# available.
|
|
514
550
|
def ping
|
|
515
551
|
RequestBuilder.new(@user_key, @alternate_url + PING, @http_client,
|
|
@@ -530,5 +566,9 @@ class RosetteAPI
|
|
|
530
566
|
message = 'Expects a DocumentParameters type as an argument',
|
|
531
567
|
type = DocumentParameters)
|
|
532
568
|
raise BadRequestError.new message unless params.is_a? type
|
|
569
|
+
|
|
570
|
+
return unless defined?(params.genre) && !params.genre.nil?
|
|
571
|
+
|
|
572
|
+
@log.warn('The genre parameter is deprecated and will be removed in a future release.')
|
|
533
573
|
end
|
|
534
574
|
end
|
data/lib/rosette_api_error.rb
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# This class encapsulates all
|
|
3
|
+
# This class encapsulates all API server errors encountered during
|
|
4
4
|
# requests.
|
|
5
5
|
class RosetteAPIError < StandardError
|
|
6
|
-
#
|
|
6
|
+
# API error's status code
|
|
7
7
|
attr_accessor :status_code
|
|
8
|
-
#
|
|
8
|
+
# API error's message
|
|
9
9
|
attr_accessor :message
|
|
10
10
|
|
|
11
|
-
def initialize(status_code, message)
|
|
11
|
+
def initialize(status_code, message) # :notnew:
|
|
12
12
|
@status_code = status_code
|
|
13
13
|
@message = message
|
|
14
|
+
super(message)
|
|
14
15
|
end
|
|
15
16
|
end
|
metadata
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rosette_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.37.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Analytics by Babel Street
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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.
|
|
33
|
-
email: support@rosette.com
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Our product is a full text processing pipeline from data preparation
|
|
13
|
+
to extracting the most relevant information andanalysis utilizing precise, focused
|
|
14
|
+
AI that has built-in human understanding. Text Analytics provides foundationallinguistic
|
|
15
|
+
analysis for identifying languages and relating words. The result is enriched and
|
|
16
|
+
normalized text forhigh-speed search and processing without translation.Text Analytics
|
|
17
|
+
extracts events and entities — people, organizations, and places — from unstructured
|
|
18
|
+
text and adds thestructure of associating those entities into events that deliver
|
|
19
|
+
only the necessary information for near real-timedecision making. Accompanying tools
|
|
20
|
+
shorten the process of training AI models to recognize domain-specific events.The
|
|
21
|
+
product delivers a multitude of ways to sharpen and expand search results. Semantic
|
|
22
|
+
similarity expands searchbeyond keywords to words with the same meaning, even in
|
|
23
|
+
other languages. Sentiment analysis and topic extraction helpfilter results to what’s
|
|
24
|
+
relevant.
|
|
25
|
+
email: analyticssupport@babelstreet.com
|
|
34
26
|
executables: []
|
|
35
27
|
extensions: []
|
|
36
28
|
extra_rdoc_files: []
|
|
@@ -41,6 +33,7 @@ files:
|
|
|
41
33
|
- examples/address_similarity.rb
|
|
42
34
|
- examples/categories.rb
|
|
43
35
|
- examples/entities.rb
|
|
36
|
+
- examples/events.rb
|
|
44
37
|
- examples/info.rb
|
|
45
38
|
- examples/language.rb
|
|
46
39
|
- examples/language_multilingual.rb
|
|
@@ -49,10 +42,12 @@ files:
|
|
|
49
42
|
- examples/morphology_han-readings.rb
|
|
50
43
|
- examples/morphology_lemmas.rb
|
|
51
44
|
- examples/morphology_parts-of-speech.rb
|
|
45
|
+
- examples/multipart_language_file.rb
|
|
52
46
|
- examples/name_deduplication.rb
|
|
53
47
|
- examples/name_similarity.rb
|
|
54
48
|
- examples/name_translation.rb
|
|
55
49
|
- examples/ping.rb
|
|
50
|
+
- examples/record_similarity.rb
|
|
56
51
|
- examples/relationships.rb
|
|
57
52
|
- examples/semantic_vectors.rb
|
|
58
53
|
- examples/sentences.rb
|
|
@@ -71,14 +66,15 @@ files:
|
|
|
71
66
|
- lib/name_parameter.rb
|
|
72
67
|
- lib/name_similarity_parameters.rb
|
|
73
68
|
- lib/name_translation_parameters.rb
|
|
69
|
+
- lib/record_similarity_parameters.rb
|
|
74
70
|
- lib/request_builder.rb
|
|
75
71
|
- lib/rosette_api.rb
|
|
76
72
|
- lib/rosette_api_error.rb
|
|
77
|
-
homepage: https://developer.
|
|
73
|
+
homepage: https://developer.babelstreet.com/
|
|
78
74
|
licenses:
|
|
79
75
|
- Apache-2.0
|
|
80
|
-
metadata:
|
|
81
|
-
|
|
76
|
+
metadata:
|
|
77
|
+
rubygems_mfa_required: 'true'
|
|
82
78
|
rdoc_options: []
|
|
83
79
|
require_paths:
|
|
84
80
|
- lib
|
|
@@ -86,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
86
82
|
requirements:
|
|
87
83
|
- - ">="
|
|
88
84
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
85
|
+
version: 3.0.0
|
|
90
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
87
|
requirements:
|
|
92
88
|
- - ">="
|
|
93
89
|
- !ruby/object:Gem::Version
|
|
94
90
|
version: '0'
|
|
95
91
|
requirements: []
|
|
96
|
-
rubygems_version:
|
|
97
|
-
signing_key:
|
|
92
|
+
rubygems_version: 4.0.6
|
|
98
93
|
specification_version: 4
|
|
99
|
-
summary: A Ruby interface for
|
|
94
|
+
summary: A Ruby interface for Babel Street Analytics Server and Hosted Services
|
|
100
95
|
test_files: []
|