Skip to content

Commit 49b34ab

Browse files
authored
Merge pull request #67 from rosette-api/BX-68618
Bx 68618
2 parents 242bcd7 + ea8197f commit 49b34ab

51 files changed

Lines changed: 1352 additions & 462 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Ruby SDK",
3+
"image": "mcr.microsoft.com/devcontainers/ruby:3.3",
4+
"postCreateCommand": "gem install bundler && bundle install",
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"Shopify.ruby-lsp"
9+
]
10+
}
11+
}
12+
}

.rubocop_todo.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-01-11 22:13:12 UTC using RuboCop version 1.59.0.
3+
# on 2026-03-05 13:36:13 UTC using RuboCop version 1.85.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -9,28 +9,35 @@
99
# Offense count: 4
1010
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
1111
Metrics/AbcSize:
12-
Max: 45
12+
Max: 50
1313

1414
# Offense count: 10
1515
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
1616
# AllowedMethods: refine
1717
Metrics/BlockLength:
1818
Max: 786
19+
#TODO check rubocop-rspec extension
20+
Exclude:
21+
- 'tests/tests_spec.rb'
1922

2023
# Offense count: 2
2124
# Configuration parameters: CountComments, CountAsOne.
2225
Metrics/ClassLength:
23-
Max: 232
26+
Max: 250
2427

2528
# Offense count: 1
2629
# Configuration parameters: AllowedMethods, AllowedPatterns.
2730
Metrics/CyclomaticComplexity:
28-
Max: 8
31+
Max: 10
32+
33+
Metrics/PerceivedComplexity:
34+
Max: 10
35+
2936

30-
# Offense count: 11
37+
# Offense count: 10
3138
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
3239
Metrics/MethodLength:
33-
Max: 51
40+
Max: 50
3441

3542
# Offense count: 1
3643
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
@@ -43,6 +50,7 @@ Metrics/ParameterLists:
4350
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
4451
Naming/FileName:
4552
Exclude:
53+
- 'Rakefile.rb'
4654
- 'examples/morphology_compound-components.rb'
4755
- 'examples/morphology_han-readings.rb'
4856
- 'examples/morphology_parts-of-speech.rb'
@@ -60,18 +68,19 @@ Style/CommentedKeyword:
6068
- 'lib/name_parameter.rb'
6169
- 'lib/name_similarity_parameters.rb'
6270
- 'lib/name_translation_parameters.rb'
71+
- 'lib/record_similarity_parameters.rb'
6372
- 'lib/rosette_api_error.rb'
6473

6574
# Offense count: 14
66-
# This cop supports safe autocorrection (--autocorrect).
75+
# This cop supports unsafe autocorrection (--autocorrect-all).
6776
# Configuration parameters: AllowedCompactTypes.
6877
# SupportedStyles: compact, exploded
6978
Style/RaiseArgs:
7079
EnforcedStyle: compact
7180

72-
# Offense count: 11
81+
# Offense count: 18
7382
# This cop supports safe autocorrection (--autocorrect).
74-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
83+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
7584
# URISchemes: http, https
7685
Layout/LineLength:
7786
Max: 772

CI.Jenkinsfile

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
1+
def versions = [3.3, 3.4, 4.0]
12

2-
3-
def versions = [3.0, 3.1, 3.2, 3.3]
4-
5-
def runSonnarForPythonVersion(sourceDir, ver){
6-
mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
7-
if("${env.CHANGE_ID}" != "null"){
8-
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}"
9-
} else {
10-
mySonarOpts = "$mySonarOpts -Dsonar.branch.name=${env.BRANCH_NAME}"
11-
}
12-
if ("${env.CHANGE_BRANCH}" != "null") {
13-
mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
14-
}
15-
3+
def runSonarIfVersion(sourceDir, ver){
164
// Only run Sonar once.
175
// Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/
18-
if(ver == 3.3) {
6+
def sonarScannerVersion = "8.1.0.6389-linux-x64"
7+
def sonarExec = ""
8+
9+
if(ver == 4.0) {
10+
def mySonarOpts= "-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.token=${env.SONAR_AUTH_TOKEN} -Dsonar.ruby.coverage.reportPaths=coverage/coverage.json"
11+
if("${env.CHANGE_ID}" != "null"){
12+
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}"
13+
} else {
14+
mySonarOpts = "$mySonarOpts -Dsonar.branch.name=${env.BRANCH_NAME}"
15+
}
16+
if ("${env.CHANGE_BRANCH}" != "null") {
17+
mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
18+
}
1919
sonarExec="cd /root/ && \
20-
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \
21-
unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \
20+
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${sonarScannerVersion}.zip && \
21+
unzip -q sonar-scanner-cli-${sonarScannerVersion}.zip && \
2222
cd /source && \
23-
/root/sonar-scanner-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}"
23+
/root/sonar-scanner-${sonarScannerVersion}/bin/sonar-scanner ${mySonarOpts}"
2424
} else {
2525
sonarExec="echo Skipping Sonar for this version."
2626
}
2727

