use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method testClassifyCollection.
/**
* Test classifying a collection.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testClassifyCollection() throws InterruptedException {
final String path = String.format(CLASSIFY_COLLECTION_PATH, classifierId);
server.enqueue(jsonResponse(classificationCollection));
ClassifyInput input1 = new ClassifyInput();
input1.setText("How hot will it be today?");
ClassifyInput input2 = new ClassifyInput();
input2.setText("Is it hot outside?");
List<ClassifyInput> inputCollection = Arrays.asList(input1, input2);
ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder().classifierId(classifierId).collection(inputCollection).build();
final ClassificationCollection result = service.classifyCollection(classifyOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
assertEquals(classificationCollection, result);
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method testClassify.
/**
* Test classify.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testClassify() throws InterruptedException {
final JsonObject contentJson = new JsonObject();
contentJson.addProperty(TEXT, classification.getText());
final String path = String.format(CLASSIFY_PATH, classifierId);
server.enqueue(jsonResponse(classification));
ClassifyOptions classifyOptions = new ClassifyOptions.Builder().classifierId(classifierId).text(classification.getText()).build();
final Classification result = service.classify(classifyOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
assertEquals(contentJson.toString(), request.getBody().readUtf8());
assertEquals(classification, result);
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromUrl.
/**
* Test classify images from url.
*/
@Test
public void testClassifyImagesFromUrl() {
ClassifyOptions options = new ClassifyOptions.Builder().url(IMAGE_URL).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromFile.
/**
* Test classify images from zip file.
*/
@Test
public void testClassifyImagesFromFile() throws FileNotFoundException {
File images = new File(IMAGE_FILE);
ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(images).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromUrlUsingParameters.
/**
* Test classify images from url using the deprecated parameters option.
*/
@Test
public void testClassifyImagesFromUrlUsingParameters() {
String parameters = "{\"url\":\"" + IMAGE_URL + "\"}";
ClassifyOptions options = new ClassifyOptions.Builder().parameters(parameters).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
Aggregations