rosette_api 1.8.0 → 1.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +13 -0
- data/README.md +38 -0
- data/examples/README.md +36 -0
- data/examples/address_similarity.rb +29 -0
- data/examples/categories.rb +22 -0
- data/examples/entities.rb +23 -0
- data/examples/info.rb +20 -0
- data/examples/language.rb +23 -0
- data/examples/language_multilingual.rb +25 -0
- data/examples/morphology_complete.rb +22 -0
- data/examples/morphology_compound-components.rb +24 -0
- data/examples/morphology_han-readings.rb +22 -0
- data/examples/morphology_lemmas.rb +22 -0
- data/examples/morphology_parts-of-speech.rb +22 -0
- data/examples/name_deduplication.rb +25 -0
- data/examples/name_similarity.rb +28 -0
- data/examples/name_translation.rb +26 -0
- data/examples/ping.rb +20 -0
- data/examples/relationships.rb +23 -0
- data/examples/semantic_vectors.rb +22 -0
- data/examples/sentences.rb +24 -0
- data/examples/sentiment.rb +26 -0
- data/examples/similar_terms.rb +23 -0
- data/examples/syntax_dependencies.rb +23 -0
- data/examples/tokens.rb +22 -0
- data/examples/topics.rb +23 -0
- data/examples/transliteration.rb +24 -0
- data/lib/address_parameter.rb +117 -0
- data/lib/address_similarity_parameters.rb +49 -0
- data/lib/bad_request_error.rb +2 -0
- data/lib/bad_request_format_error.rb +2 -0
- data/lib/document_parameters.rb +20 -11
- data/lib/name_deduplication_parameters.rb +15 -7
- data/lib/name_parameter.rb +6 -3
- data/lib/name_similarity_parameters.rb +14 -6
- data/lib/name_translation_parameters.rb +12 -6
- data/lib/request_builder.rb +49 -18
- data/lib/rosette_api.rb +193 -66
- data/lib/rosette_api_error.rb +3 -1
- metadata +43 -14
- data/.rubocop.yml +0 -312
- data/tests/tests_spec.rb +0 -583
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b38b4872ea8951d43abf562f7feed44bf672e2508ec78e34c6e05327293b8c35
|
4
|
+
data.tar.gz: 5608e8136b43a67a771fe860f51deee5c14da58aefa90211d6bb0be77a14834a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f6244f0c40958eabe5165b85dc2ee13e849924f9a500404391541bfb490291e46b8461dcc4f3bfd90ca54ff04ba5585d3b9654d4df8b9b3d2d7c72a4f031ae
|
7
|
+
data.tar.gz: 2dea9f348e81a32fa8f6e692f66385fe0b4143b34902d03765d027087f0b83f670bb428845d77afded27a12bfa013a52b806d042e233266e3cd5924a805bcd64
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2016-2019 Basis Technology Corporation.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
<a href="https://www.rosette.com"><img src="https://s3.amazonaws.com/styleguide.basistech.com/logos/rosette-logo.png" width="181" height="47" /></a>
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/rosette-api/ruby.svg?branch=develop)](https://travis-ci.org/rosette-api/ruby) [![Gem Version](https://badge.fury.io/rb/rosette_api.svg)](https://badge.fury.io/rb/rosette_api)
|
6
|
+
|
7
|
+
## Rosette API
|
8
|
+
The Rosette Text Analytics Platform uses natural language processing, statistical modeling, and machine learning to
|
9
|
+
analyze unstructured and semi-structured text across 364 language-encoding-script combinations, revealing valuable
|
10
|
+
information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and
|
11
|
+
comparing the similarity of names, categorizing and adding linguistic tags to text and more.
|
12
|
+
|
13
|
+
## Rosette API Access
|
14
|
+
- Rosette Cloud [Sign Up](https://developer.rosette.com/signup)
|
15
|
+
- Rosette Enterprise [Evaluation](https://www.rosette.com/product-eval/)
|
16
|
+
|
17
|
+
## Quick Start
|
18
|
+
|
19
|
+
#### Installation
|
20
|
+
|
21
|
+
`gem install rosette_api`
|
22
|
+
|
23
|
+
#### Examples
|
24
|
+
View small example programs for each Rosette endpoint
|
25
|
+
in the [examples](https://github.com/rosette-api/ruby/tree/develop/examples) directory.
|
26
|
+
|
27
|
+
#### Documentation & Support
|
28
|
+
- [Binding API](https://rosette-api.github.io/ruby/)
|
29
|
+
- [Rosette Platform API](https://developer.rosette.com/features-and-functions)
|
30
|
+
- [Binding Release Notes](https://github.com/rosette-api/ruby/wiki/Release-Notes)
|
31
|
+
- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes)
|
32
|
+
- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?ruby#)
|
33
|
+
- [Support](https://support.rosette.com)
|
34
|
+
- [Binding License: Apache 2.0](https://github.com/rosette-api/ruby/blob/develop/LICENSE)
|
35
|
+
|
36
|
+
## Binding Developer Information
|
37
|
+
If you are modifying the binding code, please refer to the [developer README](https://github.com/rosette-api/ruby/tree/develop/DEVELOPER.md) file.
|
38
|
+
|
data/examples/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
## Endpoint Examples
|
2
|
+
|
3
|
+
These examples are scripts that can be run independently to demonstrate the Rosette API functionality.
|
4
|
+
|
5
|
+
Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console.
|
6
|
+
|
7
|
+
Here are some methods for running the examples. Each example will also accept an optional parameter for
|
8
|
+
overriding the default URL. To use, place the url parameter after the key parameter.
|
9
|
+
|
10
|
+
A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it.
|
11
|
+
|
12
|
+
#### Docker/Latest Version From RubyGems
|
13
|
+
```
|
14
|
+
git clone git@github.com:rosette-api/ruby.git
|
15
|
+
cd ruby
|
16
|
+
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
|
17
|
+
|
18
|
+
gem install rosette_api
|
19
|
+
|
20
|
+
cd /source/examples
|
21
|
+
ruby ping.rb $API_KEY
|
22
|
+
```
|
23
|
+
|
24
|
+
#### Docker/Latest Source
|
25
|
+
```
|
26
|
+
git clone git@github.com:rosette-api/ruby.git
|
27
|
+
cd ruby
|
28
|
+
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
|
29
|
+
|
30
|
+
cd /source
|
31
|
+
gem build rosette_api.gemspec
|
32
|
+
gem install rosette_api*.gem
|
33
|
+
|
34
|
+
cd examples
|
35
|
+
ruby ping.rb $API_KEY
|
36
|
+
```
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
address1 = AddressParameter.new(
|
15
|
+
house_number: '1600',
|
16
|
+
road: 'Pennsylvania Ave NW',
|
17
|
+
city: 'Washington',
|
18
|
+
state: 'DC',
|
19
|
+
post_code: '20500'
|
20
|
+
)
|
21
|
+
address2 = '160 Pennsilvana Avenue, Washington, D.C., 20500'
|
22
|
+
params = AddressSimilarityParameters.new(address1, address2)
|
23
|
+
response = rosette_api.get_address_similarity(params)
|
24
|
+
puts JSON.pretty_generate(response)
|
25
|
+
rescue RosetteAPIError => e
|
26
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
27
|
+
status_code: e.status_code,
|
28
|
+
message: e.message)
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
categories_url_data = 'https://onlocationvacations.com/2018/02/06/downton-abbey-exhibition-extended-april-2-nyc/'
|
14
|
+
begin
|
15
|
+
params = DocumentParameters.new(content_uri: categories_url_data)
|
16
|
+
response = rosette_api.get_categories(params)
|
17
|
+
puts JSON.pretty_generate(response)
|
18
|
+
rescue RosetteAPIError => e
|
19
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
20
|
+
status_code: e.status_code,
|
21
|
+
message: e.message)
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
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
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: entities_text_data,
|
16
|
+
genre: 'social-media')
|
17
|
+
response = rosette_api.get_entities(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
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
response = rosette_api.info
|
14
|
+
begin
|
15
|
+
puts JSON.pretty_generate(response)
|
16
|
+
rescue RosetteAPIError => e
|
17
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
18
|
+
status_code: e.status_code,
|
19
|
+
message: e.message)
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
language_data = 'Por favor Señorita, says the man.'
|
14
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: language_data)
|
16
|
+
params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' }
|
17
|
+
response = rosette_api.get_language(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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
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
|
+
begin
|
16
|
+
params = DocumentParameters.new(content: language_multilingual_data)
|
17
|
+
params.rosette_options = { 'multilingual' => 'true' }
|
18
|
+
params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' }
|
19
|
+
response = rosette_api.get_language(params)
|
20
|
+
puts JSON.pretty_generate(response)
|
21
|
+
rescue RosetteAPIError => e
|
22
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
23
|
+
status_code: e.status_code,
|
24
|
+
message: e.message)
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
morphology_complete_data = 'The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)'
|
14
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: morphology_complete_data)
|
16
|
+
response = rosette_api.get_morphology_complete(params)
|
17
|
+
puts JSON.pretty_generate(response)
|
18
|
+
rescue RosetteAPIError => e
|
19
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
20
|
+
status_code: e.status_code,
|
21
|
+
message: e.message)
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
morphology_compound_components_data = 'Rechtsschutzversicherungsgesellschaften'
|
14
|
+
begin
|
15
|
+
params = DocumentParameters.new(
|
16
|
+
content: morphology_compound_components_data
|
17
|
+
)
|
18
|
+
response = rosette_api.get_compound_components(params)
|
19
|
+
puts JSON.pretty_generate(response)
|
20
|
+
rescue RosetteAPIError => e
|
21
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
22
|
+
status_code: e.status_code,
|
23
|
+
message: e.message)
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
morphology_han_readings_data = '北京大学生物系主任办公室内部会议'
|
14
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: morphology_han_readings_data)
|
16
|
+
response = rosette_api.get_han_readings(params)
|
17
|
+
puts JSON.pretty_generate(response)
|
18
|
+
rescue RosetteAPIError => e
|
19
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
20
|
+
status_code: e.status_code,
|
21
|
+
message: e.message)
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
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
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: morphology_lemmas_data)
|
16
|
+
response = rosette_api.get_lemmas(params)
|
17
|
+
puts JSON.pretty_generate(response)
|
18
|
+
rescue RosetteAPIError => e
|
19
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
20
|
+
status_code: e.status_code,
|
21
|
+
message: e.message)
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
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
|
+
begin
|
15
|
+
params = DocumentParameters.new(content: morphology_parts_of_speech_data)
|
16
|
+
response = rosette_api.get_parts_of_speech(params)
|
17
|
+
puts JSON.pretty_generate(response)
|
18
|
+
rescue RosetteAPIError => e
|
19
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
20
|
+
status_code: e.status_code,
|
21
|
+
message: e.message)
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
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
|
+
threshold = 0.75
|
16
|
+
names = name_dedupe_data.split(',').map { |n| NameParameter.new(n) }
|
17
|
+
begin
|
18
|
+
params = NameDeduplicationParameters.new(names, threshold)
|
19
|
+
response = rosette_api.get_name_deduplication(params)
|
20
|
+
puts JSON.pretty_generate(response)
|
21
|
+
rescue RosetteAPIError => e
|
22
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
23
|
+
status_code: e.status_code,
|
24
|
+
message: e.message)
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
matched_name_data1 = 'Michael Jackson'
|
14
|
+
matched_name_data2 = '迈克尔·杰克逊'
|
15
|
+
begin
|
16
|
+
name1 = NameParameter.new(
|
17
|
+
matched_name_data1,
|
18
|
+
entity_type: 'PERSON',
|
19
|
+
language: 'eng'
|
20
|
+
)
|
21
|
+
params = NameSimilarityParameters.new(name1, matched_name_data2)
|
22
|
+
response = rosette_api.get_name_similarity(params)
|
23
|
+
puts JSON.pretty_generate(response)
|
24
|
+
rescue RosetteAPIError => e
|
25
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
26
|
+
status_code: e.status_code,
|
27
|
+
message: e.message)
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rosette_api'
|
4
|
+
|
5
|
+
api_key, url = ARGV
|
6
|
+
|
7
|
+
rosette_api = if url
|
8
|
+
RosetteAPI.new(api_key, url)
|
9
|
+
else
|
10
|
+
RosetteAPI.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
translated_name_data = 'معمر محمد أبو منيار القذاف'
|
14
|
+
begin
|
15
|
+
params = NameTranslationParameters.new(
|
16
|
+
translated_name_data,
|
17
|
+
'eng',
|
18
|
+
target_script: 'Latn'
|
19
|
+
)
|
20
|
+
response = rosette_api.get_name_translation(params)
|
21
|
+
puts JSON.pretty_generate(response)
|
22
|
+
rescue RosetteAPIError => e
|
23
|
+
printf('Rosette API Error (%<status_code>s): %<message>s',
|
24
|
+
status_code: e.status_code,
|
25
|
+
message: e.message)
|
26
|
+
end
|