GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Updated README and version to `3.0.0-RC1` · einsnull/java-sdk@9679e97

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • build.gradle
  • examples/retrieve-and-rank-solrj
    • pom.xml
  • pom.xml
  • src
    • main/java/com/ibm/watson/developer_cloud/service
      • WatsonService.java
    • test/java/com/ibm/watson/developer_cloud/service
      • GenericServiceTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+85-25Lines changed: 85 additions & 25 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ APIs and SDKs that use cognitive computing to solve complex problems.
88

99

1010
## Table of Contents
11+
* [Breaking Changes for v3.0](#breaking-changes-for-v30)
1112
* [Installation](#installation)
1213
* [Maven](#maven)
1314
* [Gradle](#gradle)
@@ -38,24 +39,62 @@ APIs and SDKs that use cognitive computing to solve complex problems.
3839
* [License](#license)
3940
* [Contributing](#contributing)
4041

41-
## Installation
42+
## Breaking Changes for v3.0
43+
44+
The version 3.0.0-RC1 is a major release focused on simplicity and consistency. Several breaking changes were introduced.
45+
46+
### Synchronous vs Asynchronous
47+
48+
Before 3.0 all the API calls were synchonous
49+
```java
50+
List<Dialog> dialogs = dialogService.getDialogs();
51+
System.out.println(dialogs);
52+
```
53+
Now to do synchonous call you need to add `execute()`
54+
55+
```java
56+
List<Dialog> dialogs = dialogService.getDialogs().execute();
57+
System.out.println(dialogs);
58+
```
59+
To do asynchronous calls you need to specify a callback
60+
61+
```java
62+
List<Dialog> dialogs = dialogService.getDialogs().enqueue(new Callback<List<Dialog>() {
63+
@Override
64+
public void onFailure(Exception e) {
65+
66+
}
4267

43-
[![Download Jar](https://raw.githubusercontent.com/watson-developer-cloud/java-sdk/master/src/test/resources/download.png)][jar]
68+
@Override
69+
public void onResponse(List<Dialog> response) throws IOException {
70+
System.out.println(response);
71+
}
72+
}
73+
```
74+
75+
* Websocke requests are now using `okhttp-ws` instead of `nv-websocket-client`
76+
* Several deprecated services have been removed
77+
78+
## Installation
4479

4580
##### Maven
4681
```xml
4782
<dependency>
4883
<groupId>com.ibm.watson.developer_cloud</groupId>
4984
<artifactId>java-sdk</artifactId>
50-
<version>3.0.0</version>
85+
<version>3.0.0-RC1</version>
5186
</dependency>
5287
```
5388
##### Gradle
5489

5590
```gradle
56-
'com.ibm.watson.developer_cloud:java-sdk:3.0.0'
91+
'com.ibm.watson.developer_cloud:java-sdk:3.0.0-RC1'
5792
```
5893

94+
##### JAR
95+
96+
Download the jar file [here][jar].
97+
5998
Now, you are ready to see some [examples](https://github.com/watson-developer-cloud/java-sdk/tree/master/examples/java/com/ibm/watson/developer_cloud).
6099

61100
## Usage
@@ -106,7 +145,7 @@ service.setApiKey("<api_key>");
106145
107146
Map<String,Object> params = new HashMap<String, Object>();
108147
params.put(AlchemyLanguage.TEXT, "IBM Watson won the Jeopardy television show hosted by Alex Trebek");
109-
DocumentSentiment sentiment = service.getSentiment(params);
148+
DocumentSentiment sentiment = service.getSentiment(params).execute();
110149
111150
System.out.println(sentiment);
112151
```
@@ -123,7 +162,7 @@ service.setApiKey("<api_key>");
123162
File image = new File("src/test/resources/alchemy/obama.jpg");
124163
Boolean forceShowAll = false;
125164
Boolean knowledgeGraph = false;
126-
ImageKeywords keywords = service.getImageKeywords(image, forceShowAll, knowledgeGraph);
165+
ImageKeywords keywords = service.getImageKeywords(image, forceShowAll, knowledgeGraph).execute();
127166

128167
System.out.println(keywords);
129168
```
@@ -148,7 +187,7 @@ params.put(AlchemyDataNews.START, "1440720000");
148187
params.put(AlchemyDataNews.END, "1441407600");
149188
params.put(AlchemyDataNews.COUNT, 7);
150189

151-
DocumentsResult result = service.getNewsDocuments(params);
190+
DocumentsResult result = service.getNewsDocuments(params).execute();
152191

153192
System.out.println(result);
154193
```
@@ -162,7 +201,8 @@ ConceptInsights service = new ConceptInsights();
162201
service.setUsernameAndPassword("<username>", "<password>");
163202

164203
Annotations annotations = service.annotateText(Graph.WIKIPEDIA,
165-
"IBM Watson won the Jeopardy television show hosted by Alex Trebek");
204+
"IBM Watson won the Jeopardy television show hosted by Alex Trebek")
205+
.execute();
166206

167207
System.out.println(annotations);
168208
```
@@ -174,7 +214,7 @@ Returns the dialog list using the [Dialog][dialog] service.
174214
DialogService service = new DialogService();
175215
service.setUsernameAndPassword("<username>", "<password>");
176216

177-
List<Dialog> dialogs = service.getDialogs();
217+
List<Dialog> dialogs = service.getDialogs().execute();
178218
System.out.println(dialogs);
179219
```
180220

@@ -188,7 +228,7 @@ DocumentConversion service = new DocumentConversion("2015-12-01");
188228
service.setUsernameAndPassword("<username>", "<password>");
189229

190230
File doc = new File("src/test/resources/document_conversion/word-document-heading-input.doc");
191-
Answers htmlToAnswers = service.convertDocumentToAnswer(doc);
231+
Answers htmlToAnswers = service.convertDocumentToAnswer(doc).execute();
192232
System.out.println(htmlToAnswers);
193233
```
194234

@@ -200,7 +240,10 @@ Example: Translate 'hello' from English to Spanish using the [Language Translati
200240
LanguageTranslation service = new LanguageTranslation();
201241
service.setUsernameAndPassword("<username>", "<password>");
202242

203-
TranslationResult translationResult = service.translate("hello", "en", "es");
243+
TranslationResult translationResult = service.translate(
244+
"hello", Language.ENGLISH, Language.SPANISH)
245+
.execute();
246+
204247
System.out.println(translationResult);
205248
```
206249

@@ -211,7 +254,7 @@ Use [Natural Language Classifier](http://www.ibm.com/smarterplanet/us/en/ibmwats
211254
NaturalLanguageClassifier service = new NaturalLanguageClassifier();
212255
service.setUsernameAndPassword("<username>", "<password>");
213256

214-
Classification classification = service.classify("<classifier-id>", "Is it sunny?");
257+
Classification classification = service.classify("<classifier-id>", "Is it sunny?").execute();
215258
System.out.println(classification);
216259
```
217260

@@ -244,7 +287,7 @@ String text = "Call me Ishmael. Some years ago-never mind how long precisely-hav
244287
+ "city of the Manhattoes, belted round by wharves as Indian isles by coral reefs-commerce surrounds "
245288
+ "it with her surf. Right and left, the streets take you waterward.";
246289

247-
Profile profile = service.getProfile(text);
290+
Profile profile = service.getProfile(text).execute();
248291
System.out.println(profile);
249292
```
250293

@@ -263,7 +306,7 @@ RelationshipExtraction service = new RelationshipExtraction();
263306
service.setUsernameAndPassword("<username>", "<password>");
264307
265308
service.setDataset(Dataset.ENGLISH_NEWS);
266-
String response = service.extract("IBM Watson Developer Cloud");
309+
String response = service.extract("IBM Watson Developer Cloud").execute();
267310
System.out.println(response);
268311
```
269312
@@ -280,13 +323,13 @@ service.setUsernameAndPassword("<username>", "<password>");
280323
281324
// 1 create the Solr Cluster
282325
SolrClusterOptions options = new SolrClusterOptions("my-cluster-name", 1);
283-
SolrCluster cluster = service.createSolrCluster(options);
326+
SolrCluster cluster = service.createSolrCluster(options).execute();
284327
System.out.println("Solr cluster: " + cluster);
285328
286329
// 2 wait until the Solr Cluster is available
287330
while (cluster.getStatus() == Status.NOT_AVAILABLE) {
288331
Thread.sleep(10000); // sleep 10 seconds
289-
cluster = service.getSolrCluster(cluster.getId());
332+
cluster = service.getSolrCluster(cluster.getId()).execute();
290333
System.out.println("Solr cluster status: " + cluster.getStatus());
291334
}
292335
@@ -306,7 +349,7 @@ service.setUsernameAndPassword("<username>", "<password>");
306349
307350
File audio = new File("src/test/resources/sample1.wav");
308351
309-
SpeechResults transcript = service.recognize(audio, HttpMediaType.AUDIO_WAV);
352+
SpeechResults transcript = service.recognize(audio, HttpMediaType.AUDIO_WAV).execute();
310353
System.out.println(transcript);
311354
```
312355
@@ -315,7 +358,24 @@ System.out.println(transcript);
315358
Speech to Text supports WebSocket, the url is:
316359
`wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize`
317360
318-
We recommend you use [this](http://java-websocket.org/) java client.
361+
```java
362+
SpeechToText service = new SpeechToText();
363+
service.setUsernameAndPassword("<username>", "<password>");
364+
365+
File audio = new File("src/test/resources/sample1.wav");
366+
367+
RecognizeOptions options = new RecognizeOptions();
368+
options.continuous(true).interimResults(true).contentType(HttpMediaType.AUDIO_WAV);
369+
370+
service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
371+
@Override
372+
public void onTranscription(SpeechResults speechResults) {
373+
System.out.println(speechResults);
374+
}
375+
);
376+
// wait 20 seconds for the asynchronous response
377+
Thread.sleep(20000);
378+
```
319379
320380
### Text to Speech
321381
Use the [Text to Speech][text_to_speech] service to get the available voices to synthesize.
@@ -324,7 +384,7 @@ Use the [Text to Speech][text_to_speech] service to get the available voices to
324384
TextToSpeech service = new TextToSpeech();
325385
service.setUsernameAndPassword("<username>", "<password>");
326386
327-
List<Voice> voices = service.getVoices();
387+
List<Voice> voices = service.getVoices().execute();
328388
System.out.println(voices);
329389
```
330390
@@ -348,7 +408,7 @@ String text =
348408
+ "business outcomes. Economy has nothing to do with it.";
349409
350410
// Call the service and get the tone
351-
ToneAnalysis tone = service.getTone(text);
411+
ToneAnalysis tone = service.getTone(text).execute();
352412
System.out.println(tone);
353413
```
354414
@@ -398,7 +458,7 @@ optimusSpecs.put(screen, 5);
398458
options.add(new Option("3", "LG Optimus G").withValues(optimusSpecs));
399459
400460
// Call the service and get the resolution
401-
Dilemma dilemma = service.dilemmas(problem);
461+
Dilemma dilemma = service.dilemmas(problem).execute();
402462
System.out.println(dilemma);
403463
```
404464
@@ -410,7 +470,7 @@ VisualInsights service = new VisualInsights();
410470
service.setUsernameAndPassword("<username>", "<password>");
411471
412472
File images = new File("src/test/resources/visual_insights/images.zip");
413-
Summary summary = service.getSummary(images);
473+
Summary summary = service.getSummary(images).execute();
414474
415475
System.out.println(summary);
416476
```
@@ -427,7 +487,7 @@ service.setUsernameAndPassword("<username>", "<password>");
427487
428488
File image = new File("src/test/resources/visual_recognition/car.png");
429489
430-
VisualRecognitionImages recognizedImage = service.recognize(image);
490+
VisualRecognitionImages recognizedImage = service.recognize(image).execute();
431491
System.out.println(recognizedImage);
432492
```
433493
@@ -454,7 +514,7 @@ Gradle:
454514
455515
```sh
456516
$ cd java-sdk
457-
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.0.0.jar)
517+
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.0.0-RC1.jar)
458518
$ gradle test # run tests
459519
```
460520
@@ -524,4 +584,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
524584
[apache_maven]: http://maven.apache.org/
525585
[releases]: https://github.com/watson-developer-cloud/java-sdk/releases
526586
527-
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-3.0.0/java-sdk-3.0.0-jar-with-dependencies.jar
587+
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-3.0.0-RC1/java-sdk-3.0.0-RC1-jar-with-dependencies.jar
Collapse file

‎build.gradle‎

Copy file name to clipboardExpand all lines: build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sourceCompatibility = 1.6
77
targetCompatibility = 1.6
88
group = 'com.ibm.watson.developercloud'
99
archivesBaseName = 'watson-developer-cloud'
10-
version = '3.0.0'
10+
version = '3.0.0-RC1'
1111

1212
description = 'Client library to use the IBM Watson Services and AlchemyAPI'
1313

Collapse file

‎examples/retrieve-and-rank-solrj/pom.xml‎

Copy file name to clipboardExpand all lines: examples/retrieve-and-rank-solrj/pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<dependency>
2828
<groupId>com.ibm.watson.developer_cloud</groupId>
2929
<artifactId>java-sdk</artifactId>
30-
<version>3.0.0</version>
30+
<version>3.0.0-RC1</version>
3131
</dependency>
3232
</dependencies>
3333
</project>
Collapse file

‎pom.xml‎

Copy file name to clipboardExpand all lines: pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.ibm.watson.developer_cloud</groupId>
6-
<version>3.0.0-SNAPSHOT</version>
6+
<version>3.0.0-RC1-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<artifactId>java-sdk</artifactId>
99
<name>Watson Developer Cloud Java SDK</name>
Collapse file

‎src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public String getName() {
276276
* @return the user agent
277277
*/
278278
private String getUserAgent() {
279-
return "watson-developer-cloud-java-sdk-3.0.0";
279+
return "watson-developer-cloud-java-sdk-3.0.0-RC1";
280280
}
281281

282282
/**
Collapse file

‎src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,6 @@ public void testUserAgentIsSet() {
214214
mockAPICall();
215215
service.getProfile(sampleText).execute();
216216
mockServer.verify(new HttpRequest().withMethod("POST").withHeader(
217-
new Header(HttpHeaders.USER_AGENT, "watson-developer-cloud-java-sdk-3.0.0")));
217+
new Header(HttpHeaders.USER_AGENT, "watson-developer-cloud-java-sdk-3.0.0-RC1")));
218218
}
219219
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.