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

Constants

const String!
HINT_TEXT_IS_EDITABLE = "android.text_is_editable"

Designates that the text in question is editable.

const String!
HINT_TEXT_IS_NOT_EDITABLE = "android.text_is_not_editable"

Designates that the text in question is not editable.

const TextClassifier!

No-op TextClassifier.

const String!
TYPE_ADDRESS = "address"

Identifies a physical address.

const String!
TYPE_DATE = "date"

Time reference that is no more specific than a date.

const String!
TYPE_DATE_TIME = "datetime"

Time reference that includes a specific time.

const String!
TYPE_EMAIL = "email"

Identifies an e-mail address.

const String!

Flight number in IATA format.

const String!
TYPE_OTHER = "other"

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

const String!
TYPE_PHONE = "phone"

Identifies a phone number.

const String!

Signifies that the TextClassifier did not identify an entity.

const String!
TYPE_URL = "url"

Identifies a URL.

const String!

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

const String!

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

const String!

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

const String!

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

const String!
WIDGET_TYPE_EDIT_WEBVIEW = "edit-webview"

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

const String!

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

const String!

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

const String!

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

const String!

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

Public constructors

Public functions

TextClassification

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

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.

ConversationActions

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

TextSelection

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

Constants

HINT_TEXT_IS_EDITABLE

const val HINT_TEXT_IS_EDITABLE = "android.text_is_editable": String!

Designates that the text in question is editable.

HINT_TEXT_IS_NOT_EDITABLE

const val HINT_TEXT_IS_NOT_EDITABLE = "android.text_is_not_editable": String!

Designates that the text in question is not editable.

NO_OP

const val NO_OPTextClassifier!

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

TYPE_ADDRESS

const val TYPE_ADDRESS = "address": String!

Identifies a physical address.

TYPE_DATE

const val TYPE_DATE = "date": String!

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

const val TYPE_DATE_TIME = "datetime": String!

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

const val TYPE_EMAIL = "email": String!

Identifies an e-mail address.

TYPE_FLIGHT_NUMBER

const val TYPE_FLIGHT_NUMBER = "flight": String!

Flight number in IATA format.

TYPE_OTHER

const val TYPE_OTHER = "other": String!

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

TYPE_PHONE

const val TYPE_PHONE = "phone": String!

Identifies a phone number.

TYPE_UNKNOWN

const val TYPE_UNKNOWN = "": String!

Signifies that the TextClassifier did not identify an entity.

TYPE_URL

const val TYPE_URL = "url": String!

Identifies a URL.

WIDGET_TYPE_CUSTOM_EDITTEXT

const val WIDGET_TYPE_CUSTOM_EDITTEXT = "customedit": String!

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

WIDGET_TYPE_CUSTOM_TEXTVIEW

const val WIDGET_TYPE_CUSTOM_TEXTVIEW = "customview": String!

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

WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW

const val WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW = "nosel-customview": String!

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

WIDGET_TYPE_EDITTEXT

const val WIDGET_TYPE_EDITTEXT = "edittext": String!

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

WIDGET_TYPE_EDIT_WEBVIEW

const val WIDGET_TYPE_EDIT_WEBVIEW = "edit-webview": String!

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

WIDGET_TYPE_TEXTVIEW

const val WIDGET_TYPE_TEXTVIEW = "textview": String!

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

WIDGET_TYPE_UNKNOWN

const val WIDGET_TYPE_UNKNOWN = "unknown": String!

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

WIDGET_TYPE_UNSELECTABLE_TEXTVIEW

const val WIDGET_TYPE_UNSELECTABLE_TEXTVIEW = "nosel-textview": String!

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

WIDGET_TYPE_WEBVIEW

const val WIDGET_TYPE_WEBVIEW = "webview": String!

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

Public constructors

TextClassifier

TextClassifier()

Public functions

classifyText

@WorkerThread
fun classifyText(request: TextClassification.Request): TextClassification

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
request: TextClassification.Request

the text classification request

generateLinks

@WorkerThread
fun generateLinks(request: TextLinks.Request): TextLinks

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
request: TextLinks.Request

the text links request

getMaxGenerateLinksTextLength

fun getMaxGenerateLinksTextLength(): Int

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

See also
generateLinks

suggestConversationActions

@WorkerThread
fun suggestConversationActions(request: ConversationActions.Request): ConversationActions

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

suggestSelection

@WorkerThread
fun suggestSelection(request: TextSelection.Request): TextSelection

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
request: TextSelection.Request

the text selection request