rosette_api 1.27.1 → 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 +22 -14
- data/examples/README.md +2 -2
- data/examples/address_similarity.rb +7 -6
- data/examples/categories.rb +7 -6
- data/examples/entities.rb +7 -6
- 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 +1 -1
- data/lib/address_similarity_parameters.rb +11 -3
- data/lib/bad_request_error.rb +1 -1
- data/lib/bad_request_format_error.rb +1 -1
- data/lib/document_parameters.rb +4 -5
- data/lib/name_deduplication_parameters.rb +2 -2
- data/lib/name_parameter.rb +20 -2
- data/lib/name_similarity_parameters.rb +49 -16
- data/lib/name_translation_parameters.rb +14 -4
- data/lib/record_similarity_parameters.rb +68 -0
- data/lib/request_builder.rb +89 -49
- data/lib/rosette_api.rb +78 -42
- data/lib/rosette_api_error.rb +3 -3
- metadata +25 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 648715b05a66f8b54708e36ae3a6548d8a07c0e06f5c225060a1a7c02fea6208
|
|
4
|
+
data.tar.gz: 15a9eb85d4df30ee6b6de01fb2f0b4ca48863b3da492c95793784b46a514c58d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9f43d9d0333720b3ad08e7460ea92fbeffbd22b3e4f445b21b51f50a74b14ee3b5eb7677a0af8a444f0aa3f718d0e7ca8ad59ff3f3187ae665b2f81f0a83adf
|
|
7
|
+
data.tar.gz: 5b404dd299bc6e06964d19cbe51c71b3f1efa266d631ac462d31be85f058dfbdba130964092572df5596988b97367f605377f0ab31a17da689ead9ba04e34fe0
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
<a href="https://www.babelstreet.com/
|
|
1
|
+
<a href="https://www.babelstreet.com/modules">
|
|
2
|
+
<img src="https://charts.babelstreet.com/icon.png" width="48" height="48" alt="Babel Street Logo"/>
|
|
3
|
+
</a>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Analytics by Babel Street
|
|
4
6
|
|
|
5
7
|
[](https://badge.fury.io/rb/rosette_api)
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
comparing the similarity of names, categorizing and adding linguistic tags to text and more.
|
|
9
|
+
Our product is a full text processing pipeline from data preparation to extracting the most relevant information and
|
|
10
|
+
analysis utilizing precise, focused AI that has built-in human understanding. Text Analytics provides foundational
|
|
11
|
+
linguistic analysis for identifying languages and relating words. The result is enriched and normalized text for
|
|
12
|
+
high-speed search and processing without translation.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
Text Analytics extracts events and entities — people, organizations, and places — from unstructured text and adds the
|
|
15
|
+
structure of associating those entities into events that deliver only the necessary information for near real-time
|
|
16
|
+
decision making. Accompanying tools shorten the process of training AI models to recognize domain-specific events.
|
|
17
|
+
|
|
18
|
+
The product delivers a multitude of ways to sharpen and expand search results. Semantic similarity expands search
|
|
19
|
+
beyond keywords to words with the same meaning, even in other languages. Sentiment analysis and topic extraction help
|
|
20
|
+
filter results to what’s relevant.
|
|
21
|
+
|
|
22
|
+
## Analytics API Access
|
|
23
|
+
- Analytics Cloud [Sign Up](https://developer.babelstreet.com/signup)
|
|
15
24
|
|
|
16
25
|
## Quick Start
|
|
17
26
|
|
|
@@ -20,16 +29,15 @@ comparing the similarity of names, categorizing and adding linguistic tags to te
|
|
|
20
29
|
`gem install rosette_api`
|
|
21
30
|
|
|
22
31
|
#### Examples
|
|
23
|
-
View small example programs for each
|
|
32
|
+
View small example programs for each Analytics endpoint
|
|
24
33
|
in the [examples](https://github.com/rosette-api/ruby/tree/develop/examples) directory.
|
|
25
34
|
|
|
26
35
|
#### Documentation & Support
|
|
27
36
|
- [Binding API](https://rosette-api.github.io/ruby/)
|
|
28
|
-
- [
|
|
37
|
+
- [Analytics Platform API](https://documentation.babelstreet.com/analytics)
|
|
29
38
|
- [Binding Release Notes](https://github.com/rosette-api/ruby/wiki/Release-Notes)
|
|
30
|
-
- [
|
|
31
|
-
- [
|
|
32
|
-
- [Support](https://support.rosette.com)
|
|
39
|
+
- [Analytics Platform Release Notes](https://docs.babelstreet.com/r/Hosted-Services-Release-Notes)
|
|
40
|
+
- [Support](https://babelstreet.my.site.com/support/s/contactsupport)
|
|
33
41
|
- [Binding License: Apache 2.0](https://github.com/rosette-api/ruby/blob/develop/LICENSE)
|
|
34
42
|
|
|
35
43
|
## Binding Developer Information
|
data/examples/README.md
CHANGED
|
@@ -13,7 +13,7 @@ A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolcha
|
|
|
13
13
|
```
|
|
14
14
|
git clone git@github.com:rosette-api/ruby.git
|
|
15
15
|
cd ruby
|
|
16
|
-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.
|
|
16
|
+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
|
|
17
17
|
|
|
18
18
|
gem install rosette_api
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@ ruby ping.rb $API_KEY
|
|
|
25
25
|
```
|
|
26
26
|
git clone git@github.com:rosette-api/ruby.git
|
|
27
27
|
cd ruby
|
|
28
|
-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.
|
|
28
|
+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
|
|
29
29
|
|
|
30
30
|
cd /source
|
|
31
31
|
gem build rosette_api.gemspec
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
begin
|
|
14
15
|
address1 = AddressParameter.new(
|
|
@@ -20,7 +21,7 @@ begin
|
|
|
20
21
|
)
|
|
21
22
|
address2 = '160 Pennsilvana Avenue, Washington, D.C., 20500'
|
|
22
23
|
params = AddressSimilarityParameters.new(address1, address2)
|
|
23
|
-
response =
|
|
24
|
+
response = analytics_api.get_address_similarity(params)
|
|
24
25
|
puts JSON.pretty_generate(response)
|
|
25
26
|
rescue RosetteAPIError => e
|
|
26
27
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
data/examples/categories.rb
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
categories_text_data = 'If you are a fan of the British television series Downton Abbey and you are planning to be in New York anytime before April 2nd, there is a perfect stop for you while in town.'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: categories_text_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_categories(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
data/examples/entities.rb
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
entities_text_data = 'The Securities and Exchange Commission today announced the leadership of the agency\'s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency\'s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency\'s Washington D.C. headquarters as well as coordinating with litigators in the SEC\'s 11 regional offices around the country.'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: entities_text_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_entities(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
data/examples/events.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'rosette_api'
|
|
5
|
+
|
|
6
|
+
api_key, url = ARGV
|
|
7
|
+
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
events_text_data = 'Bill Gates went to the store.'
|
|
15
|
+
begin
|
|
16
|
+
params = DocumentParameters.new(content: events_text_data)
|
|
17
|
+
response = analytics_api.get_events(params)
|
|
18
|
+
puts JSON.pretty_generate(response)
|
|
19
|
+
rescue RosetteAPIError => e
|
|
20
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
21
|
+
status_code: e.status_code,
|
|
22
|
+
message: e.message)
|
|
23
|
+
end
|
data/examples/info.rb
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
|
-
response =
|
|
14
|
+
response = analytics_api.info
|
|
14
15
|
begin
|
|
15
16
|
puts JSON.pretty_generate(response)
|
|
16
17
|
rescue RosetteAPIError => e
|
data/examples/language.rb
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
language_data = 'Por favor Señorita, says the man.'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: language_data)
|
|
16
17
|
params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' }
|
|
17
|
-
response =
|
|
18
|
+
response = analytics_api.get_language(params)
|
|
18
19
|
puts JSON.pretty_generate(response)
|
|
19
20
|
rescue RosetteAPIError => e
|
|
20
21
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
language_multilingual_data = 'On Thursday, as protesters gathered in Washington D.C., the United States Federal Communications Commission under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly called Net Neutrality, that forbade Internet service providers (ISPs) such as Verizon, Comcast, and AT&T from blocking individual websites or charging websites or customers more for faster load times. Quatre femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.'
|
|
14
15
|
|
|
@@ -16,7 +17,7 @@ begin
|
|
|
16
17
|
params = DocumentParameters.new(content: language_multilingual_data)
|
|
17
18
|
params.rosette_options = { 'multilingual' => 'true' }
|
|
18
19
|
params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' }
|
|
19
|
-
response =
|
|
20
|
+
response = analytics_api.get_language(params)
|
|
20
21
|
puts JSON.pretty_generate(response)
|
|
21
22
|
rescue RosetteAPIError => e
|
|
22
23
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
morphology_complete_data = 'The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: morphology_complete_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_morphology_complete(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
morphology_compound_components_data = 'Rechtsschutzversicherungsgesellschaften'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(
|
|
16
17
|
content: morphology_compound_components_data
|
|
17
18
|
)
|
|
18
|
-
response =
|
|
19
|
+
response = analytics_api.get_compound_components(params)
|
|
19
20
|
puts JSON.pretty_generate(response)
|
|
20
21
|
rescue RosetteAPIError => e
|
|
21
22
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
morphology_han_readings_data = '北京大学生物系主任办公室内部会议'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: morphology_han_readings_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_han_readings(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
morphology_lemmas_data = 'The fact is that the geese just went back to get a rest and I\'m not banking on their return soon'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: morphology_lemmas_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_lemmas(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
morphology_parts_of_speech_data = 'The fact is that the geese just went back to get a rest and I\'m not banking on their return soon'
|
|
14
15
|
begin
|
|
15
16
|
params = DocumentParameters.new(content: morphology_parts_of_speech_data)
|
|
16
|
-
response =
|
|
17
|
+
response = analytics_api.get_parts_of_speech(params)
|
|
17
18
|
puts JSON.pretty_generate(response)
|
|
18
19
|
rescue RosetteAPIError => e
|
|
19
20
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'rosette_api'
|
|
6
|
+
|
|
7
|
+
api_key, url = ARGV
|
|
8
|
+
|
|
9
|
+
analytics_api = if url
|
|
10
|
+
RosetteAPI.new(api_key, url)
|
|
11
|
+
else
|
|
12
|
+
RosetteAPI.new(api_key)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
begin
|
|
16
|
+
# Create a sample file to upload (so the example is runnable as-is).
|
|
17
|
+
file_path = File.expand_path('sample.txt', __dir__)
|
|
18
|
+
File.write(file_path, "Bonjour tout le monde.\n")
|
|
19
|
+
|
|
20
|
+
params = DocumentParameters.new(file_path: file_path)
|
|
21
|
+
response = analytics_api.get_language(params)
|
|
22
|
+
puts JSON.pretty_generate(response)
|
|
23
|
+
rescue RosetteAPIError => e
|
|
24
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
25
|
+
status_code: e.status_code,
|
|
26
|
+
message: e.message)
|
|
27
|
+
ensure
|
|
28
|
+
FileUtils.rm_f(file_path)
|
|
29
|
+
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
name_dedupe_data = 'Alice Terry,Alice Thierry,Betty Grable,Betty Gable,Norma Shearer,Norm Shearer,Brigitte Helm,Bridget Helem,Judy Holliday,Julie Halliday'
|
|
14
15
|
|
|
@@ -16,7 +17,7 @@ threshold = 0.75
|
|
|
16
17
|
names = name_dedupe_data.split(',').map { |n| NameParameter.new(n) }
|
|
17
18
|
begin
|
|
18
19
|
params = NameDeduplicationParameters.new(names, threshold)
|
|
19
|
-
response =
|
|
20
|
+
response = analytics_api.get_name_deduplication(params)
|
|
20
21
|
puts JSON.pretty_generate(response)
|
|
21
22
|
rescue RosetteAPIError => e
|
|
22
23
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
data/examples/name_similarity.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
matched_name_data1 = 'Michael Jackson'
|
|
14
15
|
matched_name_data2 = '迈克尔·杰克逊'
|
|
@@ -18,8 +19,9 @@ begin
|
|
|
18
19
|
entity_type: 'PERSON',
|
|
19
20
|
language: 'eng'
|
|
20
21
|
)
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
match_parameters = { conflictScore: '0.35' }
|
|
23
|
+
params = NameSimilarityParameters.new(name1, matched_name_data2, match_parameters)
|
|
24
|
+
response = analytics_api.get_name_similarity(params)
|
|
23
25
|
puts JSON.pretty_generate(response)
|
|
24
26
|
rescue RosetteAPIError => e
|
|
25
27
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
translated_name_data = 'معمر محمد أبو منيار القذاف'
|
|
14
15
|
begin
|
|
@@ -17,7 +18,7 @@ begin
|
|
|
17
18
|
'eng',
|
|
18
19
|
target_script: 'Latn'
|
|
19
20
|
)
|
|
20
|
-
response =
|
|
21
|
+
response = analytics_api.get_name_translation(params)
|
|
21
22
|
puts JSON.pretty_generate(response)
|
|
22
23
|
rescue RosetteAPIError => e
|
|
23
24
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|
data/examples/ping.rb
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
3
4
|
require 'rosette_api'
|
|
4
5
|
|
|
5
6
|
api_key, url = ARGV
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
analytics_api = if url
|
|
9
|
+
RosetteAPI.new(api_key, url)
|
|
10
|
+
else
|
|
11
|
+
RosetteAPI.new(api_key)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
begin
|
|
14
|
-
response =
|
|
15
|
+
response = analytics_api.ping
|
|
15
16
|
puts JSON.pretty_generate(response)
|
|
16
17
|
rescue RosetteAPIError => e
|
|
17
18
|
printf('Rosette API Error (%<status_code>s): %<message>s',
|