Skip to content

Commit 4ffe5b3

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents 4672096 + 4c1cafe commit 4ffe5b3

File tree

8 files changed

+169
-37
lines changed

8 files changed

+169
-37
lines changed

Jenkinsfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
node {
2+
def SOURCEDIR = pwd()
3+
try {
4+
stage("Clean up") {
5+
step([$class: 'WsCleanup'])
6+
}
7+
stage("Checkout Code") {
8+
checkout scm
9+
}
10+
stage("Test with Docker") {
11+
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
12+
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-ruby"
13+
}
14+
}
15+
slack(true)
16+
} catch (e) {
17+
currentBuild.result = "FAILED"
18+
slack(false)
19+
throw e
20+
}
21+
}
22+
23+
def slack(boolean success) {
24+
def color = success ? "#00FF00" : "#FF0000"
25+
def status = success ? "SUCCESSFUL" : "FAILED"
26+
def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
27+
slackSend(color: color, channel: "#rapid", message: message)
28+
}

Jenkinsfile.examples

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
node {
2+
def SOURCEDIR = pwd()
3+
def TEST_CONTAINER = 'examples/ruby-test'
4+
def DOCKERFILE_DIR = './examples/docker'
5+
try {
6+
stage("Clean up") {
7+
step([$class: 'WsCleanup'])
8+
}
9+
stage("Checkout Code") {
10+
checkout scm
11+
}
12+
stage("Build Dockerfile") {
13+
dir ("${DOCKERFILE_DIR}") {
14+
docker.build("${TEST_CONTAINER}")
15+
}
16+
}
17+
stage("Run Examples") {
18+
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
19+
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}"
20+
}
21+
}
22+
slack(true)
23+
} catch (e) {
24+
currentBuild.result = "FAILED"
25+
slack(false)
26+
throw e
27+
}
28+
}
29+
30+
def slack(boolean success) {
31+
def color = success ? "#00FF00" : "#FF0000"
32+
def status = success ? "SUCCESSFUL" : "FAILED"
33+
def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
34+
slackSend(color: color, channel: "#rapid", message: message)
35+
}

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ See the wiki for more information.
77

88
`gem install rosette_api`
99

