Skip to content

Commit 4d06966

Browse files
Merge branch 'dev' of github.com:watson-developer-cloud/java-sdk into dev
2 parents 5902df2 + c321fd3 commit 4d06966

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class RelationshipExtraction extends WatsonService {
3838

3939
/** The dataset. */
4040
private Dataset dataset;
41+
42+
/** The return type. */
43+
private String returnType = "xml";
4144

4245
/**
4346
* Instantiates a new relationship extraction service.
@@ -65,15 +68,15 @@ public RelationshipExtraction() {
6568
*
6669
* @param text the text to analyze
6770
*
68-
* @return the result as XML string
71+
* @return the result as an XML/JSON string
6972
*/
7073
public String extract(final String text) {
7174
Validate.notNull(dataset, "dataset cannot be null");
7275
Validate.notNull(text, "text cannot be null");
7376

7477
final Request request =
7578
RequestBuilder.post("/v1/sire/0")
76-
.withForm("sid", dataset.getId(), "rt", "xml", "txt", text).build();
79+
.withForm("sid", dataset.getId(), "rt", returnType, "txt", text).build();
7780
final Response response = execute(request);
7881
return ResponseUtil.getString(response);
7982
}
@@ -96,5 +99,18 @@ public Dataset getDataset() {
9699
public void setDataset(final Dataset dataset) {
97100
this.dataset = dataset;
98101
}
102+
103+
/**
104+
* Sets the returnType.
105+
*
106+
* @param returnType the new returnType
107+
*/
108+
public void setReturnType(final ReturnType returnType) {
109+
if (returnType == ReturnType.XML) {
110+
this.returnType = "xml";
111+
} else if (returnType == ReturnType.JSON) {
112+
this.returnType = "json";
113+
}
114+
}
99115

100116
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.ibm.watson.developer_cloud.relationship_extraction.v1;
2+
3+
public enum ReturnType {
4+
XML,
5+
JSON
6+
}

0 commit comments

Comments
 (0)