use of com.ibm.watson.natural_language_classifier.v1.model.Classifier in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testUpdateClassifierWOptions.
@Test
public void testUpdateClassifierWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00.000Z\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
String updateClassifierPath = "/v3/classifiers/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the UpdateClassifierOptions model
UpdateClassifierOptions updateClassifierOptionsModel = new UpdateClassifierOptions.Builder().classifierId("testString").positiveExamples(mockStreamMap).negativeExamples(TestUtilities.createMockStream("This is a mock file.")).negativeExamplesFilename("testString").build();
// Invoke operation with valid options model (positive test)
Response<Classifier> response = visualRecognitionService.updateClassifier(updateClassifierOptionsModel).execute();
assertNotNull(response);
Classifier responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("version"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, updateClassifierPath);
}
use of com.ibm.watson.natural_language_classifier.v1.model.Classifier in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testGetCoreMlModel.
/**
* Test getting the Core ML file for a classifier.
*/
@Ignore
@Test
public void testGetCoreMlModel() {
ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
List<Classifier> classifiers = service.listClassifiers(options).execute().getResult().getClassifiers();
for (Classifier classifier : classifiers) {
if (classifier.isCoreMlEnabled()) {
GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder().classifierId(classifier.getClassifierId()).build();
InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute().getResult();
assertNotNull(coreMlFile);
break;
}
}
}
use of com.ibm.watson.natural_language_classifier.v1.model.Classifier in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierIT method eDelete.
/**
* Test delete classifier. Do not delete the pre created classifier. We need it for classify
*/
@Test
public void eDelete() {
List<Classifier> classifiers = service.listClassifiers().execute().getClassifiers();
for (Classifier classifier : classifiers) {
if (!classifier.getClassifierId().equals(preCreatedClassifierId)) {
DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder().classifierId(classifier.getClassifierId()).build();
service.deleteClassifier(deleteOptions).execute();
}
}
}
use of com.ibm.watson.natural_language_classifier.v1.model.Classifier in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierIT method bGetClassifier.
/**
* Test get classifier.
*/
@Test
public void bGetClassifier() {
final Classifier classifier;
try {
GetClassifierOptions getOptions = new GetClassifierOptions.Builder().classifierId(classifierId).build();
classifier = service.getClassifier(getOptions).execute();
} catch (NotFoundException e) {
// The build should not fail here, because this is out of our control.
throw new AssumptionViolatedException(e.getMessage(), e);
}
assertNotNull(classifier);
assertEquals(classifierId, classifier.getClassifierId());
assertEquals(Classifier.Status.TRAINING, classifier.getStatus());
}
use of com.ibm.watson.natural_language_classifier.v1.model.Classifier in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method testGetClassifier.
/**
* Test get classifier.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testGetClassifier() throws InterruptedException {
server.enqueue(jsonResponse(classifier));
GetClassifierOptions getOptions = new GetClassifierOptions.Builder().classifierId(classifierId).build();
final Classifier response = service.getClassifier(getOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(CLASSIFIERS_PATH + "/" + classifierId, request.getPath());
assertEquals(classifier, response);
}
Aggregations