TextClassificationManager


public final class TextClassificationManager


Class to handle the creation of TextClassifier.

Summary

Public methods

@NonNull TextClassifier

Returns the default text classifier provided by this library.

@NonNull TextClassifier

Returns the text classifier set through setTextClassifier, a default text classifier is returned if it is not ever set, or a null is set.

static TextClassificationManager
of(@NonNull Context context)

Returns an instance of TextClassificationManager for the specified context.

void

Sets a preferred text classifier.

Public methods

getDefaultTextClassifier

public @NonNull TextClassifier getDefaultTextClassifier()

Returns the default text classifier provided by this library.

This is mainly for text classifier implementation to delegate the request to the default text classifier. Otherwise, in most cases, you shuold consider getTextClassifier instead.

Note that the returned text classifier should be only used within the same context that is passed to of.

getTextClassifier

public @NonNull TextClassifier getTextClassifier()

Returns the text classifier set through setTextClassifier, a default text classifier is returned if it is not ever set, or a null is set.

If you are implementing a text classifier, and want to delegate requests to the default text classifier provided by this library, you may want to use getDefaultTextClassifier instead.

of

public static TextClassificationManager of(@NonNull Context context)

Returns an instance of TextClassificationManager for the specified context. Each context has its own TextClassificationManager.

setTextClassifier

public void setTextClassifier(@Nullable TextClassifier textClassifier)

Sets a preferred text classifier.

To turn off the feature completely, you can set a NO_OP. If null is set, default text classifier is used.

Note that the given text classifier is only set to this instance of the TextClassificationManager.