Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class RelationshipExtraction extends WatsonService {

/** The dataset. */
private Dataset dataset;

/** The return type. */
private String returnType = "xml";

/**
* Instantiates a new relationship extraction service.
Expand Down Expand Up @@ -65,15 +68,15 @@ public RelationshipExtraction() {
*
* @param text the text to analyze
*
* @return the result as XML string
* @return the result as an XML/JSON string
*/
public String extract(final String text) {
Validate.notNull(dataset, "dataset cannot be null");
Validate.notNull(text, "text cannot be null");

final Request request =
RequestBuilder.post("/v1/sire/0")
.withForm("sid", dataset.getId(), "rt", "xml", "txt", text).build();
.withForm("sid", dataset.getId(), "rt", returnType, "txt", text).build();
final Response response = execute(request);
return ResponseUtil.getString(response);
}
Expand All @@ -96,5 +99,18 @@ public Dataset getDataset() {
public void setDataset(final Dataset dataset) {
this.dataset = dataset;
}

/**
* Sets the returnType.
*
* @param returnType the new returnType
*/
public void setReturnType(final ReturnType returnType) {
if (returnType == ReturnType.XML) {
this.returnType = "xml";
} else if (returnType == ReturnType.JSON) {
this.returnType = "json";
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.ibm.watson.developer_cloud.relationship_extraction.v1;

public enum ReturnType {
XML,
JSON
}