10+
If the version you are using is not [the latest from RubyGems](https://rubygems.org/gems/rosette_api),
11+
please check for its [**compatibilty with api.rosette.com**](https://developer.rosette.com/features-and-functions?ruby).
12+
If you have an on-premise version of Rosette API server, please contact support for
13+
binding compatibility with your installation.
14+
15+
To check your installed version:
16+
17+
`gem list rosette_api`
18+
1019
## Docker ##
1120
A Docker image for running the examples against the compiled source library is available on Docker Hub.
1221

@@ -21,9 +30,10 @@ Additional environment settings:
2130
See [examples](examples)
2231

2332
## API Documentation ##
24-
2533
See [documentation](http://rosette-api.github.io/ruby)
2634

27-
## Additional Information ##
35+
## Release Notes
36+
See the [wiki](https://github.com/rosette-api/ruby/wiki/Release-Notes)
2837

38+
## Additional Information ##
2939
Visit [Rosette API site](https://developer.rosette.com)

examples/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ For example, run `ruby categories.js <your_key>` if you want to see the categori
1111
functionality demonstrated.
1212

1313
All files require you to input your Rosette API User Key after `--key` to run.
14-
For example: `ruby ping.js 1234567890`
14+
For example: `ruby ping.js 1234567890`
1515

1616
To run all of the examples:
1717
`find -maxdepth 1 -name *.rb -exec ruby {} api_key alternate_url`
1818

1919
Each example, when run, prints its output to the console.
2020

21-
| File Name | What it does |
21+
| File Name | What it does |
2222
| ------------- |------------- |
23-
| categories.rb | Gets the category of a document at a URL |
24-
| entities.rb | Gets the entities from a piece of text |
25-
| info.rb | Gets information about Rosette API |
26-
| language.rb | Gets the language of a piece of text |
23+
| categories.rb | Gets the category of a document at a URL |
24+
| entities.rb | Gets the entities from a piece of text |
25+
| info.rb | Gets information about Rosette API |
26+
| language.rb | Gets the language of a piece of text |
2727
| name_similarity.rb | Gets the similarity score of two names |
28-
| morphology_complete.rb | Gets the complete morphological analysis of a piece of text|
28+
| morphology_complete.rb | Gets the complete morphological analysis of a piece of text|
2929
| morphology_compound_components.rb | Gets the de-compounded words from a piece of text |
3030
| morphology_han_readings.rb | Gets the Chinese words from a piece of text |
31-
| morphology_lemmas.rb | Gets the lemmas of words from a piece of text |
31+
| morphology_lemmas.rb | Gets the lemmas of words from a piece of text |
3232
| morphology_parts_of_speech.rb | Gets the part-of-speech tags for words in a piece of text |
33-
| ping.rb | Pings the Rosette API to check for reachability |
33+
| ping.rb | Pings the Rosette API to check for reachability |
3434
| sentences.rb | Gets the sentences from a piece of text |
35-
| sentiment.rb | Gets the sentiment of a local file |
36-
| tokens.rb | Gets the tokens (words) from a piece of text |
35+
| sentiment.rb | Gets the sentiment of a local file |
36+
| tokens.rb | Gets the tokens (words) from a piece of text |
37+
| topics.rb | Gets the key phrases and concepts from a piece of text |
3738
| name_translation.rb | Translates a name from one language to another |

examples/topics.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
topics_data = "Lily Collins is in talks to join Nicholas Hoult in Chernin Entertainment and Fox Searchlight's J.R.R. Tolkien biopic Tolkien. Anthony Boyle, known for playing Scorpius Malfoy in the British play Harry Potter and the Cursed Child, also has signed on for the film centered on the famed author. In Tolkien, Hoult will play the author of the Hobbit and Lord of the Rings book series that were later adapted into two Hollywood trilogies from Peter Jackson. Dome Karukoski is directing the project."
12+
begin
13+
params = DocumentParameters.new(content: topics_data)
14+
response = rosette_api.get_topics(params)
15+
puts JSON.pretty_generate(response)
16+
rescue RosetteAPIError => rosette_api_error
17+
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
18+
end

lib/rosette_api.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# This class allows you to access all Rosette API endpoints.
1111
class RosetteAPI
1212
# Version of Ruby binding
13-
BINDING_VERSION = '1.7.0'
13+
BINDING_VERSION = '1.8.0'
1414
# Rosette API language endpoint
1515
LANGUAGE_ENDPOINT = '/language'.freeze
1616
# Rosette API morphology endpoint
@@ -43,6 +43,9 @@ class RosetteAPI
4343
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'.freeze
4444
# Transliteration endpoint
4545
TRANSLITERATION_ENDPOINT = '/transliteration'.freeze
46+
# Topics endpoint
47+
TOPICS_ENDPOINT = '/topics'.freeze
48+
4649

4750
# Rosette API key
4851
attr_accessor :user_key
@@ -365,6 +368,22 @@ def get_transliteration(params)
365368
.send_post_request
366369
end
367370

371+
# Divides the input into topics (key phrases and concepts).
372+
#
373+
# ==== Attributes
374+
#
375+
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
376+
#
377+
# Returns list of topics of the input.
378+
def get_topics(params)
379+
check_params params
380+
381+
params = params.load_params
382+
383+
RequestBuilder.new(@user_key, @alternate_url + TOPICS_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
384+
.send_post_request
385+
end
386+
368387
# Gets information about the Rosette API, returns name, build number
369388
# and build time.
370389
def info

rosette_api.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
88
s.required_ruby_version = '>= 2.0.0'
99

1010
s.name = 'rosette_api'
11-
s.version = '1.7.0'
11+
s.version = '1.8.0'
1212
s.license = 'MIT'
1313

1414
s.summary = 'Rosette API gem that supports multilingual text-analytics.'
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
1919
s.authors = ['Basis Technology Corp']
2020
s.email = %q{[email protected]}
2121
s.homepage = %q{https://developer.rosette.com/}
22-
s.date = %q{2017-06-14}
22+
s.date = %q{2017-10-24}
2323

2424
all_files = `git ls-files -z`.split("\x0")
2525
s.files = all_files.grep(%r{^(bin|lib)/|^.rubocop.yml$})

0 commit comments

Comments
 (0)