Skip to content

Commit 4672096

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents 823594f + eba2382 commit 4672096

21 files changed

+522
-291
lines changed

examples/categories.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
rosette_api = RosetteAPI.new(api_key, url)
99
end
1010

11-
categories_url_data = "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/"
11+
categories_url_data = 'http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/'
1212
begin
13-
params = DocumentParameters.new(content_uri: categories_url_data)
14-
response = rosette_api.get_categories(params)
15-
puts JSON.pretty_generate(response)
13+
params = DocumentParameters.new(content_uri: categories_url_data)
14+
response = rosette_api.get_categories(params)
15+
puts JSON.pretty_generate(response)
1616
rescue RosetteAPIError => rosette_api_error
17-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
17+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1818
end

examples/name_deduplication.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'rosette_api'
2+
3+
api_key, url = ARGV
4+
5+
if !url
6+
rosette_api = RosetteAPI.new(api_key)
7+
else
8+
rosette_api = RosetteAPI.new(api_key, url)
9+
end
10+
11+
name_dedupe_data = 'John Smith,Johnathon Smith,Fred Jones'
12+
13+
threshold = 0.75
14+
names = name_dedupe_data.split(',').map { |n| NameParameter.new(n) }
15+
begin
16+
params = NameDeduplicationParameters.new(names, threshold)
17+
response = rosette_api.get_name_deduplication(params)
18+
puts JSON.pretty_generate(response)
19+
rescue RosetteAPIError => rosette_api_error
20+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
21+
end

examples/name_similarity.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
rosette_api = RosetteAPI.new(api_key, url)
99
end
1010

11-
matched_name_data1 = "Michael Jackson"
12-
matched_name_data2 = "迈克尔·杰克逊"
11+
matched_name_data1 = 'Michael Jackson'
12+
matched_name_data2 = '迈克尔·杰克逊'
1313
begin
14-
name1 = NameParameter.new(matched_name_data1, entity_type: 'PERSON', language:'eng')
15-
params = NameSimilarityParameters.new(name1, matched_name_data2)
16-
response = rosette_api.name_similarity(params)
17-
puts JSON.pretty_generate(response)
14+
name1 = NameParameter.new(matched_name_data1, entity_type: 'PERSON', language: 'eng')
15+
params = NameSimilarityParameters.new(name1, matched_name_data2)
16+
response = rosette_api.get_name_similarity(params)
17+
puts JSON.pretty_generate(response)
1818
rescue RosetteAPIError => rosette_api_error
19-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
19+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
2020
end

examples/name_translation.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
rosette_api = RosetteAPI.new(api_key, url)
99
end
1010

11-
translated_name_data = "معمر محمد أبو منيار القذاف"
11+
translated_name_data = 'معمر محمد أبو منيار القذاف'
1212
begin
13-
params = NameTranslationParameters.new(translated_name_data, 'eng', target_script: 'Latn')
14-
response = rosette_api.name_translation(params)
15-
puts JSON.pretty_generate(response)
13+
params = NameTranslationParameters.new(translated_name_data, 'eng', target_script: 'Latn')
14+
response = rosette_api.get_name_translation(params)
15+
puts JSON.pretty_generate(response)
1616
rescue RosetteAPIError => rosette_api_error
17-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
17+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1818
end

examples/ping.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
rosette_api = RosetteAPI.new(api_key, url)
99
end
1010
begin
11-
response = rosette_api.ping
12-
puts JSON.pretty_generate(response)
11+
response = rosette_api.ping
12+
puts JSON.pretty_generate(response)
1313
rescue RosetteAPIError => rosette_api_error
14-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
14+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1515
end

examples/relationships.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
relationships_text_data = "Bill Gates, Microsoft's former CEO, is a philanthropist."
1212
begin
13-
params = DocumentParameters.new(content: relationships_text_data)
14-
params.rosette_options = { accuracyMode: 'PRECISION' }
15-
response = rosette_api.get_relationships(params)
16-
puts JSON.pretty_generate(response)
13+
params = DocumentParameters.new(content: relationships_text_data)
14+
params.rosette_options = { accuracyMode: 'PRECISION' }
15+
response = rosette_api.get_relationships(params)
16+
puts JSON.pretty_generate(response)
1717
rescue RosetteAPIError => rosette_api_error
18-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
18+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1919
end

examples/sentences.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
sentences_data = "This land is your land. This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\nAs I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me."
1212

1313
begin
14-
params = DocumentParameters.new
15-
params.content = sentences_data
16-
response = rosette_api.get_sentences(params)
17-
puts JSON.pretty_generate(response)
14+
params = DocumentParameters.new
15+
params.content = sentences_data
16+
response = rosette_api.get_sentences(params)
17+
puts JSON.pretty_generate(response)
1818
rescue RosetteAPIError => rosette_api_error
19-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
19+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
2020
end

examples/sentiment.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
rosette_api = RosetteAPI.new(api_key, url)
1010
end
1111

12-
file = Tempfile.new(%w(foo .html))
12+
file = Tempfile.new(%w[foo .html])
1313
sentiment_file_data = '<html><head><title>New Ghostbusters Film</title></head><body><p>Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”</p></body></html>'
1414
file.write(sentiment_file_data)
1515
file.close
1616
begin
17-
params = DocumentParameters.new(file_path: file.path, language: 'eng')
18-
response = rosette_api.get_sentiment(params)
19-
puts JSON.pretty_generate(response)
17+
params = DocumentParameters.new(file_path: file.path, language: 'eng')
18+
response = rosette_api.get_sentiment(params)
19+
puts JSON.pretty_generate(response)
2020
rescue RosetteAPIError => rosette_api_error
21-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
21+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
2222
end

examples/syntax_dependencies.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
rosette_api = RosetteAPI.new(api_key, url)
99
end
1010

11-
syntax_dependencies_data = "Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday."
11+
syntax_dependencies_data = 'Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday.'
1212
begin
13-
params = DocumentParameters.new(content: syntax_dependencies_data, genre: 'social-media')
14-
response = rosette_api.get_syntax_dependencies(params)
15-
puts JSON.pretty_generate(response)
13+
params = DocumentParameters.new(content: syntax_dependencies_data)
14+
response = rosette_api.get_syntax_dependencies(params)
15+
puts JSON.pretty_generate(response)
1616
rescue RosetteAPIError => rosette_api_error
17-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
17+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1818
end

examples/text_embedding.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
embeddings_data = 'Cambridge, Massachusetts'
1212
begin
13-
params = DocumentParameters.new(content: embeddings_data)
14-
response = rosette_api.get_text_embedding(params)
15-
puts JSON.pretty_generate(response)
13+
params = DocumentParameters.new(content: embeddings_data)
14+
response = rosette_api.get_text_embedding(params)
15+
puts JSON.pretty_generate(response)
1616
rescue RosetteAPIError => rosette_api_error
17-
printf("Rosette API Error (%s): %s", rosette_api_error.status_code, rosette_api_error.message)
17+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
1818
end

0 commit comments

Comments
 (0)