Skip to content

Commit 441b338

Browse files
cp2bostonseth-mg
authored andcommitted
RCB-542 1.9 release (#118)
* Added java.version to User-Agent * WS-1272 Multilingual Example * Example updates
1 parent 55e3cb7 commit 441b338

File tree

7 files changed

+63
-6
lines changed

7 files changed

+63
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class HttpRosetteAPI extends AbstractRosetteAPI {
8282
public static final String DEFAULT_URL_BASE = "https://api.rosette.com/rest/v1";
8383
public static final String SERVICE_NAME = "RosetteAPI";
8484
public static final String BINDING_VERSION = getVersion();
85-
public static final String USER_AGENT_STR = SERVICE_NAME + "-Java/" + BINDING_VERSION;
85+
public static final String USER_AGENT_STR = SERVICE_NAME + "-Java/" + BINDING_VERSION + "/" + System.getProperty("java.version");
8686
private static final Logger LOG = LoggerFactory.getLogger(HttpRosetteAPI.class);
8787
private String urlBase = DEFAULT_URL_BASE;
8888
private int failureRetries = 1;

examples/src/main/java/com/basistech/rosette/examples/EntitiesExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void main(String[] args) {
3535
}
3636

3737
private void run() throws IOException {
38-
String entitiesTextData = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
38+
String entitiesTextData = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country.";
3939
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4040
.key(getApiKeyFromSystemProperty())
4141
.url(getAltUrlFromSystemProperty())
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2014 Basis Technology Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.basistech.rosette.examples;
17+
18+
import com.basistech.rosette.api.HttpRosetteAPI;
19+
import com.basistech.rosette.apimodel.DocumentRequest;
20+
import com.basistech.rosette.apimodel.LanguageOptions;
21+
import com.basistech.rosette.apimodel.LanguageResponse;
22+
23+
import java.io.IOException;
24+
25+
/**
26+
* Example which demonstrates the language detection api with the multilingual option.
27+
*/
28+
public final class LanguageMultilingualExample extends ExampleBase {
29+
public static void main(String[] args) {
30+
try {
31+
new LanguageMultilingualExample().run();
32+
} catch (Exception e) {
33+
e.printStackTrace();
34+
System.exit(1);
35+
}
36+
}
37+
38+
private void run() throws IOException {
39+
String languageMultilingualData = "On Thursday, as protesters gathered in Washington D.C., the United States Federal Communications Commission under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly called Net Neutrality, that forbade Internet service providers (ISPs) such as Verizon, Comcast, and AT&T from blocking individual websites or charging websites or customers more for faster load times. Quatre femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.";
40+
41+
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
42+
.key(getApiKeyFromSystemProperty())
43+
.url(getAltUrlFromSystemProperty())
44+
.build();
45+
//The api object creates an http client, but to provide your own:
46+
//rosetteApi.httpClient(CloseableHttpClient)
47+
48+
LanguageOptions options = LanguageOptions.builder().multilingual(true).build();
49+
50+
DocumentRequest<LanguageOptions> request = DocumentRequest.<LanguageOptions>builder()
51+
.content(languageMultilingualData)
52+
.options(options)
53+
.build();
54+
LanguageResponse response = rosetteApi.perform(HttpRosetteAPI.LANGUAGE_SERVICE_PATH, request, LanguageResponse.class);
55+
System.out.println(responseToJson(response));
56+
}
57+
}

examples/src/main/java/com/basistech/rosette/examples/MorphologyCompleteExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void main(String[] args) {
3737
}
3838

3939
private void run() throws IOException {
40-
String morphologyCompleteData = "The quick brown fox jumped over the lazy dog. Yes he did.";
40+
String morphologyCompleteData = "The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)";
4141

4242
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4343
.key(getApiKeyFromSystemProperty())

examples/src/main/java/com/basistech/rosette/examples/RelationshipsExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void main(String[] args) {
3636
}
3737

3838
private void run() throws IOException {
39-
String relationshipsTextData = "Bill Gates, Microsoft's former CEO, is a philanthropist.";
39+
String relationshipsTextData = "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems. According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008. Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials. At the time, Timms was the head of FLIR’s Middle East office in Dubai.";
4040

4141
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4242
.key(getApiKeyFromSystemProperty())

examples/src/main/java/com/basistech/rosette/examples/SentencesExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void main(String[] args) {
3535
}
3636

3737
private void run() throws IOException {
38-
String sentencesData = "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.";
38+
String sentencesData = "This land is your land. This land is my land, from California to the New York island; from the red wood forest to the Gulf Stream waters. This land was made for you and Me. As I was walking that ribbon of highway, I saw above me that endless skyway: I saw below me that golden valley: This land was made for you and me.";
3939

4040
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4141
.key(getApiKeyFromSystemProperty())

examples/src/main/java/com/basistech/rosette/examples/TransliterationExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void main(String[] args) {
3737
}
3838

3939
private void run() throws IOException {
40-
String transliterationData = "haza ya7taj fakat ila an takoun ba3dh el-nousous allati na7n ymkn an tata7awal ila al-3arabizi.";
40+
String transliterationData = "ana r2ye7 el gam3a el sa3a 3 el 3asr";
4141

4242
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4343
.key(getApiKeyFromSystemProperty())

0 commit comments

Comments
 (0)