Skip to content

Commit 753ada0

Browse files
authored
Merge pull request #267 from rosette-api/WS-3314-update-key-header-and-urls
Ws 3314 update key header and urls
2 parents 0b04278 + bf37405 commit 753ada0

File tree

55 files changed

+262
-196
lines changed

Some content is hidden

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

55 files changed

+262
-196
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
<a href="https://www.babelstreet.com/rosette"><img src="https://charts.babelstreet.com/icon.png" width="47" height="60"/></a>
2-
# Rosette by Babel Street
1+
<a href="https://www.babelstreet.com/rosette">
2+
<picture>
3+
<source media="(prefers-color-scheme: light)" srcset="https://charts.babelstreet.com/icon-dark.png">
4+
<source media="(prefers-color-scheme: dark)" srcset="https://charts.babelstreet.com/icon-light.png">
5+
<img alt="Babel Street Logo" width="48" height="48">
6+
</picture>
7+
</a>
8+
9+
# Analytics by Babel Street
310

411
---
512

613
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.basistech.rosette/rosette-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.basistech.rosette/rosette-api-java-binding)
714

8-
Rosette uses natural language processing, statistical modeling, and machine learning to analyze unstructured and semi-structured text across hundreds of language-script combinations, revealing valuable information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and comparing the similarity of names, categorizing and adding linguistic tags to text and more. Rosette Server is the on-premises installation of Rosette, with access to Rosette's functions as RESTful web service endpoints. This solves cloud security worries and allows customization (models/indexes) as needed for your business.
15+
Our product is a full text processing pipeline from data preparation to extracting the most relevant information and
16+
analysis utilizing precise, focused AI that has built-in human understanding. Text Analytics provides foundational
17+
linguistic analysis for identifying languages and relating words. The result is enriched and normalized text for
18+
high-speed search and processing without translation.
19+
20+
Text Analytics extracts events and entities — people, organizations, and places — from unstructured text and adds the
21+
structure of associating those entities into events that deliver only the necessary information for near real-time
22+
decision making. Accompanying tools shorten the process of training AI models to recognize domain-specific events.
923

24+
The product delivers a multitude of ways to sharpen and expand search results. Semantic similarity expands search
25+
beyond keywords to words with the same meaning, even in other languages. Sentiment analysis and topic extraction help
26+
filter results to what’s relevant.
1027

