LanguageDetector.LanguageDetectorOptions.Builder

public abstract class LanguageDetector.LanguageDetectorOptions.Builder


Builder for LanguageDetectorOptions.

Summary

Public constructors

Public methods

final LanguageDetector.LanguageDetectorOptions

Validates and builds the LanguageDetectorOptions instance.

abstract LanguageDetector.LanguageDetectorOptions.Builder

Sets the base options for the text classifier task.

abstract LanguageDetector.LanguageDetectorOptions.Builder
setCategoryAllowlist(List<String> categoryAllowlist)

Sets the optional allowlist of category names.

abstract LanguageDetector.LanguageDetectorOptions.Builder
setCategoryDenylist(List<String> categoryDenylist)

Sets the optional denylist of category names.

abstract LanguageDetector.LanguageDetectorOptions.Builder

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

abstract LanguageDetector.LanguageDetectorOptions.Builder
setMaxResults(Integer maxResults)

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

abstract LanguageDetector.LanguageDetectorOptions.Builder
setScoreThreshold(Float scoreThreshold)

Sets the optional score threshold.

Public constructors

Builder

public Builder()

Public methods

build

public final LanguageDetector.LanguageDetectorOptions build()

Validates and builds the LanguageDetectorOptions instance.

Throws
java.lang.IllegalArgumentException

if any of the set options are invalid.

setBaseOptions

public abstract LanguageDetector.LanguageDetectorOptions.Builder setBaseOptions(BaseOptions value)

Sets the base options for the text classifier task.

setCategoryAllowlist

public abstract LanguageDetector.LanguageDetectorOptions.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.

setCategoryDenylist

public abstract LanguageDetector.LanguageDetectorOptions.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.

setDisplayNamesLocale

public abstract LanguageDetector.LanguageDetectorOptions.Builder setDisplayNamesLocale(String locale)

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

setMaxResults

public abstract LanguageDetector.LanguageDetectorOptions.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.

setScoreThreshold

public abstract LanguageDetector.LanguageDetectorOptions.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.