tensorflow/lite/g3doc/api_docs/java/org/tensorflow/lite/task/text/nlclassifier/NLClassifier.html
public class NLClassifier
Classifier API for natural language classification tasks, categorizes string into different classes.
The API expects a TFLite model with the following input/output tensor:
Input tensor (kTfLiteString)
Output score tensor (kTfLiteUInt8/kTfLiteInt8/kTfLiteInt16/kTfLiteFloat32/kTfLiteFloat64/kTfLiteBool)
Optional Output label tensor (kTfLiteString/kTfLiteInt32)
output classname for each class, should be of the same length with scores. If this tensor is not present, the API uses score indices as classnames.
will be ignored if output score tensor already has an associated labe file.
By default the API tries to find the input/output tensors with default configurations in NLClassifier.NLClassifierOptions, with tensor name prioritized over tensor index. The option is configurable for different TFLite models.
| class | NLClassifier.NLClassifierOptions | Options to identify input and output tensors of the model. |
| List<Category> |
classify(String text)
Performs classification on a string input, returns classified Categorys.
|
| static NLClassifier |
createFromBufferAndOptions(ByteBuffer modelBuffer, NLClassifier.NLClassifierOptions options)
Creates NLClassifier with a model ByteBuffer and NLClassifier.NLClassifierOptions.
|
| static NLClassifier |
createFromFile(Context context, String modelPath)
Creates NLClassifier from default NLClassifier.NLClassifierOptions.
|
| static NLClassifier |
createFromFile(File modelFile)
Creates NLClassifier from default NLClassifier.NLClassifierOptions.
|
| static NLClassifier |
createFromFileAndOptions(File modelFile, NLClassifier.NLClassifierOptions options)
Creates NLClassifier from NLClassifier.NLClassifierOptions.
|
| static NLClassifier |
createFromFileAndOptions(Context context, String modelPath, NLClassifier.NLClassifierOptions options)
Creates NLClassifier from NLClassifier.NLClassifierOptions.
|
From class org.tensorflow.lite.task.core.BaseTaskApi
| synchronized void | close() Release the memory allocated from C++ and deregister the library from the static holder.
| | long | getNativeHandle() | | boolean | isClosed() |
From class java.lang.Object
| boolean | equals(Object arg0) | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |
From interface java.io.Closeable
| abstract void | close() |
From interface java.lang.AutoCloseable
| abstract void | close() |
Performs classification on a string input, returns classified Categorys.
| text | input text to the model |
Creates NLClassifier with a model ByteBuffer and NLClassifier.NLClassifierOptions.
| modelBuffer | a direct ByteBuffer or a MappedByteBuffer of the classification model |
| options | configurations for the model |
NLClassifier instance| IllegalStateException | if there is an internal error |
| RuntimeException | if there is an otherwise unspecified error |
| IllegalArgumentException | if the model buffer is not a direct ByteBuffer or a MappedByteBuffer |
Creates NLClassifier from default NLClassifier.NLClassifierOptions.
| context | Android context | | modelPath | path to the classification model relative to asset dir |
NLClassifier instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates NLClassifier from default NLClassifier.NLClassifierOptions.
| modelFile | the classification model File instance |
NLClassifier instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates NLClassifier from NLClassifier.NLClassifierOptions.
| modelFile | the classification model File instance |
| options | configurations for the model |
NLClassifier instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |
Creates NLClassifier from NLClassifier.NLClassifierOptions.
| context | Android context | | modelPath | path to the classification model relative to asset dir | | options | configurations for the model. |
NLClassifier instance| IOException | if model file fails to load | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |