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 — Switch to okhttp 3 for HTTP and WS · einsnull/java-sdk@1d2f74b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • build.gradle
  • examples
    • java/com/ibm/watson/developer_cloud
      • alchemy_data_news/v1
        • GetNewsDocumentExample.java
      • alchemy_language/v1
        • AlchemyLanguageExample.java
      • retrieve_and_rank/v1
        • CreateASolrClusterExample.java
      • speech_to_text/v1
        • RecognizeUsingWebSocketsExample.java
      • text_to_speech/v1
        • TextToSpeechExample.java
        • TranslateAndSynthesizeExample.java
      • tradeoff_analytics/v1
        • TradeoffAnalyticsExample.java
    • retrieve-and-rank-solrj
      • pom.xml
  • pom.xml
  • src
    • main
      • java/com/ibm/watson/developer_cloud
        • alchemy/v1
          • AlchemyDataNews.java
          • AlchemyLanguage.java
          • AlchemyVision.java
          • model
            • AlchemyLanguageGenericModel.java
            • Article.java
            • DocumentAuthors.java
            • ImageKeyword.java
            • ImageSceneText.java
            • ImageSceneTextLine.java
            • LanguageSelection.java
          • util
            • AlchemyEndPoints.java
            • ImageKeywordTypeAdapter.java
            • PublicationDateTypeAdapter.java
            • TaxonomyTypeAdapter.java
        • concept_insights/v2
          • ConceptInsights.java
          • model
            • Account.java
            • AccountPermission.java
            • Accounts.java
            • Annotation.java
            • Annotations.java
            • BuildStatus.java
            • ConceptMetadata.java
            • Concepts.java
            • Corpora.java
            • Corpus.java
            • CorpusProcessingState.java
            • CorpusStats.java
            • Document.java
            • DocumentAnnotations.java
            • DocumentProcessingStatus.java
            • Documents.java
            • Graph.java
            • Graphs.java
            • Matches.java
            • Part.java
            • QueryConcepts.java
            • RequestedFields.java
            • Result.java
            • Score.java
            • ScoredConcept.java
            • Scores.java
            • Tag.java
            • TopTags.java
          • util
            • IDHelper.java
        • dialog/v1
          • DialogService.java
          • model
            • Conversation.java
            • ConversationData.java
            • ConversationDataOptions.java
            • DialogContent.java
            • HitNode.java
            • Message.java
            • NameValue.java
        • document_conversion/v1
          • DocumentConversion.java
          • util
            • ConversionTarget.java
            • ConversionUtils.java
        • http
          • RequestBuilder.java
        • language_translation/v2
          • LanguageTranslation.java
          • model
            • CreateModelOptions.java
            • IdentifiableLanguage.java
            • IdentifiableLanguages.java
            • IdentifiedLanguages.java
            • Language.java
            • TranslationModel.java
            • TranslationResult.java
        • natural_language_classifier/v1
          • NaturalLanguageClassifier.java
          • model
            • Classification.java
            • Classifier.java
        • personality_insights/v2
          • PersonalityInsights.java
          • model
            • Content.java
            • ContentItem.java
            • ProfileOptions.java
            • Trait.java
        • relationship_extraction/v1_beta
          • RelationshipExtraction.java
          • model
            • Dataset.java
        • retrieve_and_rank/v1
          • RetrieveAndRank.java
          • model
            • Ranker.java
            • Rankers.java
            • RemoteError.java
            • SolrCluster.java
          • util
            • Messages.java
            • ZipUtils.java
        • service
          • AlchemyService.java
          • ResponseConverter.java
          • WatsonService.java
          • exception
            • BadRequestException.java
            • ConflictException.java
            • ForbiddenException.java
            • InternalServerErrorException.java
            • NotFoundException.java
            • RequestTooLargeException.java
            • ServiceResponseException.java
            • ServiceUnavailableException.java
            • TooManyRequestsException.java
            • UnauthorizedException.java
            • UnsupportedException.java
        • speech_to_text/v1
          • SpeechToText.java
          • model
            • SpeechAlternative.java
            • SpeechModel.java
            • SpeechModelSet.java
            • SpeechResults.java
            • SpeechSessionStatus.java
            • SpeechTimestamp.java
            • SpeechWordConfidence.java
            • Transcript.java
          • util
            • SpeechTimestampTypeAdapter.java
            • SpeechWordConfidenceTypeAdapter.java
          • websocket
            • BaseRecognizeCallback.java
            • RecognizeCallback.java
            • ResponseListener.java
            • WebSocketManager.java
            • WebSocketSpeechToTextClient.java
        • text_to_speech/v1
          • TextToSpeech.java
          • model
            • AudioFormat.java
            • Voice.java
          • util
            • WaveUtils.java
        • tone_analyzer/v3_beta
          • ToneAnalyzer.java
          • model
            • ElementTone.java
            • SentenceTone.java
            • ToneAnalysis.java
            • ToneCategory.java
            • ToneScore.java
        • tradeoff_analytics/v1
          • TradeoffAnalytics.java
          • model
            • Dilemma.java
            • Option.java
            • Problem.java
            • Resolution.java
            • Solution.java
            • column
              • CategoricalColumn.java
              • Column.java
              • DateColumn.java
              • NumericColumn.java
              • TextColumn.java
          • util
            • ColumnTypeAdapter.java
        • util
          • CredentialUtils.java
          • DateDeserializer.java
          • DateSerializer.java
          • GsonSingleton.java
          • RequestUtils.java
          • ResponseConverterUtils.java
          • ResponseUtils.java
          • Validator.java
        • visual_insights/v1_experimental
          • VisualInsights.java
        • visual_recognition/v2_beta
          • VisualRecognition.java
          • model
            • VisualClassifier.java
      • resources
        • alchemy_endpoints.json
    • test/java/com/ibm/watson/developer_cloud
      • language_translation/v2
        • LanguageTranslationIT.java
        • LanguageTranslationTest.java
      • retrieve_and_rank/v1
        • RetrieveAndRankIT.java
      • service
        • GenericServiceTest.java
      • speech_to_text/v1
        • SpeechToTextIT.java
        • SpeechToTextTest.java
      • tradeoff_analytics/v1
        • TradeoffAnalyticsIT.java
      • visual_insights/v1
        • VisualInsightsIT.java
      • visual_recognition/v2
        • VisualRecognitionIT.java

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ APIs and SDKs that use cognitive computing to solve complex problems.
4747
<dependency>
4848
<groupId>com.ibm.watson.developer_cloud</groupId>
4949
<artifactId>java-sdk</artifactId>
50-
<version>2.10.0</version>
50+
<version>3.0.0</version>
5151
</dependency>
5252
```
5353
##### Gradle
5454

5555
```gradle
56-
'com.ibm.watson.developer_cloud:java-sdk:2.10.0'
56+
'com.ibm.watson.developer_cloud:java-sdk:3.0.0'
5757
```
5858

5959
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).
@@ -454,7 +454,7 @@ Gradle:
454454

455455
```sh
456456
$ cd java-sdk
457-
$ gradle jar # build jar file (build/libs/watson-developer-cloud-2.10.0.jar)
457+
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.0.0.jar)
458458
$ gradle test # run tests
459459
```
460460

@@ -524,4 +524,4 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
524524
[apache_maven]: http://maven.apache.org/
525525
[releases]: https://github.com/watson-developer-cloud/java-sdk/releases
526526

527-
[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-2.10.0/java-sdk-2.10.0-jar-with-dependencies.jar
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
Collapse file

‎build.gradle‎

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

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

1414
repositories {
1515
mavenCentral()
1616
}
1717
dependencies {
18-
compile group: 'com.squareup.okhttp', name: 'okhttp', version:'2.7.2'
1918
compile group: 'com.squareup.okhttp3', name: 'okhttp', version:'3.2.0'
19+
compile group: 'com.squareup.okhttp3', name: 'okhttp-ws', version:'3.2.0'
2020
compile group: 'com.squareup.okhttp3', name: 'okhttp-urlconnection', version:'3.2.0'
2121
compile group: 'com.google.code.gson', name: 'gson', version:'2.6.2'
2222
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'
23-
compile group: 'com.neovisionaries', name: 'nv-websocket-client', version:'1.22'
23+
testCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version:'3.2.0'
2424
testCompile group: 'org.mock-server', name: 'mockserver-netty', version:'3.9.17'
2525
testCompile group: 'junit', name: 'junit-dep', version:'4.11'
2626
}
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/alchemy_data_news/v1/GetNewsDocumentExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/alchemy_data_news/v1/GetNewsDocumentExample.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static void main(String[] args) {
4545
params.put(AlchemyDataNews.START, "1440720000");
4646
params.put(AlchemyDataNews.END, "1441407600");
4747
params.put(AlchemyDataNews.COUNT, 7);
48+
4849
//Query on adjacent nested fields:
4950
params.put("q.enriched.url.enrichedTitle.entities.entity", "|text=IBM,type=company|");
5051
params.put("q.enriched.url.enrichedTitle.docSentiment.type", "positive");
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;
2121
import com.ibm.watson.developer_cloud.alchemy.v1.model.DocumentSentiment;
22+
import com.ibm.watson.developer_cloud.alchemy.v1.model.Entities;
2223

2324
public class AlchemyLanguageExample {
2425

@@ -29,9 +30,13 @@ public static void main(String[] args) {
2930
Map<String, Object> params = new HashMap<String, Object>();
3031
params.put(AlchemyLanguage.TEXT,
3132
"IBM Watson won the Jeopardy television show hosted by Alex Trebek");
32-
DocumentSentiment sentiment = service.getSentiment(params).execute();
3333

34-
System.out.println(sentiment);
34+
DocumentSentiment sentiment = service.getSentiment(params).execute();
35+
System.out.println("Sentiment: " + sentiment);
36+
37+
Entities entities = service.getEntities(params).execute();
38+
System.out.println("Entities: " + entities);
39+
3540
}
3641

3742
}
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/CreateASolrClusterExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/CreateASolrClusterExample.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void main(String[] args) throws InterruptedException {
4040
}
4141

4242
// 3 list Solr Clusters
43-
System.out.println("Solr clusters: " + service.getSolrClusters());
43+
System.out.println("Solr clusters: " + service.getSolrClusters().execute());
4444

4545
}
4646
}
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsExample.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import com.ibm.watson.developer_cloud.http.HttpMediaType;
99
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechResults;
10-
import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeDelegate;
10+
import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeCallback;
1111

1212
/**
1313
* Recognize using WebSockets a sample wav file and print the transcript into the console output.
@@ -24,15 +24,15 @@ public static void main(String[] args) throws FileNotFoundException, Interrupted
2424
RecognizeOptions options = new RecognizeOptions();
2525
options.continuous(true).interimResults(true).contentType(HttpMediaType.AUDIO_WAV);
2626

27-
service.recognizeUsingWebSockets(audio, options, new BaseRecognizeDelegate() {
27+
service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
2828
@Override
29-
public void onMessage(SpeechResults speechResults) {
29+
public void onTranscription(SpeechResults speechResults) {
3030
System.out.println(speechResults);
3131
if (speechResults.isFinal())
3232
lock.countDown();
3333
}
3434
});
3535

36-
lock.await(20000, TimeUnit.MILLISECONDS);
36+
lock.await(1, TimeUnit.MINUTES);
3737
}
3838
}
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechExample.java
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515

1616
import java.util.List;
1717

18-
import com.ibm.watson.developer_cloud.WatsonServiceTest;
1918
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice;
2019

21-
public class TextToSpeechExample extends WatsonServiceTest {
20+
public class TextToSpeechExample {
2221

2322

2423
public static void main(String[] args) {
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java
+22-4Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.ibm.watson.developer_cloud.text_to_speech.v1;
22

3+
import java.io.File;
4+
import java.io.FileOutputStream;
35
import java.io.IOException;
46
import java.io.InputStream;
5-
import java.nio.file.Files;
6-
import java.nio.file.Paths;
7-
import java.nio.file.StandardCopyOption;
7+
import java.io.OutputStream;
88

99
import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation;
1010
import com.ibm.watson.developer_cloud.language_translation.v2.model.Language;
1111
import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationResult;
1212
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AudioFormat;
1313
import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice;
14+
import com.ibm.watson.developer_cloud.text_to_speech.v1.util.WaveUtils;
1415

1516
public class TranslateAndSynthesizeExample {
1617

@@ -29,7 +30,24 @@ public static void main(String[] args) throws IOException {
2930

3031
// synthesize
3132
InputStream in = synthesizer.synthesize(translation, Voice.ES_LAURA, AudioFormat.WAV).execute();
32-
Files.copy(in, Paths.get("output.wav"), StandardCopyOption.REPLACE_EXISTING);
33+
writeToFile(WaveUtils.reWriteWaveHeader(in), new File("output.wav"));
34+
}
3335

36+
/**
37+
* Write the input stream to a file
38+
*/
39+
private static void writeToFile(InputStream in, File file) {
40+
try {
41+
OutputStream out = new FileOutputStream(file);
42+
byte[] buf = new byte[1024];
43+
int len;
44+
while ((len = in.read(buf)) > 0) {
45+
out.write(buf, 0, len);
46+
}
47+
out.close();
48+
in.close();
49+
} catch (Exception e) {
50+
e.printStackTrace();
51+
}
3452
}
3553
}
Collapse file

‎examples/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsExample.java‎

Copy file name to clipboardExpand all lines: examples/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsExample.java
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public static void main(String[] args) {
4040
List<Column> columns = new ArrayList<Column>();
4141
problem.setColumns(columns);
4242

43-
columns.add(new NumericColumn().withRange(0, 100).withKey(price).withGoal(Goal.MIN)
44-
.withObjective(true));
45-
columns.add(new NumericColumn().withKey(screen).withGoal(Goal.MAX).withObjective(true));
46-
columns.add(new NumericColumn().withKey(ram).withGoal(Goal.MAX));
43+
columns.add(new NumericColumn().range(0, 100).key(price).goal(Goal.MIN)
44+
.objective(true));
45+
columns.add(new NumericColumn().key(screen).goal(Goal.MAX).objective(true));
46+
columns.add(new NumericColumn().key(ram).goal(Goal.MAX));
4747

4848
// Define the options to choose
4949
List<Option> options = new ArrayList<Option>();
@@ -53,19 +53,19 @@ public static void main(String[] args) {
5353
galaxySpecs.put(price, 50);
5454
galaxySpecs.put(ram, 45);
5555
galaxySpecs.put(screen, 5);
56-
options.add(new Option("1", "Galaxy S4").withValues(galaxySpecs));
56+
options.add(new Option("1", "Galaxy S4").values(galaxySpecs));
5757

5858
HashMap<String, Object> iphoneSpecs = new HashMap<String, Object>();
5959
iphoneSpecs.put(price, 99);
6060
iphoneSpecs.put(ram, 40);
6161
iphoneSpecs.put(screen, 4);
62-
options.add(new Option("2", "iPhone 5").withValues(iphoneSpecs));
62+
options.add(new Option("2", "iPhone 5").values(iphoneSpecs));
6363

6464
HashMap<String, Object> optimusSpecs = new HashMap<String, Object>();
6565
optimusSpecs.put(price, 10);
6666
optimusSpecs.put(ram, 300);
6767
optimusSpecs.put(screen, 5);
68-
options.add(new Option("3", "LG Optimus G").withValues(optimusSpecs));
68+
options.add(new Option("3", "LG Optimus G").values(optimusSpecs));
6969

7070
// Call the service and get the resolution
7171
Dilemma dilemma = service.dilemmas(problem).execute();
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>2.10.0</version>
30+
<version>3.0.0</version>
3131
</dependency>
3232
</dependencies>
3333
</project>

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.