|
25 | 25 | import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifiers; |
26 | 26 | import com.ibm.watson.developer_cloud.service.WatsonService; |
27 | 27 | import com.ibm.watson.developer_cloud.util.ResponseUtil; |
| 28 | +import com.ibm.watson.developer_cloud.util.Validate; |
28 | 29 | import com.squareup.okhttp.Headers; |
29 | 30 | import com.squareup.okhttp.MultipartBuilder; |
30 | 31 | import com.squareup.okhttp.Request; |
@@ -103,20 +104,20 @@ public Classification classify(final String classifierId, final String text) { |
103 | 104 | * this status for a while. |
104 | 105 | * |
105 | 106 | * @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' |
107 | 108 | * @param trainingData The set of questions and their "keys" used to adapt a system to a domain |
108 | 109 | * (the ground truth) |
109 | 110 | * @return the classifier |
110 | 111 | * @see Classifier |
111 | 112 | */ |
112 | 113 | public Classifier createClassifier(final String name, final String language, |
113 | 114 | 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 | + |
117 | 118 | final JsonObject contentJson = new JsonObject(); |
118 | 119 |
|
119 | | - contentJson.addProperty(LANGUAGE, language == null ? LANGUAGE_EN : language); |
| 120 | + contentJson.addProperty(LANGUAGE, language); |
120 | 121 |
|
121 | 122 | if (name != null && !name.isEmpty()) { |
122 | 123 | contentJson.addProperty(NAME, name); |
|
0 commit comments