Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Oct 24, 2017
2 parents 4672096 + 4c1cafe commit 4ffe5b3
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 37 deletions.
28 changes: 28 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,28 @@
node {
def SOURCEDIR = pwd()
try {
stage("Clean up") {
step([$class: 'WsCleanup'])
}
stage("Checkout Code") {
checkout scm
}
stage("Test with Docker") {
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-ruby"
}
}
slack(true)
} catch (e) {
currentBuild.result = "FAILED"
slack(false)
throw e
}
}

def slack(boolean success) {
def color = success ? "#00FF00" : "#FF0000"
def status = success ? "SUCCESSFUL" : "FAILED"
def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
slackSend(color: color, channel: "#rapid", message: message)
}
35 changes: 35 additions & 0 deletions Jenkinsfile.examples
@@ -0,0 +1,35 @@
node {
def SOURCEDIR = pwd()
def TEST_CONTAINER = 'examples/ruby-test'
def DOCKERFILE_DIR = './examples/docker'
try {
stage("Clean up") {
step([$class: 'WsCleanup'])
}
stage("Checkout Code") {
checkout scm
}
stage("Build Dockerfile") {
dir ("${DOCKERFILE_DIR}") {
docker.build("${TEST_CONTAINER}")
}
}
stage("Run Examples") {
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}"
}
}
slack(true)
} catch (e) {
currentBuild.result = "FAILED"
slack(false)
throw e
}
}

def slack(boolean success) {
def color = success ? "#00FF00" : "#FF0000"
def status = success ? "SUCCESSFUL" : "FAILED"
def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
slackSend(color: color, channel: "#rapid", message: message)
}
14 changes: 12 additions & 2 deletions README.md
Expand Up @@ -7,6 +7,15 @@ See the wiki for more information.

`gem install rosette_api`

If the version you are using is not [the latest from RubyGems](https://rubygems.org/gems/rosette_api),
please check for its [**compatibilty with api.rosette.com**](https://developer.rosette.com/features-and-functions?ruby).
If you have an on-premise version of Rosette API server, please contact support for
binding compatibility with your installation.

To check your installed version:

`gem list rosette_api`

## Docker ##
A Docker image for running the examples against the compiled source library is available on Docker Hub.

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

## API Documentation ##

See [documentation](http://rosette-api.github.io/ruby)

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

## Additional Information ##
Visit [Rosette API site](https://developer.rosette.com)
23 changes: 12 additions & 11 deletions examples/README.md
Expand Up @@ -11,27 +11,28 @@ For example, run `ruby categories.js <your_key>` if you want to see the categori
functionality demonstrated.

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

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

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

| File Name | What it does |
| File Name | What it does |
| ------------- |------------- |
| categories.rb | Gets the category of a document at a URL |
| entities.rb | Gets the entities from a piece of text |
| info.rb | Gets information about Rosette API |
| language.rb | Gets the language of a piece of text |
| categories.rb | Gets the category of a document at a URL |
| entities.rb | Gets the entities from a piece of text |
| info.rb | Gets information about Rosette API |
| language.rb | Gets the language of a piece of text |
| name_similarity.rb | Gets the similarity score of two names |
| morphology_complete.rb | Gets the complete morphological analysis of a piece of text|
| morphology_complete.rb | Gets the complete morphological analysis of a piece of text|
| morphology_compound_components.rb | Gets the de-compounded words from a piece of text |
| morphology_han_readings.rb | Gets the Chinese words from a piece of text |
| morphology_lemmas.rb | Gets the lemmas of words from a piece of text |
| morphology_lemmas.rb | Gets the lemmas of words from a piece of text |
| morphology_parts_of_speech.rb | Gets the part-of-speech tags for words in a piece of text |
| ping.rb | Pings the Rosette API to check for reachability |
| ping.rb | Pings the Rosette API to check for reachability |
| sentences.rb | Gets the sentences from a piece of text |
| sentiment.rb | Gets the sentiment of a local file |
| tokens.rb | Gets the tokens (words) from a piece of text |
| sentiment.rb | Gets the sentiment of a local file |
| tokens.rb | Gets the tokens (words) from a piece of text |
| topics.rb | Gets the key phrases and concepts from a piece of text |
| name_translation.rb | Translates a name from one language to another |
18 changes: 18 additions & 0 deletions examples/topics.rb
@@ -0,0 +1,18 @@
require 'rosette_api'

api_key, url = ARGV

if !url
rosette_api = RosetteAPI.new(api_key)
else
rosette_api = RosetteAPI.new(api_key, url)
end

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."
begin
params = DocumentParameters.new(content: topics_data)
response = rosette_api.get_topics(params)
puts JSON.pretty_generate(response)
rescue RosetteAPIError => rosette_api_error
printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message)
end
21 changes: 20 additions & 1 deletion lib/rosette_api.rb
Expand Up @@ -10,7 +10,7 @@
# This class allows you to access all Rosette API endpoints.
class RosetteAPI
# Version of Ruby binding
BINDING_VERSION = '1.7.0'
BINDING_VERSION = '1.8.0'
# Rosette API language endpoint
LANGUAGE_ENDPOINT = '/language'.freeze
# Rosette API morphology endpoint
Expand Down Expand Up @@ -43,6 +43,9 @@ class RosetteAPI
SYNTACTIC_DEPENDENCIES_ENDPOINT = '/syntax/dependencies'.freeze
# Transliteration endpoint
TRANSLITERATION_ENDPOINT = '/transliteration'.freeze
# Topics endpoint
TOPICS_ENDPOINT = '/topics'.freeze


# Rosette API key
attr_accessor :user_key
Expand Down Expand Up @@ -365,6 +368,22 @@ def get_transliteration(params)
.send_post_request
end

# Divides the input into topics (key phrases and concepts).
#
# ==== Attributes
#
# * +params+ - DocumentParameters helps to build the request body in RequestBuilder.
#
# Returns list of topics of the input.
def get_topics(params)
check_params params

params = params.load_params

RequestBuilder.new(@user_key, @alternate_url + TOPICS_ENDPOINT, @http_client, params, @url_parameters, BINDING_VERSION)
.send_post_request
end

# Gets information about the Rosette API, returns name, build number
# and build time.
def info
Expand Down
4 changes: 2 additions & 2 deletions rosette_api.gemspec
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.0.0'

s.name = 'rosette_api'
s.version = '1.7.0'
s.version = '1.8.0'
s.license = 'MIT'

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

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

0 comments on commit 4ffe5b3

Please sign in to comment.