GeezerVison is showing github.com — Update README examples · guillept/java-sdk@35adaf9
File treeExpand file treeCollapse file tree Open diff view settings examples/conversation_tone_analyzer_integration/src/main/java/com/ibm/watson/developer_cloud/conversation_tone_analyzer_integration/v1
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: conversation/README.md +13-12Lines changed: 13 additions & 12 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,24 +33,25 @@ System.out.println(response); | 33 | 33 | Moving from Node 1 to Node 2. | 34 | 34 |
| 35 | 35 | ```java | 36 | | - | 37 | | -Map<String, Object> context = new HashMap<String, Object>(); | | 36 | +Context context = null; | 38 | 37 |
| 39 | 38 | // first message | 40 | | -MessageRequest newMessage = new MessageRequest.Builder() | 41 | | - .input(new InputData.Builder("First message").build()) | 42 | | - .context(context) | 43 | | - .build(); | | 39 | +MessageOptions newMessageOptions = new MessageOptions.Builder() | | 40 | + .workspaceId("<workspace-id>") | | 41 | + .input(new InputData.Builder("First message").build()) | | 42 | + .context(context) | | 43 | + .build(); | 44 | 44 |
| 45 | | -MessageResponse response = service.message("<workspace-id>", newMessage).execute(); | | 45 | +MessageResponse response = service.message(newMessageOptions).execute(); | 46 | 46 |
| 47 | 47 | // second message | 48 | | -newMessage = new MessageRequest.Builder() | 49 | | - .input(new InputData.Builder("Second message").build()) | 50 | | - .context(response.getContext()) // output context from the first message | 51 | | - .build(); | | 48 | +newMessageOptions = new MessageOptions.Builder() | | 49 | + .workspaceId("<workspace-id>") | | 50 | + .input(new InputData.Builder("Second message").build()) | | 51 | + .context(response.getContext()) // output context from the first message | | 52 | + .build(); | 52 | 53 |
| 53 | | -response = service.message("<workspace-id>", newMessage).execute(); | | 54 | +response = service.message(newMessageOptions).execute(); | 54 | 55 |
| 55 | 56 | System.out.println(response); | 56 | 57 | ``` | |
Collapse file Copy file name to clipboardExpand all lines: examples/conversation_tone_analyzer_integration/src/main/java/com/ibm/watson/developer_cloud/conversation_tone_analyzer_integration/v1/ToneConversationIntegrationV1.java +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 26 | 26 | import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; | 27 | 27 |
| 28 | 28 | /** | 29 | | - * Example of how to call the {@link ConversationService#message(String, MessageRequest)} | | 29 | + * Example of how to call the {@link ConversationService#message(String, MessageRequest)} | 30 | 30 | * method asynchronously. | 31 | 31 | * | 32 | 32 | * @version v1 | @@ -37,19 +37,20 @@ public static void main(String[] args) throws Exception { | 37 | 37 |
| 38 | 38 | // load the properties file | 39 | 39 | Properties props = new Properties(); | 40 | | - props.load(FileUtils.openInputStream(new File("tone_conversation_integration.properties"))); | | 40 | + props.load(FileUtils.openInputStream(new File("tone_conversation_integration.properties.example"))); | 41 | 41 |
| 42 | 42 | // instantiate the conversation service | 43 | | - ConversationService conversationService = new ConversationService(ConversationService.VERSION_DATE_2016_07_11); | | 43 | + final ConversationService conversationService = new ConversationService(ConversationService | | 44 | + .VERSION_DATE_2016_07_11); | 44 | 45 | conversationService.setUsernameAndPassword( | 45 | | - props.getProperty("CONVERSATION_USERNAME", "<conversation_username>"), | | 46 | + props.getProperty("CONVERSATION_USERNAME", "<conversation_username>"), | 46 | 47 | props.getProperty("CONVERSATION_PASSWORD", "<conversation_password>") | 47 | 48 | ); | 48 | 49 |
| 49 | 50 | // instantiate the tone analyzer service | 50 | 51 | ToneAnalyzer toneService = new ToneAnalyzer(ToneAnalyzer.VERSION_DATE_2016_05_19); | 51 | 52 | toneService.setUsernameAndPassword( | 52 | | - props.getProperty("TONE_ANALYZER_USERNAME", "<tone_analyzer_username>"), | | 53 | + props.getProperty("TONE_ANALYZER_USERNAME", "<tone_analyzer_username>"), | 53 | 54 | props.getProperty("TONE_ANALYZER_PASSWORD", "<tone_analyzer_password>") | 54 | 55 | ); | 55 | 56 |
| |
Collapse file Copy file name to clipboardExpand all lines: speech-to-text/README.md +18-13Lines changed: 18 additions & 13 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,11 @@ service.setUsernameAndPassword("<username>", "<password>"); | 25 | 25 |
| 26 | 26 | File audio = new File("src/test/resources/sample1.wav"); | 27 | 27 |
| 28 | | -SpeechResults transcript = service.recognize(audio, HttpMediaType.AUDIO_WAV).execute(); | | 28 | +RecognizeOptions options = new RecognizeOptions.Builder() | | 29 | + .contentType(HttpMediaType.AUDIO_WAV) | | 30 | + .build(); | | 31 | + | | 32 | +SpeechResults transcript = service.recognize(audio, options).execute(); | 29 | 33 | System.out.println(transcript); | 30 | 34 | ``` | 31 | 35 |
| @@ -38,21 +42,22 @@ Speech to Text supports WebSocket, the url is: | 38 | 42 | SpeechToText service = new SpeechToText(); | 39 | 43 | service.setUsernameAndPassword("<username>", "<password>"); | 40 | 44 |
| 41 | | -File audio = new File("src/test/resources/sample1.wav"); | | 45 | +InputStream audio = new FileInputStream("src/test/resources/sample1.wav"); | 42 | 46 |
| 43 | 47 | RecognizeOptions options = new RecognizeOptions.Builder() | 44 | | - .interimResults(true) | 45 | | - .contentType(HttpMediaType.AUDIO_WAV) | 46 | | - .build(); | | 48 | + .interimResults(true) | | 49 | + .contentType(HttpMediaType.AUDIO_WAV) | | 50 | + .build(); | | 51 | + | | 52 | +service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() { | | 53 | + @Override | | 54 | + public void onTranscription(SpeechResults speechResults) { | | 55 | + System.out.println(speechResults); | | 56 | + } | | 57 | +}); | 47 | 58 |
| 48 | | - service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() { | 49 | | - @Override | 50 | | - public void onTranscription(SpeechResults speechResults) { | 51 | | - System.out.println(speechResults); | 52 | | - } | 53 | | - ); | 54 | | - // wait 20 seconds for the asynchronous response | 55 | | - Thread.sleep(20000); | | 59 | +// wait 20 seconds for the asynchronous response | | 60 | +Thread.sleep(20000); | 56 | 61 | ``` | 57 | 62 | #### Microphone example | 58 | 63 | Use your microphone to recognize audio for 30 seconds. | |
Collapse file Copy file name to clipboardExpand all lines: tradeoff-analytics/README.md +15-6Lines changed: 15 additions & 6 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,9 +34,18 @@ String screen = "screen"; | 34 | 34 | List<Column> columns = new ArrayList<Column>(); | 35 | 35 | problem.setColumns(columns); | 36 | 36 |
| 37 | | -columns.add(new NumericColumn().withRange(0, 100).withKey(price).withGoal(Goal.MIN).withObjective(true)); | 38 | | -columns.add(new NumericColumn().withKey(screen).withGoal(Goal.MAX).withObjective(true)); | 39 | | -columns.add(new NumericColumn().withKey(ram).withGoal(Goal.MAX)); | | 37 | +columns.add(new NumericColumn() | | 38 | + .range(0, 100) | | 39 | + .key(price) | | 40 | + .goal(Goal.MIN) | | 41 | + .objective(true)); | | 42 | +columns.add(new NumericColumn() | | 43 | + .key(screen) | | 44 | + .goal(Goal.MAX) | | 45 | + .objective(true)); | | 46 | +columns.add(new NumericColumn() | | 47 | + .key(ram) | | 48 | + .goal(Goal.MAX)); | 40 | 49 |
| 41 | 50 | // Define the options to choose | 42 | 51 | List<Option> options = new ArrayList<Option>(); | @@ -46,19 +55,19 @@ HashMap<String, Object> galaxySpecs = new HashMap<String, Object>(); | 46 | 55 | galaxySpecs.put(price, 50); | 47 | 56 | galaxySpecs.put(ram, 45); | 48 | 57 | galaxySpecs.put(screen, 5); | 49 | | -options.add(new Option("1", "Galaxy S4").withValues(galaxySpecs)); | | 58 | +options.add(new Option("1", "Galaxy S4").values(galaxySpecs)); | 50 | 59 |
| 51 | 60 | HashMap<String, Object> iphoneSpecs = new HashMap<String, Object>(); | 52 | 61 | iphoneSpecs.put(price, 99); | 53 | 62 | iphoneSpecs.put(ram, 40); | 54 | 63 | iphoneSpecs.put(screen, 4); | 55 | | -options.add(new Option("2", "iPhone 5").withValues(iphoneSpecs)); | | 64 | +options.add(new Option("2", "iPhone 5").values(iphoneSpecs)); | 56 | 65 |
| 57 | 66 | HashMap<String, Object> optimusSpecs = new HashMap<String, Object>(); | 58 | 67 | optimusSpecs.put(price, 10); | 59 | 68 | optimusSpecs.put(ram, 300); | 60 | 69 | optimusSpecs.put(screen, 5); | 61 | | -options.add(new Option("3", "LG Optimus G").withValues(optimusSpecs)); | | 70 | +options.add(new Option("3", "LG Optimus G").values(optimusSpecs)); | 62 | 71 |
| 63 | 72 | // Call the service and get the resolution | 64 | 73 | Dilemma dilemma = service.dilemmas(problem).execute(); | |
Collapse file Copy file name to clipboardExpand all lines: visual-recognition/README.md +3-3Lines changed: 3 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -27,10 +27,10 @@ VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE | 27 | 27 | service.setApiKey("<api-key>"); | 28 | 28 |
| 29 | 29 | System.out.println("Classify an image"); | 30 | | -ClassifyImagesOptions options = new ClassifyImagesOptions.Builder() | 31 | | - .images(new File("src/test/resources/visual_recognition/car.png")) | | 30 | +ClassifyOptions options = new ClassifyOptions.Builder() | | 31 | + .imagesFile(new File(SINGLE_IMAGE_FILE)) | 32 | 32 | .build(); | 33 | | -VisualClassification result = service.classify(options).execute(); | | 33 | +ClassifiedImages result = service.classify(options).execute(); | 34 | 34 | System.out.println(result); | 35 | 35 | ``` | 36 | 36 |
| |
|