Skip to content

Most visited

Recently visited

navigation

TextClassifier

public interface TextClassifier

android.view.textclassifier.TextClassifier


Interface for providing text classification related features.

Unless otherwise stated, methods of this interface are blocking operations and you should avoid calling them on the UI thread.

Summary

Constants

String TYPE_ADDRESS

String TYPE_EMAIL

String TYPE_OTHER

String TYPE_PHONE

String TYPE_URL

Fields

public static final TextClassifier NO_OP

No-op TextClassifier.

Public methods

abstract LinksInfo getLinks(CharSequence text, int linkMask, LocaleList defaultLocales)

Returns a LinksInfo that may be applied to the text to annotate it with links information.

abstract TextClassificationResult getTextClassificationResult(CharSequence text, int startIndex, int endIndex, LocaleList defaultLocales)

Returns a TextClassificationResult object that can be used to generate a widget for handling the classified text.

abstract TextSelection suggestSelection(CharSequence text, int selectionStartIndex, int selectionEndIndex, LocaleList defaultLocales)

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

Constants

TYPE_ADDRESS

String TYPE_ADDRESS

Constant Value: "address"

TYPE_EMAIL

String TYPE_EMAIL

Constant Value: "email"

TYPE_OTHER

String TYPE_OTHER

Constant Value: "other"

TYPE_PHONE

String TYPE_PHONE

Constant Value: "phone"

TYPE_URL

String TYPE_URL

Constant Value: "url"

Fields

NO_OP

TextClassifier NO_OP

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

Public methods

getLinks

LinksInfo getLinks (CharSequence text, 
                int linkMask, 
                LocaleList defaultLocales)

Returns a LinksInfo that may be applied to the text to annotate it with links information.

Parameters
text CharSequence: the text to generate annotations for
linkMask int: See Linkify for a list of linkMasks that may be specified. Subclasses of this interface may specify additional linkMasks
defaultLocales LocaleList: ordered list of locale preferences that can be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list in which case the classifier will decide whether to use no locale information, use a default locale, or use the system default.
Returns
LinksInfo
Throws
IllegalArgumentException if text is null

getTextClassificationResult

TextClassificationResult getTextClassificationResult (CharSequence text, 
                int startIndex, 
                int endIndex, 
                LocaleList defaultLocales)

Returns a TextClassificationResult object that can be used to generate a widget for handling the classified text.

Parameters
text CharSequence: text providing context for the text to classify (which is specified by the sub sequence starting at startIndex and ending at endIndex)
startIndex int: start index of the text to classify
endIndex int: end index of the text to classify
defaultLocales LocaleList: ordered list of locale preferences that can be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list in which case the classifier will decide whether to use no locale information, use a default locale, or use the system default.
Returns
TextClassificationResult
Throws
IllegalArgumentException if text is null; startIndex is negative; endIndex is greater than text.length() or not greater than startIndex

suggestSelection

TextSelection suggestSelection (CharSequence text, 
                int selectionStartIndex, 
                int selectionEndIndex, 
                LocaleList defaultLocales)

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

Parameters
text CharSequence: text providing context for the selected text (which is specified by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex)
selectionStartIndex int: start index of the selected part of text
selectionEndIndex int: end index of the selected part of text
defaultLocales LocaleList: ordered list of locale preferences that can be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list in which case the classifier will decide whether to use no locale information, use a default locale, or use the system default.
Returns
TextSelection
Throws
IllegalArgumentException if text is null; selectionStartIndex is negative; selectionEndIndex is greater than text.length() or not greater than selectionStartIndex
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.