/** * List classifiers. * * Returns an empty array if no classifiers are available. * * @return a {@link ServiceCall} with a response type of {@link ClassifierList} */ public ServiceCall<ClassifierList> listClassifiers() { return listClassifiers(null); }
/** * Instantiates a new `NaturalLanguageClassifier` with username and password. * * @param username the username * @param password the password */ public NaturalLanguageClassifier(String username, String password) { this(); setUsernameAndPassword(username, password); }
/** * Instantiates a new `NaturalLanguageClassifier` with IAM. Note that if the access token is specified in the * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token * before this * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors * after this token expires. * * @param iamOptions the options for authenticating through IAM */ public NaturalLanguageClassifier(IamOptions iamOptions) { this(); setIamCredentials(iamOptions); }
/** * Classify. * * This method is here for backwards-compatibility with the other version of classify. * * @param classifierId the classifier ID * @param text the submitted phrase to classify * @return the classification of a phrase with a given classifier */ public ServiceCall<Classification> classify(String classifierId, String text) { ClassifyOptions classifyOptions = new ClassifyOptions.Builder() .classifierId(classifierId) .text(text) .build(); return classify(classifyOptions); }
/** * Delete classifier. * * This method is here for backwards-compatibility with the old version of deleteClassifier. * * @param classifierId the classifier ID * @return the service call */ public ServiceCall<Void> deleteClassifier(String classifierId) { DeleteClassifierOptions deleteClassifierOptions = new DeleteClassifierOptions.Builder() .classifierId(classifierId) .build(); return deleteClassifier(deleteClassifierOptions); }
/** * Get information about a classifier. * * This method is here for backwards-compatibility with the old version of getClassifier. * * @param classifierId the classifier ID * @return the classifier */ public ServiceCall<Classifier> getClassifier(String classifierId) { GetClassifierOptions getClassifierOptions = new GetClassifierOptions.Builder() .classifierId(classifierId) .build(); return getClassifier(getClassifierOptions); }
@Override @Before public void setUp() throws Exception { super.setUp(); service = new NaturalLanguageClassifier(); service.setUsernameAndPassword("", ""); service.setEndPoint(getMockWebServerUrl()); classifierId = "foo"; classifiers = loadFixture(RESOURCE + "classifiers.json", ClassifierList.class); classifier = loadFixture(RESOURCE + "classifier.json", Classifier.class); classification = loadFixture(RESOURCE + "classification.json", Classification.class); classificationCollection = loadFixture(RESOURCE + "classification_collection.json", ClassificationCollection.class); }
/** * Test null delete classifier. */ @Test(expected = IllegalArgumentException.class) public void testNullDeleteClassifier() { DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() .build(); service.deleteClassifier(deleteOptions); }
/** * Instantiates a new `NaturalLanguageClassifier`. * */ public NaturalLanguageClassifier() { super(SERVICE_NAME); if ((getEndPoint() == null) || getEndPoint().isEmpty()) { setEndPoint(URL); } }
/** * Test null classifier. */ @Test(expected = IllegalArgumentException.class) public void testNullClassifier() { ClassifyOptions classifyOptions = new ClassifyOptions.Builder() .text("test") .build(); service.classify(classifyOptions); }
/** * Delete classifier. * * This method is here for backwards-compatibility with the old version of deleteClassifier. * * @param classifierId the classifier ID * @return the service call */ public ServiceCall<Void> deleteClassifier(String classifierId) { DeleteClassifierOptions deleteClassifierOptions = new DeleteClassifierOptions.Builder() .classifierId(classifierId) .build(); return deleteClassifier(deleteClassifierOptions); }
/** * Get information about a classifier. * * This method is here for backwards-compatibility with the old version of getClassifier. * * @param classifierId the classifier ID * @return the classifier */ public ServiceCall<Classifier> getClassifier(String classifierId) { GetClassifierOptions getClassifierOptions = new GetClassifierOptions.Builder() .classifierId(classifierId) .build(); return getClassifier(getClassifierOptions); }
/** * Instantiates a new `NaturalLanguageClassifier`. * */ public NaturalLanguageClassifier() { super(SERVICE_NAME); if ((getEndPoint() == null) || getEndPoint().isEmpty()) { setEndPoint(URL); } }
/** * List classifiers. * * This method is here for backwards-compatibility with the old version of getClassifiers, which has been renamed * to listClassifiers. * * @return the classifier list */ public ServiceCall<ClassifierList> getClassifiers() { return listClassifiers(); } }
/** * Instantiates a new `NaturalLanguageClassifier` with username and password. * * @param username the username * @param password the password */ public NaturalLanguageClassifier(String username, String password) { this(); setUsernameAndPassword(username, password); }
/** * Instantiates a new `NaturalLanguageClassifier` with IAM. Note that if the access token is specified in the * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token * before this * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors * after this token expires. * * @param iamOptions the options for authenticating through IAM */ public NaturalLanguageClassifier(IamOptions iamOptions) { this(); setIamCredentials(iamOptions); }
/** * Test null text. */ @Test(expected = IllegalArgumentException.class) public void testNullText() { ClassifyOptions classifyOptions = new ClassifyOptions.Builder() .classifierId(classifierId) .build(); service.classify(classifyOptions); }
/** * Test delete classifier. * * @throws InterruptedException the interrupted exception */ @Test public void testDeleteClassifier() throws InterruptedException { DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() .classifierId(classifierId) .build(); service.deleteClassifier(deleteOptions); }
/** * List classifiers. * * Returns an empty array if no classifiers are available. * * @return a {@link ServiceCall} with a response type of {@link ClassifierList} */ public ServiceCall<ClassifierList> listClassifiers() { return listClassifiers(null); }
/** * List classifiers. * * This method is here for backwards-compatibility with the old version of getClassifiers, which has been renamed * to listClassifiers. * * @return the classifier list */ public ServiceCall<ClassifierList> getClassifiers() { return listClassifiers(); } }