Search in sources :

Example 21 with Classifier

use of com.ibm.watson.visual_recognition.v3.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();
        }
    }
}
Also used : DeleteClassifierOptions(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.DeleteClassifierOptions) Classifier(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 22 with Classifier

use of com.ibm.watson.visual_recognition.v3.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());
}
Also used : GetClassifierOptions(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.GetClassifierOptions) AssumptionViolatedException(org.junit.AssumptionViolatedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Classifier(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 23 with Classifier

use of com.ibm.watson.visual_recognition.v3.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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GetClassifierOptions(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.GetClassifierOptions) Classifier(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier) Test(org.junit.Test) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest)

Example 24 with Classifier

use of com.ibm.watson.visual_recognition.v3.model.Classifier in project java-sdk by watson-developer-cloud.

the class VisualRecognitionIT method testDeleteAllClassifiers.

/**
 * Delete all the visual classifiers.
 */
@Test
@Ignore
public void testDeleteAllClassifiers() {
    List<Classifier> classifiers = service.listClassifiers(null).execute().getClassifiers();
    for (Classifier classifier : classifiers) {
        if (!classifier.getClassifierId().equals(classifierId)) {
            DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(classifier.getClassifierId()).build();
            service.deleteClassifier(deleteOptions).execute();
        }
    }
}
Also used : DeleteClassifierOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 25 with Classifier

use of com.ibm.watson.visual_recognition.v3.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().getClassifiers();
    for (Classifier classifier : classifiers) {
        if (classifier.isCoreMlEnabled()) {
            GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder().classifierId(classifier.getClassifierId()).build();
            InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute();
            assertNotNull(coreMlFile);
            break;
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ListClassifiersOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier) GetCoreMlModelOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 Classifier (com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier)13 File (java.io.File)12 Classifier (com.ibm.watson.visual_recognition.v3.model.Classifier)11 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)11 MockResponse (okhttp3.mockwebserver.MockResponse)9 Ignore (org.junit.Ignore)9 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)8 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)7 Classifier (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier)7 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)6 Classifier (com.ibm.watson.natural_language_classifier.v1.model.Classifier)6 InputStream (java.io.InputStream)6 MultipartBody (okhttp3.MultipartBody)6 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)5 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)5 Test (org.testng.annotations.Test)5 CreateClassifierOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions)4 FileInputStream (java.io.FileInputStream)4 HashMap (java.util.HashMap)4