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
TextClassification
|
classifyText(CharSequence text, int startIndex, int endIndex, LocaleList defaultLocales)
Classifies the specified text and returns a |
abstract
TextSelection
|
suggestSelection(CharSequence text, int selectionStartIndex, int selectionEndIndex, LocaleList defaultLocales)
Returns suggested text selection indices, recognized types and their associated confidence scores. |
Constants
Fields
NO_OP
TextClassifier NO_OP
No-op TextClassifier. This may be used to turn off TextClassifier features.
Public methods
classifyText
TextClassification classifyText (CharSequence text, int startIndex, int endIndex, LocaleList defaultLocales)
Classifies the specified text and returns a TextClassification object that can be
used to generate a widget for handling the classified text.
This method may take several seconds to complete, so it should only be called from a worker thread.
| 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)This value must never be |
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.This value may be |
| Returns | |
|---|---|
TextClassification |
This value will never be |
| 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.
This method may take several seconds to complete, so it should only be called from a worker thread.
| Parameters | |
|---|---|
text |
CharSequence: text providing context for the selected text (which is specified
by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex)This value must never be |
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.This value may be |
| Returns | |
|---|---|
TextSelection |
This value will never be |
| Throws | |
|---|---|
IllegalArgumentException |
if text is null; selectionStartIndex is negative; selectionEndIndex is greater than text.length() or not greater than selectionStartIndex |