Skip to content

Commit 2cb0228

Browse files
shubhanjan99germanattanasio
authored andcommitted
Added Generated SDK files for new version of Tone (#809)
1 parent 28aa10d commit 2cb0228

File tree

12 files changed

+253
-183
lines changed

12 files changed

+253
-183
lines changed

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
}

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

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ public class SentenceAnalysis extends GenericModel {
2525
@SerializedName("sentence_id")
2626
private Long sentenceId;
2727
private String text;
28-
@SerializedName("input_from")
29-
private Long inputFrom;
30-
@SerializedName("input_to")
31-
private Long inputTo;
32-
@SerializedName("tone_categories")
33-
private List<ToneCategory> toneCategories;
28+
private List<ToneScore> tones;
3429

3530
/**
3631
* Gets the sentenceId.
3732
*
38-
* The unique identifier of a sentence of the input content. The first sentence has ID 0, and the ID of each
39-
* subsequent sentence is incremented by one.
33+
* The unique identifier of a sentence of the input content. The first sentence has ID 0, and the ID of each subsequent sentence is incremented by one.
4034
*
4135
* @return the sentenceId
4236
*/
@@ -56,37 +50,14 @@ public String getText() {
5650
}
5751

5852
/**
59-
* Gets the inputFrom.
53+
* Gets the tones.
6054
*
61-
* The offset of the first character of the sentence in the overall input content.
55+
* An array of `ToneScore` objects that provides the results of the analysis for each qualifying tone of the sentence. 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.
6256
*
63-
* @return the inputFrom
57+
* @return the tones
6458
*/
65-
public Long getInputFrom() {
66-
return inputFrom;
67-
}
68-
69-
/**
70-
* Gets the inputTo.
71-
*
72-
* The offset of the last character of the sentence in the overall input content.
73-
*
74-
* @return the inputTo
75-
*/
76-
public Long getInputTo() {
77-
return inputTo;
78-
}
79-
80-
/**
81-
* Gets the toneCategories.
82-
*
83-
* An array of `ToneCategory` objects that provides the results for the tone analysis of the sentence. The service
84-
* returns results only for the tones specified with the `tones` parameter of the request.
85-
*
86-
* @return the toneCategories
87-
*/
88-
public List<ToneCategory> getToneCategories() {
89-
return toneCategories;
59+
public List<ToneScore> getTones() {
60+
return tones;
9061
}
9162

9263
/**
@@ -108,29 +79,11 @@ public void setText(final String text) {
10879
}
10980

11081
/**
111-
* Sets the inputFrom.
112-
*
113-
* @param inputFrom the new inputFrom
114-
*/
115-
public void setInputFrom(final long inputFrom) {
116-
this.inputFrom = inputFrom;
117-
}
118-
119-
/**
120-
* Sets the inputTo.
121-
*
122-
* @param inputTo the new inputTo
123-
*/
124-
public void setInputTo(final long inputTo) {
125-
this.inputTo = inputTo;
126-
}
127-
128-
/**
129-
* Sets the toneCategories.
82+
* Sets the tones.
13083
*
131-
* @param toneCategories the new toneCategories
84+
* @param tones the new tones
13285
*/
133-
public void setToneCategories(final List<ToneCategory> toneCategories) {
134-
this.toneCategories = toneCategories;
86+
public void setTones(final List<ToneScore> tones) {
87+
this.tones = tones;
13588
}
13689
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ToneAnalysis extends GenericModel {
3030
/**
3131
* Gets the documentTone.
3232
*
33-
* An object of type `DocumentAnalysis` that provides the results for the full document of the input content.
33+
* An object of type `DocumentAnalysis` that provides the results of the analysis for the full input document.
3434
*
3535
* @return the documentTone
3636
*/
@@ -41,9 +41,7 @@ public DocumentAnalysis getDocumentTone() {
4141
/**
4242
* Gets the sentencesTone.
4343
*
44-
* An array of `SentenceAnalysis` objects that provides the results for the individual sentences of the input
45-
* content. The service returns results only for the first 100 sentences of the input. The field is omitted if the
46-
* `sentences` parameter of the request is set to `false`.
44+
* An array of `SentenceAnalysis` objects that provides the results of the analysis for the individual sentences of the input content. The service returns results only for the first 100 sentences of the input. The field is omitted if the sentences parameter of the request is set to `false`.
4745
*
4846
* @return the sentencesTone
4947
*/

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,47 @@
2323
*/
2424
public class ToneChatOptions extends GenericModel {
2525

26+
/**
27+
* The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`.
28+
*/
29+
public interface AcceptLanguage {
30+
/** ar. */
31+
String AR = "ar";
32+
/** de. */
33+
String DE = "de";
34+
/** en. */
35+
String EN = "en";
36+
/** es. */
37+
String ES = "es";
38+
/** fr. */
39+
String FR = "fr";
40+
/** it. */
41+
String IT = "it";
42+
/** ja. */
43+
String JA = "ja";
44+
/** ko. */
45+
String KO = "ko";
46+
/** pt-br. */
47+
String PT_BR = "pt-br";
48+
/** zh-cn. */
49+
String ZH_CN = "zh-cn";
50+
/** zh-tw. */
51+
String ZH_TW = "zh-tw";
52+
}
53+
2654
private List<Utterance> utterances;
55+
private String acceptLanguage;
2756

2857
/**
2958
* Builder.
3059
*/
3160
public static class Builder {
3261
private List<Utterance> utterances;
62+
private String acceptLanguage;
3363

3464
private Builder(ToneChatOptions toneChatOptions) {
3565
utterances = toneChatOptions.utterances;
66+
acceptLanguage = toneChatOptions.acceptLanguage;
3667
}
3768

3869
/**
@@ -85,11 +116,23 @@ public Builder utterances(List<Utterance> utterances) {
85116
this.utterances = utterances;
86117
return this;
87118
}
119+
120+
/**
121+
* Set the acceptLanguage.
122+
*
123+
* @param acceptLanguage the acceptLanguage
124+
* @return the ToneChatOptions builder
125+
*/
126+
public Builder acceptLanguage(String acceptLanguage) {
127+
this.acceptLanguage = acceptLanguage;
128+
return this;
129+
}
88130
}
89131

90132
private ToneChatOptions(Builder builder) {
91133
Validator.notNull(builder.utterances, "utterances cannot be null");
92134
utterances = builder.utterances;
135+
acceptLanguage = builder.acceptLanguage;
93136
}
94137

95138
/**
@@ -111,4 +154,15 @@ public Builder newBuilder() {
111154
public List<Utterance> utterances() {
112155
return utterances;
113156
}
157+
158+
/**
159+
* Gets the acceptLanguage.
160+
*
161+
* The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`.
162+
*
163+
* @return the acceptLanguage
164+
*/
165+
public String acceptLanguage() {
166+
return acceptLanguage;
167+
}
114168
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public class ToneChatScore extends GenericModel {
2929
/**
3030
* Gets the score.
3131
*
32-
* The score for the tone in the range of 0.5 to 1. A score greater than 0.75 indicates a high likelihood that the
33-
* tone is perceived in the utterance.
32+
* The score for the tone in the range of 0.5 to 1. A score greater than 0.75 indicates a high likelihood that the tone is perceived in the utterance.
3433
*
3534
* @return the score
3635
*/
@@ -41,9 +40,7 @@ public Double getScore() {
4140
/**
4241
* Gets the toneId.
4342
*
44-
* The unique, non-localized identifier of the tone for the results. The service can return results for the
45-
* following tone IDs: `sad`, `frustrated`, `satisfied`, `excited`, `polite`, `impolite`, and `sympathetic`. The
46-
* service returns results only for tones whose scores meet a minimum threshold of 0.5.
43+
* The unique, non-localized identifier of the tone for the results. The service can return results for the following tone IDs: `sad`, `frustrated`, `satisfied`, `excited`, `polite`, `impolite`, and `sympathetic`. The service returns results only for tones whose scores meet a minimum threshold of 0.5.
4744
*
4845
* @return the toneId
4946
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Builder newBuilder() {
8585
/**
8686
* Gets the text.
8787
*
88-
* The input content that the service is to analyze. Sentences with fewer than three words cannot be analyzed.
88+
* The input content that the service is to analyze.
8989
*
9090
* @return the text
9191
*/

0 commit comments

Comments
 (0)