TextClassifier
final class TextClassifierPerforms classification on text using a TensorFlow Lite model with optional metadata.
Supports BERT-tokenized, regex-tokenized, and raw string-input classification models, returning per-head category predictions filtered by the configured TextClassifierOptions.
-
Creates a text classifier from a local model file path using default classifier options.
Declaration
Swift
convenience init(modelPath: String) throwsParameters
modelPathFile-system path to a TensorFlow Lite model asset.
-
Creates a text classifier and initializes the underlying MediaPipe task graph.
Declaration
Swift
init(options: TextClassifierOptions) throwsParameters
optionsConfiguration specifying the model asset and classification filters.
-
Classifies the input string and returns predicted categories per model output head.
Declaration
Swift
final func classify(text: String) throws -> TextClassifierResultParameters
textUTF-8 string to classify.
Return Value
Classification predictions across all output heads of the model.