28-
//
29-
//
30-
// NOTE: The test coverage data is not making it into Sonar.
31-
// I don't think it is worth spending more time on until
32-
// Sonar is upgraded.
33-
//
34-
//
3528
sh "docker run \
3629
--pull always \
30+
--env DEBIAN_FRONTEND=noninteractive \
3731
--rm --volume ${sourceDir}:/source \
3832
ruby:${ver}-slim \
3933
bash -c \"echo && \
@@ -43,7 +37,10 @@ def runSonnarForPythonVersion(sourceDir, ver){
4337
apt-get update -qq && \
4438
echo && \
4539
echo [INFO] Installing required OS packages. && \
46-
apt-get -qq install -y gcc make wget unzip > /dev/null && \
40+
apt-get -qq install -y gcc make wget unzip libyaml-dev > /dev/null && \
41+
echo && \
42+
echo [INFO] Removing any artifacts from prior executions. && \
43+
rm -rf coverage .bundle Gemfile.lock *.gem && \
4744
echo && \
4845
echo [INFO] Installing gems needed for CI. && \
4946
gem install --silent --quiet bundler rspec rubocop && \
@@ -55,8 +52,6 @@ def runSonnarForPythonVersion(sourceDir, ver){
5552
echo [INFO] Running bundle install. && \
5653
bundle install --quiet && \
5754
echo && \
58-
echo [INFO] Removing any coverage data from prior executions. && \
59-
rm -rf coverage && \
6055
echo [INFO] Running unit tests. && \
6156
rspec tests && \
6257
echo && \
@@ -70,7 +65,7 @@ def runSonnarForPythonVersion(sourceDir, ver){
7065
${sonarExec} && \
7166
echo && \
7267
echo [INFO] Re-permission files for cleanup. && \
73-
chown -R jenkins:jenkins /source\""
68+
chown -R 9960:9960 /source\""
7469
}
7570

7671
node ("docker-light") {
@@ -84,9 +79,8 @@ node ("docker-light") {
8479
}
8580
stage("Build & Test") {
8681
withSonarQubeEnv {
87-
8882
versions.each { ver ->
89-
runSonnarForPythonVersion(sourceDir, ver)
83+
runSonarIfVersion(sourceDir, ver)
9084
}
9185
}
9286
}

DEVELOPER.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Modify `.rubocop_todo.yml` as you fix issues.
44
Generate a new config file with `rubocop --auto-gen-config` as needed.
55

66
```
7-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
7+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
88
apt-get update
99
apt-get install -y gcc make
1010
@@ -14,12 +14,32 @@ rubocop
1414
1515
```
1616

17+
#### Check dependencies for CVEs
18+
19+
This uses `bundler-audit`, which checks your `Gemfile.lock` against the RubySec advisory DB.
20+
21+
```
22+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
23+
apt-get update
24+
apt-get install -y gcc make git ca-certificates libyaml-dev
25+
26+
cd /source
27+
bundle install
28+
29+
gem install bundler-audit
30+
bundle audit update
31+
bundle audit check --verbose
32+
33+
```
34+
35+
36+
1737
#### Run tests locally
1838

1939
```
20-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
40+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
2141
apt-get update
22-
apt-get install -y gcc make
42+
apt-get install -y gcc make libyaml-dev
2343
2444
gem install rspec
2545
cd /source
@@ -31,7 +51,9 @@ rspec tests
3151
#### Run a single example
3252

3353
```
34-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
54+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
55+
apt-get update
56+
apt-get install -y gcc make libyaml-dev
3557
3658
cd /source
3759
bundle install
@@ -47,7 +69,9 @@ ruby ping.rb ${API_KEY}
4769
#### Run all examples
4870

4971
```
50-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
72+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
73+
apt-get update
74+
apt-get install -y gcc make libyaml-dev
5175
5276
cd /source
5377
bundle install

Gemfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
source 'https://rubygems.org'
44

5-
gem 'rdoc', '6.6.2'
6-
gem 'rubysl-securerandom', '2.0.0'
7-
8-
gem 'rspec', '3.12.0', group: [:test]
9-
gem 'simplecov', require: false, group: :test
10-
gem 'simplecov_json_formatter', require: false, group: :test
11-
gem 'webmock', '3.19.1', group: [:test]
5+
group :test do
6+
gem 'rspec'
7+
gem 'simplecov', require: false
8+
gem 'simplecov_json_formatter', require: false
9+
gem 'webmock'
10+
end

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016-2024 Basis Technology Corporation.
1+
Copyright (c) 2016-2026 Babel Street Rosette Ltd.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
<a href="https://www.babelstreet.com/rosette"><img src="https://s3.amazonaws.com/styleguide.basistech.com/logos/rosette-logo.png" width="181" height="47" /></a>
1+
<a href="https://www.babelstreet.com/modules">
2+
<img src="https://charts.babelstreet.com/icon.png" width="48" height="48" alt="Babel Street Logo"/>
3+
</a>
24

3-
---
5+
# Analytics by Babel Street
46

57
[![Gem Version](https://badge.fury.io/rb/rosette_api.svg)](https://badge.fury.io/rb/rosette_api)
68

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.
9+
Our product is a full text processing pipeline from data preparation to extracting the most relevant information and
10+
analysis utilizing precise, focused AI that has built-in human understanding. Text Analytics provides foundational
11+
linguistic analysis for identifying languages and relating words. The result is enriched and normalized text for
12+
high-speed search and processing without translation.
1213

13-
## Rosette API Access
14-
- Rosette Cloud [Sign Up](https://developer.rosette.com/signup)
14+
Text Analytics extracts events and entities — people, organizations, and places — from unstructured text and adds the
15+
structure of associating those entities into events that deliver only the necessary information for near real-time
16+
decision making. Accompanying tools shorten the process of training AI models to recognize domain-specific events.
17+
18+
The product delivers a multitude of ways to sharpen and expand search results. Semantic similarity expands search
19+
beyond keywords to words with the same meaning, even in other languages. Sentiment analysis and topic extraction help
20+
filter results to what’s relevant.
21+
22+
## Analytics API Access
23+
- Analytics Cloud [Sign Up](https://developer.babelstreet.com/signup)
1524

1625
## Quick Start
1726

@@ -20,16 +29,15 @@ comparing the similarity of names, categorizing and adding linguistic tags to te
2029
`gem install rosette_api`
2130

2231
#### Examples
23-
View small example programs for each Rosette endpoint
32+
View small example programs for each Analytics endpoint
2433
in the [examples](https://github.com/rosette-api/ruby/tree/develop/examples) directory.
2534

2635
#### Documentation & Support
2736
- [Binding API](https://rosette-api.github.io/ruby/)
28-
- [Rosette Platform API](https://developer.rosette.com/features-and-functions)
37+
- [Analytics Platform API](https://documentation.babelstreet.com/analytics)
2938
- [Binding Release Notes](https://github.com/rosette-api/ruby/wiki/Release-Notes)
30-
- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes)
31-
- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?ruby#)
32-
- [Support](https://support.rosette.com)
39+
- [Analytics Platform Release Notes](https://docs.babelstreet.com/r/Hosted-Services-Release-Notes)
40+
- [Support](https://babelstreet.my.site.com/support/s/contactsupport)
3341
- [Binding License: Apache 2.0](https://github.com/rosette-api/ruby/blob/develop/LICENSE)
3442

3543
## Binding Developer Information

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolcha
1313
```
1414
git clone git@github.com:rosette-api/ruby.git
1515
cd ruby
16-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
16+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
1717
1818
gem install rosette_api
1919
@@ -25,7 +25,7 @@ ruby ping.rb $API_KEY
2525
```
2626
git clone git@github.com:rosette-api/ruby.git
2727
cd ruby
28-
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
28+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.4-slim
2929
3030
cd /source
3131
gem build rosette_api.gemspec

examples/address_similarity.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# frozen_string_literal: true
22

3+
require 'json'
34
require 'rosette_api'
45

56
api_key, url = ARGV
67

7-
rosette_api = if url
8-
RosetteAPI.new(api_key, url)
9-
else
10-
RosetteAPI.new(api_key)
11-
end
8+
analytics_api = if url
9+
RosetteAPI.new(api_key, url)
10+
else
11+
RosetteAPI.new(api_key)
12+
end
1213

1314
begin
1415
address1 = AddressParameter.new(
@@ -20,7 +21,7 @@
2021
)
2122
address2 = '160 Pennsilvana Avenue, Washington, D.C., 20500'
2223
params = AddressSimilarityParameters.new(address1, address2)
23-
response = rosette_api.get_address_similarity(params)
24+
response = analytics_api.get_address_similarity(params)
2425
puts JSON.pretty_generate(response)
2526
rescue RosetteAPIError => e
2627
printf('Rosette API Error (%<status_code>s): %<message>s',

0 commit comments

Comments
 (0)