11-
## Rosette API Access
12-
- Rosette Cloud [Sign Up](https://developer.rosette.com/signup)
28+
## Analytics API Access
29+
- Analytics Cloud [Sign Up](https://developer.babelstreet.com/signup)
1330
## Quick Start
1431

1532
#### Maven
@@ -26,17 +43,17 @@ in the Maven Central badge at the top of this page.
2643

2744
#### Test Releases
2845
Versions, of the form `x.y.z`, where `z` is greater than or equal to `100`, are internal testing versions. Do not use
29-
them without consultation with Basis Technology Corp.
46+
them without consultation with Babel Street.
3047

3148
#### Examples
32-
View small example programs for each Rosette endpoint in the
49+
View small example programs for each Analytics endpoint in the
3350
[examples](examples/src/main/java/com/basistech/rosette/examples) directory.
3451

3552
#### Documentation & Support
3653
- [Binding API](https://rosette-api.github.io/java/)
37-
- [Rosette Platform API](https://docs.babelstreet.com/API/en/index-en.html)
54+
- [Analytics Platform API](https://docs.babelstreet.com/API/en/index-en.html)
3855
- [Binding Release Notes](https://github.com/rosette-api/java/wiki/Release-Notes)
39-
- [Rosette Platform Release Notes](https://babelstreet.my.site.com/support/s/article/Rosette-Cloud-Release-Notes)
56+
- [Analytics Platform Release Notes](https://docs.babelstreet.com/Release/en/rosette-cloud.html)
4057
- [Support](https://babelstreet.my.site.com/support/s/)
4158
- [Binding License: Apache 2.0](LICENSE.txt)
4259

all/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</parent>
2424
<artifactId>rosette-api-all</artifactId>
2525
<name>rosette-api-all</name>
26-
<description>Rosette API all modules combined</description>
26+
<description>Babel Street Analytics API all modules combined</description>
2727
<dependencies>
2828
<dependency>
2929
<groupId>com.basistech</groupId>

annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</parent>
2424
<artifactId>rosette-api-annotations</artifactId>
2525
<name>rosette-api-annotations</name>
26-
<description>Rosette API Annotations</description>
26+
<description>Babel Street Analytics API Annotations</description>
2727
<dependencies>
2828
<dependency>
2929
<groupId>com.fasterxml.jackson.core</groupId>

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</parent>
2424
<artifactId>rosette-api</artifactId>
2525
<name>rosette-api</name>
26-
<description>Rosette API Communications</description>
26+
<description>Babel Street Analytics API Communications</description>
2727
<properties>
2828
<skip-mockserver>false</skip-mockserver>
2929
</properties>

api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 Basis Technology Corp.
2+
* Copyright 2024 Basis Technology Corp.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -79,17 +79,17 @@
7979
import static java.net.HttpURLConnection.HTTP_OK;
8080

8181
/**
82-
* Access to the RosetteAPI via HTTP.
82+
* Access to the Analytics API via HTTP.
8383
*/
8484
public class HttpRosetteAPI extends AbstractRosetteAPI {
8585

86-
public static final String DEFAULT_URL_BASE = "https://api.rosette.com/rest/v1";
87-
public static final String SERVICE_NAME = "RosetteAPI";
86+
public static final String DEFAULT_URL_BASE = "https://analytics.babelstreet.com/rest/v1";
87+
public static final String SERVICE_NAME = "Babel-Street-Analytics-API";
8888
public static final String BINDING_VERSION = getVersion();
8989
public static final String USER_AGENT_STR = SERVICE_NAME + "-Java/" + BINDING_VERSION + "/"
9090
+ System.getProperty("java.version");
9191
private static final Logger LOG = LoggerFactory.getLogger(HttpRosetteAPI.class);
92-
private static final String IO_EXCEPTION_MESSAGE = "IO Exception communicating with the Rosette API";
92+
private static final String IO_EXCEPTION_MESSAGE = "IO Exception communicating with the Babel Street Analytics API";
9393
private static final Pattern TRAILING_SLASHES = Pattern.compile("/+$");
9494
private String urlBase = DEFAULT_URL_BASE;
9595
private int failureRetries = 1;
@@ -104,16 +104,16 @@ private HttpRosetteAPI() {
104104
}
105105

106106
/**
107-
* Constructs a Rosette API instance using the builder syntax.
107+
* Constructs an Analytics API instance using the builder syntax.
108108
*
109-
* @param key Rosette API key. This may be null for use with an on-premise deployment
110-
* of the Rosette API.
111-
* @param urlToCall Alternate Rosette API URL. {@code null} uses the default, public, URL.
109+
* @param key Analytics API key. This may be null for use with an on-premise deployment
110+
* of the Analytics API.
111+
* @param urlToCall Alternate Analytics API URL. {@code null} uses the default, public, URL.
112112
* @param failureRetries Number of times to retry in case of failure; {@code null} uses the
113113
* default value: 1.
114114
* @param connectionConcurrency Number of concurrent connections. Pass this if have subscribed
115115
* to a plan that supports enhanced concurrency, or if you are using
116-
* an on-premise deployment of the Rosette API. {@code null} uses the
116+
* an on-premise deployment of the Analytics API. {@code null} uses the
117117
* default value: 2.
118118
* @throws HttpRosetteAPIException Problem with the API request
119119
*/
@@ -197,7 +197,10 @@ private void initHeaders(String key, List<Header> additionalHeaders) {
197197
this.additionalHeaders.add(new BasicHeader(HttpHeaders.USER_AGENT, USER_AGENT_STR));
198198
this.additionalHeaders.add(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"));
199199
if (key != null) {
200-
this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Key", key));
200+
this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Key", key));
201+
this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Binding", "java"));
202+
this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Binding-Version", BINDING_VERSION));
203+
// TODO: Remove in a future release.
201204
this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Binding", "java"));
202205
this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Binding-Version", BINDING_VERSION));
203206
}
@@ -216,32 +219,32 @@ public int getFailureRetries() {
216219
}
217220

218221
/**
219-
* Gets information about the Rosette API, returns name, version, build number and build time.
222+
* Gets information about the Analytics API, returns name, version, build number and build time.
220223
*
221224
* @return InfoResponse
222-
* @throws HttpRosetteAPIException Rosette specific exception
225+
* @throws HttpRosetteAPIException Analytics specific exception
223226
* @throws IOException General IO exception
224227
*/
225228
public InfoResponse info() throws IOException, HttpRosetteAPIException {
226229
return sendGetRequest(urlBase + INFO_SERVICE_PATH, InfoResponse.class);
227230
}
228231

229232
/**
230-
* Pings the Rosette API for a response indicating that the service is available.
233+
* Pings the Analytics API for a response indicating that the service is available.
231234
*
232235
* @return PingResponse
233-
* @throws HttpRosetteAPIException Rosette specific exception
236+
* @throws HttpRosetteAPIException Analytics specific exception
234237
* @throws IOException General IO exception
235238
*/
236239
public PingResponse ping() throws IOException, HttpRosetteAPIException {
237240
return sendGetRequest(urlBase + PING_SERVICE_PATH, PingResponse.class);
238241
}
239242

240243
/**
241-
* Gets the set of language and script codes supported by the specified Rosette API endpoint.
244+
* Gets the set of language and script codes supported by the specified Analytics API endpoint.
242245
*
243246
* @return SupportedLanguagesResponse
244-
* @throws HttpRosetteAPIException for an error returned from the Rosette API.
247+
* @throws HttpRosetteAPIException for an error returned from the Analytics API.
245248
*/
246249
@Override
247250
public SupportedLanguagesResponse getSupportedLanguages(String endpoint) throws HttpRosetteAPIException {
@@ -254,12 +257,12 @@ public SupportedLanguagesResponse getSupportedLanguages(String endpoint) throws
254257
}
255258

256259
/**
257-
* Gets the set of language, script codes and transliteration scheme pairs supported by the specified Rosette API
260+
* Gets the set of language, script codes and transliteration scheme pairs supported by the specified Analytics API
258261
* endpoint.
259262
*
260-
* @param endpoint Rosette API endpoint.
263+
* @param endpoint Analytics API endpoint.
261264
* @return SupportedLanguagePairsResponse
262-
* @throws HttpRosetteAPIException for an error returned from the Rosette API.
265+
* @throws HttpRosetteAPIException for an error returned from the Analytics API.
263266
*/
264267
@Override
265268
public SupportedLanguagePairsResponse getSupportedLanguagePairs(String endpoint) throws HttpRosetteAPIException {
@@ -279,7 +282,7 @@ public SupportedLanguagePairsResponse getSupportedLanguagePairs(String endpoint)
279282
* @param <RequestType> the type of the request object.
280283
* @param <ResponseType> the type of the response object.
281284
* @return the response.
282-
* @throws HttpRosetteAPIException for an error returned from the Rosette API.
285+
* @throws HttpRosetteAPIException for an error returned from the Analytics API.
283286
* @throws RosetteRuntimeException for other errors, such as communications problems with HTTP.
284287
*/
285288
@Override
@@ -300,7 +303,7 @@ public <RequestType extends Request, ResponseType extends Response> ResponseType
300303
* @param request the data for the request.
301304
* @param <RequestType> the type of the request object.
302305
* @return the response, {@link com.basistech.rosette.dm.AnnotatedText}.
303-
* @throws HttpRosetteAPIException for an error returned from the Rosette API.
306+
* @throws HttpRosetteAPIException for an error returned from the Analytics API.
304307
* @throws RosetteRuntimeException for other errors, such as communications problems with HTTP.
305308
*/
306309
@Override
@@ -326,11 +329,11 @@ public <RequestType extends Request> AnnotatedText perform(String endpoint, Requ
326329
}
327330

328331
/**
329-
* Sends a GET request to Rosette API.
332+
* Sends a GET request to Analytics API.
330333
* <p>
331334
* Returns a Response.
332335
*
333-
* @param urlStr Rosette API end point.
336+
* @param urlStr Analytics API end point.
334337
* @param clazz Response class
335338
* @return Response
336339
* @throws HttpRosetteAPIException
@@ -351,11 +354,11 @@ private <T extends Response> T sendGetRequest(String urlStr, Class<T> clazz) thr
351354
}
352355

353356
/**
354-
* Sends a POST request to Rosette API.
357+
* Sends a POST request to Analytics API.
355358
* <p>
356359
* Returns a Response.
357360
*
358-
* @param urlStr Rosette API end point.
361+
* @param urlStr Analytics API end point.
359362
* @param clazz Response class
360363
* @return Response
361364
* @throws IOException
@@ -401,10 +404,15 @@ private <T> T sendPostRequest(Object request, String urlStr, Class<T> clazz)
401404
while (numRetries-- > 0) {
402405
try (CloseableHttpResponse response = httpClient.execute(post)) {
403406
T resp = getResponse(response, clazz);
407+
// TODO: Remove in a future release
404408
Header ridHeader = response.getFirstHeader("X-RosetteAPI-DocumentRequest-Id");
405409
if (ridHeader != null && ridHeader.getValue() != null) {
406410
LOG.debug("DocumentRequest ID {}", ridHeader.getValue());
407411
}
412+
Header bsidHeader = response.getFirstHeader("X-BabelStreetAPI-DocumentRequest-Id");
413+
if (bsidHeader != null && bsidHeader.getValue() != null) {
414+
LOG.debug("DocumentRequest ID {}", bsidHeader.getValue());
415+
}
408416
if (resp instanceof Response) {
409417
responseHeadersToExtendedInformation((Response)resp, response);
410418
}
@@ -556,21 +564,37 @@ private <T extends Object> T getResponse(HttpResponse httpResponse, Class<T> cla
556564
InputStream stream = httpResponse.getEntity().getContent();
557565
InputStream inputStream = "gzip".equalsIgnoreCase(encoding) ? new GZIPInputStream(stream) : stream) {
558566
String ridHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-DocumentRequest-Id"));
567+
String bsidHeader = headerValueOrNull(httpResponse.getFirstHeader("X-BabelStreetAPI-DocumentRequest-Id"));
559568
if (HTTP_OK != status) {
560-
String ecHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Code"));
561-
String emHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Message"));
569+
String ecHeader;
570+
if (headerValueOrNull(httpResponse.getFirstHeader("X-BabelStreetAPI-Status-Code")) != null) {
571+
ecHeader = headerValueOrNull(httpResponse.getFirstHeader("X-BabelStreetAPI-Status-Code"));
572+
} else {
573+
// TODO: Remove in a future release
574+
ecHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Code"));
575+
}
576+
String emHeader;
577+
if (headerValueOrNull(httpResponse.getFirstHeader("X-BabelStreetAPI-Status-Message")) != null) {
578+
emHeader = headerValueOrNull(httpResponse.getFirstHeader("X-BabelStreetAPI-Status-Message"));
579+
} else {
580+
// TODO: Remove in a future release
581+
emHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Message"));
582+
}
562583
String responseContentType = headerValueOrNull(httpResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE));
563584
if ("application/json".equals(responseContentType)) {
564585
ErrorResponse errorResponse = mapper.readValue(inputStream, ErrorResponse.class);
565586
if (ridHeader != null) {
566587
LOG.debug("DocumentRequest ID {}", ridHeader);
567588
}
589+
if (bsidHeader != null) {
590+
LOG.debug("DocumentRequest ID {}", bsidHeader);
591+
}
568592
if (ecHeader != null) {
569593
errorResponse.setCode(ecHeader);
570594
}
571595
if (429 == status) {
572596
String concurrencyMessage = "You have exceeded your plan's limit on concurrent calls. "
573-
+ "This could be caused by multiple processes or threads making Rosette API calls "
597+
+ "This could be caused by multiple processes or threads making Analytics API calls "
574598
+ "in parallel, or if your httpClient is configured with higher concurrency "
575599
+ "than your plan allows.";
576600
if (emHeader == null) {

api/src/main/java/com/basistech/rosette/api/MorphologicalFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 Basis Technology Corp.
2+
* Copyright 2024 Basis Technology Corp.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
package com.basistech.rosette.api;
1818

1919
/**
20-
* Specify which feature you want Rosette API Morphology endpoint to return. Specify COMPLETE for every feature.
20+
* Specify which feature you want Analytics API Morphology endpoint to return. Specify COMPLETE for every feature.
2121
*/
2222
public enum MorphologicalFeature {
2323
COMPLETE("complete"),

api/src/test/java/com/basistech/rosette/api/BasicTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 Basis Technology Corp.
2+
* Copyright 2024 Basis Technology Corp.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@ void testHeaders() throws Exception {
138138
.withHeader(HttpHeaders.USER_AGENT, HttpRosetteAPI.USER_AGENT_STR))
139139
.respond(HttpResponse.response()
140140
.withHeader("Content-Type", "application/json")
141-
.withHeader("X-RosetteAPI-Concurrency", "5")
141+
.withHeader("X-BabelStreetAPI-Concurrency", "5")
142142
.withStatusCode(200)
143143
.withBody("{\"message\":\"Rosette API at your service\",\"time\":1461788498633}", StandardCharsets.UTF_8));
144144

@@ -148,7 +148,7 @@ void testHeaders() throws Exception {
148148
.additionalHeader("X-Foo", "Bar")
149149
.build();
150150
var resp = api.ping();
151-
assertEquals("5", resp.getExtendedInformation().get("X-RosetteAPI-Concurrency"));
151+
assertEquals("5", resp.getExtendedInformation().get("X-BabelStreetAPI-Concurrency"));
152152
}
153153

154154
@Test
@@ -185,7 +185,7 @@ void testExtendedInfo() throws Exception {
185185
.withHeader("Content-Type", "application/json")
186186
.withHeader("X-Foo", "Bar")
187187
.withHeader("X-FooMulti", "Bar1", "Bar2")
188-
.withHeader("X-RosetteAPI-Concurrency", "5")
188+
.withHeader("X-BabelStreetAPI-Concurrency", "5")
189189
.withBody("{\"message\":\"Rosette API at your service\",\"time\":1461788498633}", StandardCharsets.UTF_8));
190190
api = new HttpRosetteAPI.Builder()
191191
.key("foo-key")

0 commit comments

Comments
 (0)