Skip to content

Commit 5294920

Browse files
make language required when creating a classifier
1 parent bef94d9 commit 5294920

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifiers;
2626
import com.ibm.watson.developer_cloud.service.WatsonService;
2727
import com.ibm.watson.developer_cloud.util.ResponseUtil;
28+
import com.ibm.watson.developer_cloud.util.Validate;
2829
import com.squareup.okhttp.Headers;
2930
import com.squareup.okhttp.MultipartBuilder;
3031
import com.squareup.okhttp.Request;
@@ -103,20 +104,20 @@ public Classification classify(final String classifierId, final String text) {
103104
* this status for a while.
104105
*
105106
* @param name the classifier name
106-
* @param language IETF primary language for the classifier
107+
* @param language IETF primary language for the classifier. for example: 'en'
107108
* @param trainingData The set of questions and their "keys" used to adapt a system to a domain
108109
* (the ground truth)
109110
* @return the classifier
110111
* @see Classifier
111112
*/
112113
public Classifier createClassifier(final String name, final String language,
113114
final File trainingData) {
114-
if (trainingData == null || !trainingData.exists())
115-
throw new IllegalArgumentException("trainingData cannot be null or not be found");
116-
115+
Validate.isTrue(trainingData == null || !trainingData.exists(),"trainingData cannot be null or not be found");
116+
Validate.isTrue(language == null || !language.isEmpty(),"language cannot be null or empty");
117+
117118
final JsonObject contentJson = new JsonObject();
118119

119-
contentJson.addProperty(LANGUAGE, language == null ? LANGUAGE_EN : language);
120+
contentJson.addProperty(LANGUAGE, language);
120121

121122
if (name != null && !name.isEmpty()) {
122123
contentJson.addProperty(NAME, name);

0 commit comments

Comments
 (0)