@@ -209,59 +209,61 @@ public abstract static class Builder {
209209 private static final String NL_CLASSIFIER_NATIVE_LIBNAME = "task_text_jni" ;
210210
211211 /**
212- * Constructor to initialize the JNI with a pointer from C++ .
212+ * Creates {@link NLClassifier} from default {@link NLClassifierOptions} .
213213 *
214- * @param nativeHandle a pointer referencing memory allocated in C++.
215- */
216- protected NLClassifier (long nativeHandle ) {
217- super (nativeHandle );
218- }
219-
220- /**
221- * Create {@link NLClassifier} from default {@link NLClassifierOptions}.
222- *
223- * @param context Android context.
224- * @param pathToModel Path to the classification model relative to asset dir.
225- * @return {@link NLClassifier} instance.
226- * @throws IOException If model file fails to load.
214+ * @param context Android context
215+ * @param modelPath path to the classification model relative to asset dir
216+ * @return an {@link NLClassifier} instance
217+ * @throws IOException if model file fails to load
218+ * @throws IllegalArgumentException if an argument is invalid
219+ * @throws IllegalStateException if there is an internal error
220+ * @throws RuntimeException if there is an otherwise unspecified error
227221 */
228- public static NLClassifier createFromFile (Context context , String pathToModel )
229- throws IOException {
230- return createFromFileAndOptions (context , pathToModel , NLClassifierOptions .builder ().build ());
222+ public static NLClassifier createFromFile (Context context , String modelPath ) throws IOException {
223+ return createFromFileAndOptions (context , modelPath , NLClassifierOptions .builder ().build ());
231224 }
232225
233226 /**
234- * Create {@link NLClassifier} from default {@link NLClassifierOptions}.
227+ * Creates {@link NLClassifier} from default {@link NLClassifierOptions}.
235228 *
236- * @param modelFile The classification model {@link File} instance.
237- * @return {@link NLClassifier} instance.
238- * @throws IOException If model file fails to load.
229+ * @param modelFile the classification model {@link File} instance
230+ * @return an {@link NLClassifier} instance
231+ * @throws IOException if model file fails to load
232+ * @throws IllegalArgumentException if an argument is invalid
233+ * @throws IllegalStateException if there is an internal error
234+ * @throws RuntimeException if there is an otherwise unspecified error
239235 */
240236 public static NLClassifier createFromFile (File modelFile ) throws IOException {
241237 return createFromFileAndOptions (modelFile , NLClassifierOptions .builder ().build ());
242238 }
243239
244240 /**
245- * Create {@link NLClassifier} from {@link NLClassifierOptions}.
241+ * Creates {@link NLClassifier} from {@link NLClassifierOptions}.
246242 *
247243 * @param context Android context
248- * @param pathToModel Path to the classification model relative to asset dir.
249- * @param options Configurations for the model.
250- * @return {@link NLClassifier} instance.
251- * @throws IOException If model file fails to load.
244+ * @param modelPath path to the classification model relative to asset dir
245+ * @param options configurations for the model.
246+ * @return an {@link NLClassifier} instance
247+ * @throws IOException if model file fails to load
248+ * @throws IllegalArgumentException if an argument is invalid
249+ * @throws IllegalStateException if there is an internal error
250+ * @throws RuntimeException if there is an otherwise unspecified error
252251 */
253252 public static NLClassifier createFromFileAndOptions (
254- Context context , String pathToModel , NLClassifierOptions options ) throws IOException {
255- return createFromBufferAndOptions (TaskJniUtils .loadMappedFile (context , pathToModel ), options );
253+ Context context , String modelPath , NLClassifierOptions options ) throws IOException {
254+ return createFromBufferAndOptions (TaskJniUtils .loadMappedFile (context , modelPath ), options );
256255 }
257256
258257 /**
259- * Create {@link NLClassifier} from {@link NLClassifierOptions}.
258+ * Creates {@link NLClassifier} from {@link NLClassifierOptions}.
260259 *
261- * @param modelFile The classification model {@link File} instance.
262- * @param options Configurations for the model.
263- * @return {@link NLClassifier} instance.
264- * @throws IOException If model file fails to load.
260+ * @param modelFile the classification model {@link File} instance
261+ * @param options configurations for the model
262+ * @return an {@link NLClassifier} instance
263+ * @throws IOException if model file fails to load
264+ * @throws IllegalArgumentException if an argument is invalid
265+ * @throws IllegalStateException if there is an internal error
266+ * @throws RuntimeException if there is an otherwise unspecified error
265267 */
266268 public static NLClassifier createFromFileAndOptions (
267269 File modelFile , final NLClassifierOptions options ) throws IOException {
@@ -284,12 +286,14 @@ public long createHandle() {
284286 }
285287
286288 /**
287- * Create {@link NLClassifier} with a model {@link ByteBuffer} and {@link NLClassifierOptions}.
289+ * Creates {@link NLClassifier} with a model {@link ByteBuffer} and {@link NLClassifierOptions}.
288290 *
289291 * @param modelBuffer a direct {@link ByteBuffer} or a {@link MappedByteBuffer} of the
290292 * classification model
291- * @param options Configurations for the model
293+ * @param options configurations for the model
292294 * @return {@link NLClassifier} instance
295+ * @throws IllegalStateException if there is an internal error
296+ * @throws RuntimeException if there is an otherwise unspecified error
293297 * @throws IllegalArgumentException if the model buffer is not a direct {@link ByteBuffer} or a
294298 * {@link MappedByteBuffer}
295299 */
@@ -316,15 +320,29 @@ public long createHandle() {
316320 }
317321
318322 /**
319- * Perform classification on a string input, returns classified {@link Category}s.
323+ * Performs classification on a string input, returns classified {@link Category}s.
320324 *
321- * @param text input text to the model.
322- * @return A list of Category results.
325+ * @param text input text to the model
326+ * @return a list of Category results
323327 */
324328 public List <Category > classify (String text ) {
325329 return classifyNative (getNativeHandle (), text );
326330 }
327331
332+ /**
333+ * Constructor to initialize the JNI with a pointer from C++.
334+ *
335+ * @param nativeHandle a pointer referencing memory allocated in C++.
336+ */
337+ protected NLClassifier (long nativeHandle ) {
338+ super (nativeHandle );
339+ }
340+
341+ @ Override
342+ protected void deinit (long nativeHandle ) {
343+ deinitJni (nativeHandle );
344+ }
345+
328346 private static native long initJniWithByteBuffer (
329347 NLClassifierOptions options , ByteBuffer modelBuffer , long baseOptionsHandle );
330348
@@ -333,11 +351,6 @@ private static native long initJniWithFileDescriptor(
333351
334352 private static native List <Category > classifyNative (long nativeHandle , String text );
335353
336- @ Override
337- protected void deinit (long nativeHandle ) {
338- deinitJni (nativeHandle );
339- }
340-
341354 /**
342355 * Native implementation to release memory pointed by the pointer.
343356 *
0 commit comments