rosette_api 1.12.1 → 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +13 -0
  3. data/README.md +38 -0
  4. data/examples/README.md +36 -0
  5. data/examples/address_similarity.rb +35 -0
  6. data/examples/categories.rb +24 -0
  7. data/examples/entities.rb +31 -0
  8. data/examples/info.rb +20 -0
  9. data/examples/language.rb +23 -0
  10. data/examples/language_multilingual.rb +33 -0
  11. data/examples/morphology_complete.rb +23 -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 +24 -0
  15. data/examples/morphology_parts_of_speech.rb +24 -0
  16. data/examples/name_deduplication.rb +27 -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 +31 -0
  21. data/examples/semantic_vectors.rb +22 -0
  22. data/examples/sentences.rb +28 -0
  23. data/examples/sentiment.rb +32 -0
  24. data/examples/similar_terms.rb +23 -0
  25. data/examples/syntax_dependencies.rb +25 -0
  26. data/examples/tokens.rb +22 -0
  27. data/examples/topics.rb +29 -0
  28. data/examples/transliteration.rb +25 -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 +43 -18
  39. data/lib/rosette_api.rb +156 -71
  40. data/lib/rosette_api_error.rb +3 -1
  41. metadata +43 -13
  42. data/.rubocop.yml +0 -312
  43. data/tests/tests_spec.rb +0 -611
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d65a80d194b5956cf0a742db19a6076b05aace36a082697ab01a27fb9be14a2a
4
- data.tar.gz: 22f92f9b67f0533c042d32a5c1ee249b5ac4034ba1abab66d317b3ee8658c78c
3
+ metadata.gz: 88f16158b8883961fecc410ce85c874914d8610a3e179955f5d2429fb2c4b7ab
4
+ data.tar.gz: 818932647be367d98c903e4487ba52bd8164f686f0c16be791a8cc54a3b30cc5
5
5
  SHA512:
6
- metadata.gz: ca25172ef0ef615051922a8a849c3d7d11755b806f004df9eb2c0c6a131a8a203cac560aeb72c88224e0078c759553048548883cf74640f4c63168618380cf92
7
- data.tar.gz: a3d64fd9539dbacb98489e60ac19d45b6eac4e1f80edf2e8bfc433d3f8713a966448d2ddbbaf87e62a86b6fe76f23189c794a9984a957bfdf207968463882acd
6
+ metadata.gz: c1cc5483c3e5e4ed59104c82a14c548b303f85d7be9bb74551b8dbec467de16b15b23fbc9bf7b4374aade07f41bd1d2ac2b16ec509293ceeccb4ca5f35922650
7
+ data.tar.gz: 0fa5063ae2d6765314df3b33c1a0620b974b24a8c0c3b627c5617b75ca9e13d1ac1d62a2d4522464004e654c24f4217c52e164d606690ff8697ccd83389fa2f2
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.
@@ -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
+
@@ -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,35 @@
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 = AddressParameter.new(
22
+ house_number: '160',
23
+ road: 'Pennsilvana Avenue',
24
+ city: 'Washington',
25
+ state: 'D.C.',
26
+ post_code: '20500'
27
+ )
28
+ params = AddressSimilarityParameters.new(address1, address2)
29
+ response = rosette_api.get_address_similarity(params)
30
+ puts JSON.pretty_generate(response)
31
+ rescue RosetteAPIError => e
32
+ printf('Rosette API Error (%<status_code>s): %<message>s',
33
+ status_code: e.status_code,
34
+ message: e.message)
35
+ 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
+ categories_url_data =
14
+ 'https://onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-' \
15
+ 'begins-filming-in-boston-in-june/'
16
+ begin
17
+ params = DocumentParameters.new(content_uri: categories_url_data)
18
+ response = rosette_api.get_categories(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,31 @@
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 ' \
14
+ 'announced the leadership of the agency\'s trial unit. Bridget Fitzpatrick ' \
15
+ 'has been named Chief Litigation Counsel of the SEC and David Gottesman ' \
16
+ 'will continue to serve as the agency\'s Deputy Chief Litigation Counsel. ' \
17
+ 'Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as ' \
18
+ 'Co-Acting Chief Litigation Counsel. In that role, they were jointly ' \
19
+ 'responsible for supervising the trial unit at the agency\'s Washington ' \
20
+ 'D.C. headquarters as well as coordinating with litigators in the SEC\'s ' \
21
+ '11 regional offices around the country.'
22
+ begin
23
+ params = DocumentParameters.new(content: entities_text_data,
24
+ genre: 'social-media')
25
+ response = rosette_api.get_entities(params)
26
+ puts JSON.pretty_generate(response)
27
+ rescue RosetteAPIError => e
28
+ printf('Rosette API Error (%<status_code>s): %<message>s',
29
+ status_code: e.status_code,
30
+ message: e.message)
31
+ end
@@ -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,33 @@
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 ' \
14
+ 'Washington D.C., the United States Federal Communications Commission ' \
15
+ 'under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly ' \
16
+ 'called Net Neutrality, that forbade Internet service providers (ISPs) ' \
17
+ 'such as Verizon, Comcast, and AT&T from blocking individual websites or ' \
18
+ 'charging websites or customers more for faster load times. Quatre ' \
19
+ 'femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, ' \
20
+ 'le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés ' \
21
+ 'pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.'
22
+
23
+ begin
24
+ params = DocumentParameters.new(content: language_multilingual_data)
25
+ params.rosette_options = { 'multilingual' => 'true' }
26
+ params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' }
27
+ response = rosette_api.get_language(params)
28
+ puts JSON.pretty_generate(response)
29
+ rescue RosetteAPIError => e
30
+ printf('Rosette API Error (%<status_code>s): %<message>s',
31
+ status_code: e.status_code,
32
+ message: e.message)
33
+ 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
+ morphology_complete_data = 'The quick brown fox jumped over the lazy ' \
14
+ 'dog. 👍🏾 Yes he did. B)'
15
+ begin
16
+ params = DocumentParameters.new(content: morphology_complete_data)
17
+ response = rosette_api.get_morphology_complete(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,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,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_lemmas_data =
14
+ 'The fact is that the geese just went back to get a rest and I\'m not ' \
15
+ 'banking on their return soon'
16
+ begin
17
+ params = DocumentParameters.new(content: morphology_lemmas_data)
18
+ response = rosette_api.get_lemmas(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,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_parts_of_speech_data =
14
+ 'The fact is that the geese just went back to get a rest and I\'m not ' \
15
+ 'banking on their return soon'
16
+ begin
17
+ params = DocumentParameters.new(content: morphology_parts_of_speech_data)
18
+ response = rosette_api.get_parts_of_speech(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,27 @@
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,' \
14
+ 'Norma Shearer,Norm Shearer,Brigitte Helm,Bridget Helem,Judy Holliday,' \
15
+ 'Julie Halliday'
16
+
17
+ threshold = 0.75
18
+ names = name_dedupe_data.split(',').map { |n| NameParameter.new(n) }
19
+ begin
20
+ params = NameDeduplicationParameters.new(names, threshold)
21
+ response = rosette_api.get_name_deduplication(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
+ 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