use of com.ibm.watson.assistant.v2.model.BulkClassifyResponse in project java-sdk by watson-developer-cloud.
the class AssistantTest method testBulkClassifyWOptions.
// Test the bulkClassify operation with a valid options model parameter
@Test
public void testBulkClassifyWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}";
String bulkClassifyPath = "/v2/skills/testString/workspace/bulk_classify";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the BulkClassifyUtterance model
BulkClassifyUtterance bulkClassifyUtteranceModel = new BulkClassifyUtterance.Builder().text("testString").build();
// Construct an instance of the BulkClassifyOptions model
BulkClassifyOptions bulkClassifyOptionsModel = new BulkClassifyOptions.Builder().skillId("testString").input(new java.util.ArrayList<BulkClassifyUtterance>(java.util.Arrays.asList(bulkClassifyUtteranceModel))).build();
// Invoke bulkClassify() with a valid options model and verify the result
Response<BulkClassifyResponse> response = assistantService.bulkClassify(bulkClassifyOptionsModel).execute();
assertNotNull(response);
BulkClassifyResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, bulkClassifyPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.assistant.v2.model.BulkClassifyResponse in project java-sdk by watson-developer-cloud.
the class AssistantTest method testBulkClassifyWOptions.
// Test the bulkClassify operation with a valid options model parameter
@Test
public void testBulkClassifyWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}";
String bulkClassifyPath = "/v1/workspaces/testString/bulk_classify";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the BulkClassifyUtterance model
BulkClassifyUtterance bulkClassifyUtteranceModel = new BulkClassifyUtterance.Builder().text("testString").build();
// Construct an instance of the BulkClassifyOptions model
BulkClassifyOptions bulkClassifyOptionsModel = new BulkClassifyOptions.Builder().workspaceId("testString").input(new java.util.ArrayList<BulkClassifyUtterance>(java.util.Arrays.asList(bulkClassifyUtteranceModel))).build();
// Invoke bulkClassify() with a valid options model and verify the result
Response<BulkClassifyResponse> response = assistantService.bulkClassify(bulkClassifyOptionsModel).execute();
assertNotNull(response);
BulkClassifyResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, bulkClassifyPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.assistant.v2.model.BulkClassifyResponse in project java-sdk by watson-developer-cloud.
the class Assistant method bulkClassify.
/**
* Identify intents and entities in multiple user utterances.
*
* <p>Send multiple user inputs to a workspace in a single request and receive information about
* the intents and entities recognized in each input. This method is useful for testing and
* comparing the performance of different workspaces.
*
* <p>This method is available only with Enterprise with Data Isolation plans.
*
* @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse}
*/
public ServiceCall<BulkClassifyResponse> bulkClassify(BulkClassifyOptions bulkClassifyOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(bulkClassifyOptions, "bulkClassifyOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", bulkClassifyOptions.workspaceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/bulk_classify", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "bulkClassify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
final JsonObject contentJson = new JsonObject();
if (bulkClassifyOptions.input() != null) {
contentJson.add("input", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(bulkClassifyOptions.input()));
}
builder.bodyJson(contentJson);
ResponseConverter<BulkClassifyResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<BulkClassifyResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v2.model.BulkClassifyResponse in project java-sdk by watson-developer-cloud.
the class Assistant method bulkClassify.
/**
* Identify intents and entities in multiple user utterances.
*
* <p>Send multiple user inputs to a dialog skill in a single request and receive information
* about the intents and entities recognized in each input. This method is useful for testing and
* comparing the performance of different skills or skill versions.
*
* <p>This method is available only with Enterprise with Data Isolation plans.
*
* @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse}
*/
public ServiceCall<BulkClassifyResponse> bulkClassify(BulkClassifyOptions bulkClassifyOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(bulkClassifyOptions, "bulkClassifyOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("skill_id", bulkClassifyOptions.skillId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/skills/{skill_id}/workspace/bulk_classify", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "bulkClassify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
final JsonObject contentJson = new JsonObject();
if (bulkClassifyOptions.input() != null) {
contentJson.add("input", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(bulkClassifyOptions.input()));
}
builder.bodyJson(contentJson);
ResponseConverter<BulkClassifyResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<BulkClassifyResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations