TextClassifier.TextClassifierOptions.Builder

public static abstract class TextClassifier.TextClassifierOptions.Builder

Public Constructors

Public Methods

final TextClassifier.TextClassifierOptions
build()
Validates and builds the TextClassifier.TextClassifierOptions instance.
abstract TextClassifier.TextClassifierOptions.Builder
setBaseOptions(BaseOptions value)
Sets the base options for the text classifier task.
abstract TextClassifier.TextClassifierOptions.Builder
setCategoryAllowlist(List<String> categoryAllowlist)
Sets the optional allowlist of category names.
abstract TextClassifier.TextClassifierOptions.Builder
setCategoryDenylist(List<String> categoryDenylist)
Sets the optional denylist of category names.
abstract TextClassifier.TextClassifierOptions.Builder
setDisplayNamesLocale(String locale)
Sets the optional locale to use for display names specified through the TFLite Model Metadata, if any.
abstract TextClassifier.TextClassifierOptions.Builder
setMaxResults(Integer maxResults)
Sets the optional maximum number of top-scored classification results to return.
abstract TextClassifier.TextClassifierOptions.Builder
setScoreThreshold(Float scoreThreshold)
Sets the optional score threshold.

Inherited Methods

Public Constructors

public Builder ()

Public Methods

public final TextClassifier.TextClassifierOptions build ()

Validates and builds the TextClassifier.TextClassifierOptions instance.

Throws
IllegalArgumentException if any of the set options are invalid.

public abstract TextClassifier.TextClassifierOptions.Builder setBaseOptions (BaseOptions value)

Sets the base options for the text classifier task.

Parameters
value

public abstract TextClassifier.TextClassifierOptions.Builder setCategoryAllowlist (List<String> categoryAllowlist)

Sets the optional allowlist of category names.

If non-empty, detection results whose category name is not in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryDenylist.

Parameters
categoryAllowlist

public abstract TextClassifier.TextClassifierOptions.Builder setCategoryDenylist (List<String> categoryDenylist)

Sets the optional denylist of category names.

If non-empty, detection results whose category name is in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryAllowlist.

Parameters
categoryDenylist

public abstract TextClassifier.TextClassifierOptions.Builder setDisplayNamesLocale (String locale)

Sets the optional locale to use for display names specified through the TFLite Model Metadata, if any.

Parameters
locale

public abstract TextClassifier.TextClassifierOptions.Builder setMaxResults (Integer maxResults)

Sets the optional maximum number of top-scored classification results to return.

If not set, all available results are returned. If set, must be > 0.

Parameters
maxResults

public abstract TextClassifier.TextClassifierOptions.Builder setScoreThreshold (Float scoreThreshold)

Sets the optional score threshold. Results with score below this value are rejected.

Overrides the score threshold specified in the TFLite Model Metadata, if any.

Parameters
scoreThreshold