public abstract class TextClassifier


Interface for providing text classification related features. TextClassifier acts as a proxy to either the system provided TextClassifier, or an equivalent implementation provided by an app. Each instance of the class therefore represents one connection to the classifier implementation.

Unless otherwise stated, methods of this interface are blocking operations. Avoid calling them on the UI thread.

Summary

Nested types

public final class TextClassifier.EntityConfig

This class is deprecated.

Use android.view.textclassifier.TextClassifier.EntityConfig instead.

This class is deprecated.

Use android.view.textclassifier.TextClassifier.EntityConfig.Builder instead.

Constants

static final String
HINT_TEXT_IS_EDITABLE = "android.text_is_editable"

Designates that the text in question is editable.

static final String
HINT_TEXT_IS_NOT_EDITABLE = "android.text_is_not_editable"

Designates that the text in question is not editable.

static final TextClassifier

No-op TextClassifier.

static final String
TYPE_ADDRESS = "address"

Identifies a physical address.

static final String
TYPE_DATE = "date"

Time reference that is no more specific than a date.

static final String
TYPE_DATE_TIME = "datetime"

Time reference that includes a specific time.

static final String
TYPE_EMAIL = "email"

Identifies an e-mail address.

static final String

Flight number in IATA format.

static final String
TYPE_OTHER = "other"

Signifies that the classifier ran, but didn't recognize a know entity.

static final String
TYPE_PHONE = "phone"

Identifies a phone number.

static final String

Signifies that the TextClassifier did not identify an entity.

static final String
TYPE_URL = "url"

Identifies a URL.

static final String

The widget involved in the text classification session is a custom editable text widget.

static final String

The widget involved in the text classification session is a custom text widget.

static final String

The widget involved in the text classification session is a custom non-selectable text widget.

static final String

The widget involved in the text classification session is a standard android.widget.EditText.

static final String
WIDGET_TYPE_EDIT_WEBVIEW = "edit-webview"

The widget involved in the text classification session is a standard editable android.webkit.WebView.

static final String

The widget involved in the text classification session is a standard android.widget.TextView.

static final String

The widget involved in the text classification session is of an unknown/unspecified type.

static final String

The widget involved in the text classification session is a standard non-selectable android.widget.TextView.

static final String

The widget involved in the text classification session is a standard android.webkit.WebView.

Public constructors

Public methods

@NonNull TextClassification

Classifies the specified text and returns a TextClassification object that can be used to generate a widget for handling the classified text.

@NonNull TextLinks

Generates and returns a TextLinks that may be applied to the text to annotate it with links information.

int

Returns the maximal length of text that can be processed by generateLinks.

@NonNull ConversationActions

Suggests and returns a list of actions according to the given conversation.

@NonNull TextSelection

Returns suggested text selection start and end indices, recognized entity types, and their associated confidence scores.

Constants

HINT_TEXT_IS_EDITABLE

public static final String HINT_TEXT_IS_EDITABLE = "android.text_is_editable"

Designates that the text in question is editable.

HINT_TEXT_IS_NOT_EDITABLE

public static final String HINT_TEXT_IS_NOT_EDITABLE = "android.text_is_not_editable"

Designates that the text in question is not editable.

NO_OP

public static final TextClassifier NO_OP

No-op TextClassifier. This may be used to turn off text classifier features.

TYPE_ADDRESS

public static final String TYPE_ADDRESS = "address"

Identifies a physical address.

TYPE_DATE

public static final String TYPE_DATE = "date"

Time reference that is no more specific than a date. May be absolute such as "01/01/2000" or relative like "tomorrow".

TYPE_DATE_TIME

public static final String TYPE_DATE_TIME = "datetime"

Time reference that includes a specific time. May be absolute such as "01/01/2000 5:30pm" or relative like "tomorrow at 5:30pm".

TYPE_EMAIL

public static final String TYPE_EMAIL = "email"

Identifies an e-mail address.

TYPE_FLIGHT_NUMBER

public static final String TYPE_FLIGHT_NUMBER = "flight"

Flight number in IATA format.

TYPE_OTHER

public static final String TYPE_OTHER = "other"

Signifies that the classifier ran, but didn't recognize a know entity.

TYPE_PHONE

public static final String TYPE_PHONE = "phone"

Identifies a phone number.

TYPE_UNKNOWN

public static final String TYPE_UNKNOWN = ""

Signifies that the TextClassifier did not identify an entity.

TYPE_URL

public static final String TYPE_URL = "url"

Identifies a URL.

WIDGET_TYPE_CUSTOM_EDITTEXT

public static final String WIDGET_TYPE_CUSTOM_EDITTEXT = "customedit"

The widget involved in the text classification session is a custom editable text widget.

WIDGET_TYPE_CUSTOM_TEXTVIEW

public static final String WIDGET_TYPE_CUSTOM_TEXTVIEW = "customview"

The widget involved in the text classification session is a custom text widget.

WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW

public static final String WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW = "nosel-customview"

The widget involved in the text classification session is a custom non-selectable text widget.

WIDGET_TYPE_EDITTEXT

public static final String WIDGET_TYPE_EDITTEXT = "edittext"

The widget involved in the text classification session is a standard android.widget.EditText.

WIDGET_TYPE_EDIT_WEBVIEW

public static final String WIDGET_TYPE_EDIT_WEBVIEW = "edit-webview"

The widget involved in the text classification session is a standard editable android.webkit.WebView.

WIDGET_TYPE_TEXTVIEW

public static final String WIDGET_TYPE_TEXTVIEW = "textview"

The widget involved in the text classification session is a standard android.widget.TextView.

WIDGET_TYPE_UNKNOWN

public static final String WIDGET_TYPE_UNKNOWN = "unknown"

The widget involved in the text classification session is of an unknown/unspecified type.

WIDGET_TYPE_UNSELECTABLE_TEXTVIEW

public static final String WIDGET_TYPE_UNSELECTABLE_TEXTVIEW = "nosel-textview"

The widget involved in the text classification session is a standard non-selectable android.widget.TextView.

WIDGET_TYPE_WEBVIEW

public static final String WIDGET_TYPE_WEBVIEW = "webview"

The widget involved in the text classification session is a standard android.webkit.WebView.

Public constructors

TextClassifier

public TextClassifier()

Public methods

classifyText

@WorkerThread
public @NonNull TextClassification classifyText(@NonNull TextClassification.Request request)

Classifies the specified text and returns a TextClassification object that can be used to generate a widget for handling the classified text.

NOTE: Call on a worker thread.

Parameters
@NonNull TextClassification.Request request

the text classification request

generateLinks

@WorkerThread
public @NonNull TextLinks generateLinks(@NonNull TextLinks.Request request)

Generates and returns a TextLinks that may be applied to the text to annotate it with links information.

NOTE: Call on a worker thread.

Parameters
@NonNull TextLinks.Request request

the text links request

getMaxGenerateLinksTextLength

public int getMaxGenerateLinksTextLength()

Returns the maximal length of text that can be processed by generateLinks.

See also
generateLinks

suggestConversationActions

@WorkerThread
public @NonNull ConversationActions suggestConversationActions(@NonNull ConversationActions.Request request)

Suggests and returns a list of actions according to the given conversation.

suggestSelection

@WorkerThread
public @NonNull TextSelection suggestSelection(@NonNull TextSelection.Request request)

Returns suggested text selection start and end indices, recognized entity types, and their associated confidence scores. The entity types are ordered from highest to lowest scoring.

NOTE: Call on a worker thread.

Parameters
@NonNull TextSelection.Request request

the text selection request