Skip to content

Commit 247cf33

Browse files
committed
Merge branch 'develop' of https://github.com/watson-developer-cloud/java-sdk into document-sentiment-result-label-dev
2 parents 273e72b + 2cb0228 commit 247cf33

File tree

18 files changed

+356
-187
lines changed

18 files changed

+356
-187
lines changed

.bumpversion.cfg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[bumpversion]
2+
current_version = 4.0.0
3+
4+
[bumpversion:file:README.md]
5+
[bumpversion:file:alchemy/README.md]
6+
[bumpversion:file:conversation/README.md]
7+
[bumpversion:file:discovery/README.md]
8+
[bumpversion:file:document-conversion/README.md]
9+
[bumpversion:file:language-translator/README.md]
10+
[bumpversion:file:natural-language-classifier/README.md]
11+
[bumpversion:file:natural-language-understanding/README.md]
12+
[bumpversion:file:personality-insights/README.md]
13+
[bumpversion:file:retrieve-and-rank/README.md]
14+
[bumpversion:file:speech-to-text/README.md]
15+
[bumpversion:file:text-to-speech/README.md]
16+
[bumpversion:file:tone-analyzer/README.md]
17+
[bumpversion:file:tradeoff-analytics/README.md]
18+
[bumpversion:file:visual-recognition/README.md]
19+
search = {current_version}
20+
replace = {new_version}

.utility/push-javadoc-to-gh-pages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
44

55
git config --global user.email "[email protected]"
66
git config --global user.name "Watson Github Bot"
7-
git clone --quiet --branch=gh-pages https://${GITHUB_TOKEN_DOCS}@github.com/watson-developer-cloud/java-sdk gh-pages > /dev/null
7+
git clone --quiet --branch=gh-pages https://${GITHUB_TOKEN_DOCS}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null
88

99
pushd gh-pages
1010
# on tagged builds, $TRAVIS_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)

RELEASE.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,26 @@ If you are not familiar with Sonatype and/or the maven release process please re
1717

1818
### Release steps
1919

20-
1. Update `README.md` to include the new version number
20+
1. Update all READMEs to include the new version number
21+
22+
This can be done using [bumpversion]. If necessary, it can be installed with the following command:
23+
24+
```bash
25+
pip install bumpversion
26+
```
27+
28+
To then update all version numbers, simply run:
29+
30+
```bash
31+
bumpversion major|minor|patch
32+
```
33+
2134
1. Perform a release deployment to OSSRH (Staging) with:
2235

23-
`gradle release`
36+
```bash
37+
`gradle release`
38+
```
39+
40+
You will have to answer prompts for versions and tags. That will tag and commit a new version into your repository automatically.
2441

25-
You will have to answer prompts for versions and tags. That will tag and commit a new version into your repository automatically.
42+
[bumpversion]: https://pypi.python.org/pypi/bumpversion

speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class SpeechToText extends WatsonService {
6969
private static final String CALLBACK_URL = "callback_url";
7070
private static final String CONTINUOUS = "continuous";
7171
private static final String CUSTOMIZATION_ID = "customization_id";
72+
private static final String CUSTOMIZATION_WEIGHT = "customization_weight";
7273
private static final String EVENTS = "events";
7374
private static final String INACTIVITY_TIMEOUT = "inactivity_timeout";
7475
private static final String KEYWORDS = "keywords";
@@ -232,6 +233,10 @@ private void buildRecognizeRequest(RequestBuilder requestBuilder, RecognizeOptio
232233
if (options.customizationId() != null) {
233234
requestBuilder.query(CUSTOMIZATION_ID, options.customizationId());
234235
}
236+
237+
if (options.customizationWeight() != null) {
238+
requestBuilder.query(CUSTOMIZATION_WEIGHT, options.customizationWeight());
239+
}
235240
}
236241

237242
/**
@@ -815,6 +820,10 @@ public WebSocket recognizeUsingWebSocket(final InputStream audio, final Recogniz
815820
urlBuilder.addQueryParameter(CUSTOMIZATION_ID, options.customizationId());
816821
}
817822

823+
if (options.customizationWeight() != null) {
824+
urlBuilder.addQueryParameter(CUSTOMIZATION_WEIGHT, String.valueOf(options.customizationWeight()));
825+
}
826+
818827
String url = urlBuilder.toString().replace("https://", "wss://");
819828
Builder builder = new Request.Builder().url(url);
820829

speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeOptions.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static class Builder {
4848
private Boolean smartFormatting;
4949
private String customizationId;
5050
private Boolean speakerLabels;
51+
private Double customizationWeight;
5152

5253
private Builder(RecognizeOptions options) {
5354
contentType = options.contentType;
@@ -66,6 +67,7 @@ private Builder(RecognizeOptions options) {
6667
smartFormatting = options.smartFormatting;
6768
customizationId = options.customizationId;
6869
speakerLabels = options.speakerLabels;
70+
customizationWeight = options.customizationWeight;
6971
}
7072

7173
/**
@@ -135,6 +137,21 @@ public Builder speakerLabels(Boolean speakerLabels) {
135137
return this;
136138
}
137139

140+
/**
141+
* If a custom model is specified, this parameter tells the service how much weight to give
142+
* to words from the custom language model compared to those from the base model.
143+
* Specify a value between 0.0 and 1.0 (inclusive). If value is null or omitted, the customization
144+
* weight from the model is used. If no customization weight is specified on the model, the default
145+
* value of the service will be used.
146+
*
147+
* @param customizationWeight Labels or "diarization"
148+
* @return the recognize options
149+
*/
150+
public Builder customizationWeight(Double customizationWeight) {
151+
this.customizationWeight = customizationWeight;
152+
return this;
153+
}
154+
138155
/**
139156
* If true, filters profanity from all output except for keyword results by replacing inappropriate words with a
140157
* series of asterisks. Set the parameter to false to return results with no censoring. Applies to US English
@@ -330,6 +347,9 @@ public Builder wordConfidence(Boolean wordConfidence) {
330347
@SerializedName("speaker_labels")
331348
private Boolean speakerLabels;
332349

350+
@SerializedName("customization_weight")
351+
private Double customizationWeight;
352+
333353
private RecognizeOptions(Builder builder) {
334354
contentType = builder.contentType;
335355
continuous = builder.continuous;
@@ -347,6 +367,7 @@ private RecognizeOptions(Builder builder) {
347367
smartFormatting = builder.smartFormatting;
348368
customizationId = builder.customizationId;
349369
speakerLabels = builder.speakerLabels;
370+
customizationWeight = builder.customizationWeight;
350371
}
351372

352373
/**
@@ -394,6 +415,15 @@ public Boolean speakerLabels() {
394415
return speakerLabels;
395416
}
396417

418+
/**
419+
* Gets the customizationWeight.
420+
*
421+
* @return the customizationWeight
422+
*/
423+
public Double customizationWeight() {
424+
return customizationWeight;
425+
}
426+
397427
/**
398428
* Gets the continuous.
399429
*

speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,29 @@ public void testRecognizeWithCustomization() throws FileNotFoundException, Inter
358358
assertEquals(recognition, GSON.toJsonTree(result));
359359
}
360360

361+
/**
362+
* Test recognize with customization weight.
363+
*
364+
* @throws FileNotFoundException the file not found exception
365+
* @throws InterruptedException the interrupted exception
366+
*/
367+
@Test
368+
public void testRecognizeWithCustomizationWeight() throws FileNotFoundException, InterruptedException {
369+
String id = "foo";
370+
String recString =
371+
getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/recognition.json"));
372+
JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject();
373+
374+
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(recString));
375+
376+
RecognizeOptions options = new RecognizeOptions.Builder().customizationId(id).customizationWeight(0.5).build();
377+
SpeechResults result = service.recognize(SAMPLE_WAV, options).execute();
378+
final RecordedRequest request = server.takeRequest();
379+
380+
assertEquals(PATH_RECOGNIZE + "?customization_id=" + id + "&customization_weight=0.5", request.getPath());
381+
assertEquals(recognition, GSON.toJsonTree(result));
382+
}
383+
361384
/**
362385
* Test recognize -missing audio file, generate IllegalArgumentException.
363386
*

tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzer.java

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,23 @@
2121
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions;
2222
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.UtteranceAnalyses;
2323
import com.ibm.watson.developer_cloud.util.GsonSingleton;
24-
import com.ibm.watson.developer_cloud.util.RequestUtils;
2524
import com.ibm.watson.developer_cloud.util.ResponseConverterUtils;
2625
import com.ibm.watson.developer_cloud.util.Validator;
2726

2827
/**
2928
* ### Service Overview
30-
* The IBM Watson Tone Analyzer service uses linguistic analysis to detect emotional, social, and language tones in
31-
* written text. The service can analyze tone at both the document and sentence levels. You can use the service to
32-
* understand how your written communications are perceived and then to improve the tone of your communications.
33-
* Businesses can use the service to learn the tone of their customers' communications and to respond to each customer
34-
* appropriately, or to understand and improve their customer conversations.
29+
* The IBM Watson Tone Analyzer service uses linguistic analysis to detect emotional and language tones in written text.
30+
* The service can analyze tone at both the document and sentence levels. You can use the service to understand how your
31+
* written communications are perceived and then to improve the tone of your communications. Businesses can use the
32+
* service to learn the tone of their customers' communications and to respond to each customer appropriately, or to
33+
* understand and improve their customer conversations.
3534
* ### API Usage
3635
* The following information provides details about using the service to analyze tone:
3736
* * **The tone method:** The service offers `GET` and `POST /v3/tone` methods that use the general purpose endpoint to
38-
* analyze the tone of input content. The methods accept a maximum of 128 KB of content in JSON, plain text, or HTML
39-
* format.
37+
* analyze the tone of input content. The methods accept content in JSON, plain text, or HTML format.
4038
* * **The tone_chat method:** The service offers a `POST /v3/tone_chat` method that uses the customer engagement
41-
* endpoint to analyze the tone of customer service and customer support conversations. The method accepts a maximum of
42-
* 128 KB of content in JSON format.
39+
* endpoint to analyze the tone of customer service and customer support conversations. The method accepts content in
40+
* JSON format.
4341
* * **Authentication:** You authenticate to the service by using your service credentials. You can use your credentials
4442
* to authenticate via a proxy server that resides in Bluemix, or you can use your credentials to obtain a token and
4543
* contact the service directly. See [Service credentials for Watson
@@ -98,17 +96,7 @@ public ToneAnalyzer(String versionDate, String username, String password) {
9896
/**
9997
* Analyze general purpose tone.
10098
*
101-
* Uses the general purpose endpoint to analyze the tone of your input content. The service can analyze the input for
102-
* several tones: emotion, language, and social. It derives various characteristics for each tone that it analyzes.
103-
* The method always analyzes the tone of the full document; by default, it also analyzes the tone of each individual
104-
* sentence of the input. You can submit a maximum of 128 KB of content in JSON, plain text, or HTML format. Per
105-
* the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the
106-
* HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character
107-
* set). When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the
108-
* character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. For `text/html`,
109-
* the service removes HTML tags and analyzes only the textual content. Use the `POST` request method to analyze
110-
* larger amounts of content in any of the available formats. Use the `GET` request method to analyze smaller
111-
* quantities of plain text content.
99+
* Uses the general purpose endpoint to analyze the tone of your input content. The service analyzes the content for emotional and language tones. The method always analyzes the tone of the full document; by default, it also analyzes the tone of each individual sentence of the content. You can submit no more than 128 KB of total input content and no more than 1000 individual sentences in JSON, plain text, or HTML format. The service analyzes the first 1000 sentences for document-level analysis and only the first 100 sentences for sentence-level analysis. Use the `POST` request method to analyze larger amounts of content in any of the available formats. Use the `GET` request method to analyze smaller quantities of plain text content. Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. For `text/html`, the service removes HTML tags and analyzes only the textual content. **Note:** The `tones` query parameter is no longer supported. The service continues to accept the parameter for backward-compatibility, but the parameter no longer affects the response.
112100
*
113101
* @param toneOptions the {@link ToneOptions} containing the options for the call
114102
* @return the {@link ToneAnalysis} with the response
@@ -118,8 +106,11 @@ public ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions) {
118106
RequestBuilder builder = RequestBuilder.post("/v3/tone");
119107
builder.query(VERSION, versionDate);
120108
builder.header("content-type", toneOptions.contentType());
121-
if (toneOptions.tones() != null) {
122-
builder.query("tones", RequestUtils.join(toneOptions.tones(), ","));
109+
if (toneOptions.contentLanguage() != null) {
110+
builder.header("Content-Language", toneOptions.contentLanguage());
111+
}
112+
if (toneOptions.acceptLanguage() != null) {
113+
builder.header("Accept-Language", toneOptions.acceptLanguage());
123114
}
124115
if (toneOptions.sentences() != null) {
125116
builder.query("sentences", String.valueOf(toneOptions.sentences()));
@@ -135,11 +126,7 @@ public ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions) {
135126
/**
136127
* Analyze customer engagement tone.
137128
*
138-
* Uses the customer engagement endpoint to analyze the tone of customer service and customer support conversations.
139-
* For each utterance of a conversation, the method reports the most prevalent subset of the following seven tones:
140-
* sad, frustrated, satisfied, excited, polite, impolite, and sympathetic. You can submit a maximum of 128 KB of
141-
* JSON input. Per the JSON specification, the default character encoding for JSON content is effectively always
142-
* UTF-8.
129+
* Use the customer engagement endpoint to analyze the tone of customer service and customer support conversations. For each utterance of a conversation, the method reports the most prevalent subset of the following seven tones: sad, frustrated, satisfied, excited, polite, impolite, and sympathetic. If you submit more than 50 utterances, the service returns a warning for the overall content and analyzes only the first 50 utterances. If you submit a single utterance that contains more than 500 characters, the service returns an error for that utterance and does not analyze the utterance. The request fails if all utterances have more than 500 characters. Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8.
143130
*
144131
* @param toneChatOptions the {@link ToneChatOptions} containing the options for the call
145132
* @return the {@link UtteranceAnalyses} with the response
@@ -148,6 +135,9 @@ public ServiceCall<UtteranceAnalyses> toneChat(ToneChatOptions toneChatOptions)
148135
Validator.notNull(toneChatOptions, "toneChatOptions cannot be null");
149136
RequestBuilder builder = RequestBuilder.post("/v3/tone_chat");
150137
builder.query(VERSION, versionDate);
138+
if (toneChatOptions.acceptLanguage() != null) {
139+
builder.header("Accept-Language", toneChatOptions.acceptLanguage());
140+
}
151141
final JsonObject contentJson = new JsonObject();
152142
contentJson.add("utterances", GsonSingleton.getGson().toJsonTree(toneChatOptions.utterances()));
153143
builder.bodyJson(contentJson);

tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/DocumentAnalysis.java

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,53 @@
1414

1515
import java.util.List;
1616

17-
import com.google.gson.annotations.SerializedName;
1817
import com.ibm.watson.developer_cloud.service.model.GenericModel;
1918

2019
/**
2120
* DocumentAnalysis.
2221
*/
2322
public class DocumentAnalysis extends GenericModel {
2423

25-
@SerializedName("tone_categories")
26-
private List<ToneCategory> toneCategories;
24+
private List<ToneScore> tones;
25+
private String warning;
2726

2827
/**
29-
* Gets the toneCategories.
28+
* Gets the tones.
3029
*
31-
* An array of `ToneCategory` objects that provides the results of the tone analysis for the full document of the
32-
* input content. The service returns results only for the tones specified with the `tones` parameter of the request.
30+
* An array of `ToneScore` objects that provides the results of the analysis for each qualifying tone of the document. The array includes results for any tone whose score is at least 0.5. The array is empty if no tone has a score that meets this threshold.
3331
*
34-
* @return the toneCategories
32+
* @return the tones
3533
*/
36-
public List<ToneCategory> getToneCategories() {
37-
return toneCategories;
34+
public List<ToneScore> getTones() {
35+
return tones;
3836
}
3937

4038
/**
41-
* Sets the toneCategories.
39+
* Gets the warning.
4240
*
43-
* @param toneCategories the new toneCategories
41+
* A warning message if the overall content exceeds 128 KB or contains more than 1000 sentences. The service analyzes only the first 1000 sentences for document-level analysis and the first 100 sentences for sentence-level analysis.
42+
*
43+
* @return the warning
44+
*/
45+
public String getWarning() {
46+
return warning;
47+
}
48+
49+
/**
50+
* Sets the tones.
51+
*
52+
* @param tones the new tones
53+
*/
54+
public void setTones(final List<ToneScore> tones) {
55+
this.tones = tones;
56+
}
57+
58+
/**
59+
* Sets the warning.
60+
*
61+
* @param warning the new warning
4462
*/
45-
public void setToneCategories(final List<ToneCategory> toneCategories) {
46-
this.toneCategories = toneCategories;
63+
public void setWarning(final String warning) {
64+
this.warning = warning;
4765
}
4866
}

0 commit comments

Comments
 (0)